Studio
2023.10
バナーの背景画像
Studio ガイド
最終更新日 2024年4月26日

コード化された最初のテスト ケースを作成する

This tutorial provides step-by-step instructions for creating a coded test case that types information into a web form and verifies it using UiPath® Test Manager. To automate the web form and access it, the example uses Object Repository elements and UIAutomation. You can access the sample form here.
前提条件
  1. コード化されたテスト ケースを作成します。[ファイル] グループから、[新規][コード化されたテスト ケース] の順に選択します。
    テスト ケースのコードは、Given-When-Then テンプレートと同様に、3 つの部分 (Arrange-Act-Assert) に分かれています。
    • Arrange – テスト データを設定します。
    • Act – テスト ケースのステップを実行します。
    • Assert – テスト ケースの結果を検証します。
  2. テスト アプリケーションから UI 要素を取得して、コード化されたテスト ケースで使用できるようにします。この例では、Web フォームから UI 要素を取得します。[オブジェクト リポジトリ] タブに移動し、TestForm という名前のアプリケーションを作成します。
  3. TestForm アプリケーション内に TestFormScreen という名前の画面を作成し、Web フォームが開かれている Chrome タブを指定します。


  4. TestFormScreen 内で、すべてのフォーム フィールドの要素とフォーム内のボタンを作成します。UI 要素はアルファベットの昇順で並べられます。


  5. UI Automation およびテスト サービスを使用して、コード化されたテスト ケースの設計を開始します。
  6. Arrange セクションでは、UI Automation サービスと Open および TypeInto API を使用し、Web フォームを開いてテスト データを入力します。この例では、次のコード サンプルを使用します。
    var screen = uiAutomation.Open(ObjectRepository.Descriptors.TestForm.TestFormScreen);
                screen.TypeInto(ObjectRepository.Descriptors.TestForm.TestFormScreen.Name, "John Doe");
                screen.TypeInto(ObjectRepository.Descriptors.TestForm.TestFormScreen.Email, "john.doe@uipath.com");
                screen.TypeInto(ObjectRepository.Descriptors.TestForm.TestFormScreen.Password, "1234");
                screen.TypeInto(ObjectRepository.Descriptors.TestForm.TestFormScreen.ConfirmPassword, "1234");var screen = uiAutomation.Open(ObjectRepository.Descriptors.TestForm.TestFormScreen);
                screen.TypeInto(ObjectRepository.Descriptors.TestForm.TestFormScreen.Name, "John Doe");
                screen.TypeInto(ObjectRepository.Descriptors.TestForm.TestFormScreen.Email, "john.doe@uipath.com");
                screen.TypeInto(ObjectRepository.Descriptors.TestForm.TestFormScreen.Password, "1234");
                screen.TypeInto(ObjectRepository.Descriptors.TestForm.TestFormScreen.ConfirmPassword, "1234");
    
    ヒント: Studio IDE 内で IntelliSense を使用します。Ctrl+Space を押して、以下の場合に IntelliSense を使用します。
    • コードのオートコンプリート。
    • API ドキュメントの読み取り – API のパラメーターの読み取り。コード化されたオートメーション エコシステムでは、API パラメーターはアクティビティのプロパティと同等です。




  7. Act セクションに、フォームを送信するアクションを入力します。この例では、以下のコード サンプルを使用します。
    screen.Click("Submit");screen.Click("Submit");


  8. Assert セクションで、Testing サービスと VerifyExpression API を使用して、Verification 内のテキストが手順 6 で入力したユーザー名かどうかを確認します。この例では、次のコード サンプルを使用します。
    testing.VerifyExpression(screen.GetText("Verification") == "John Doe");testing.VerifyExpression(screen.GetText("Verification") == "John Doe");


サンプル プロジェクト

この手順に従ってチュートリアルを自分で試してみるには、サンプル プロジェクト「First coded test case (初めてのコード化されたテスト ケース)」をダウンロードします。

  • サンプル プロジェクト

Was this page helpful?

サポートを受ける
RPA について学ぶ - オートメーション コース
UiPath コミュニティ フォーラム
UiPath ロゴ (白)
信頼とセキュリティ
© 2005-2024 UiPath. All rights reserved.