- 基本情報
- セットアップと構成
- オートメーション プロジェクト
- 依存関係
- ワークフローの種類
- 制御フロー
- ファイルの比較
- オートメーションのベスト プラクティス
- ソース管理との連携
- デバッグ
- ログ
- 診断ツール
- ワークフロー アナライザー
- ワークフロー アナライザーについて
- ST-DBP-002 - 多数の引数
- ST-DBP-003 - 空の catch ブロック
- ST-DBP-007 - 複数のフローチャートレイヤー
- ST-DPB-010 - [ワークフロー] または [テスト ケース] の複数のインスタンス
- ST-DBP-020 - 未定義の出力プロパティ
- ST-DBP-021 - ハードコードされたタイムアウト
- ST-DBP-023 - 空のワークフロー
- ST-DBP-024 - 永続性アクティビティの確認
- ST-DBP-025 - 変数のシリアル化の前提条件
- ST-DBP-027 - Persistence のベスト プラクティス
- ST-DBP-028 - 引数のシリアル化の前提条件
- ST-USG-005 - ハードコードされたアクティビティのプロパティ
- ST-USG-009 - 未使用の変数
- ST-USG-010 - 未使用の依存関係
- ST-USG-014 - パッケージの制限
- ST-USG-017 - パラメーターの修飾子が無効
- ST-USG-020 - 最小ログ メッセージ
- ST-USG-024 - 未使用で保存されたままの値
- ST-USG-025 - 保存した値の誤用
- ST-USG-026 - アクティビティの制限
- ST-USG-027 - 必要なパッケージ
- ST-USG-028 - ファイル テンプレートの呼び出しの制限
- ST-USG-027 - 必須のタグ
- ST-USG-034 - Automation Hub URL
- 変数
- 引数
- インポートされた名前空間
- コード化されたオートメーション
- トリガーベースの有人オートメーション
- オブジェクト リポジトリ
- ScreenScrapeJavaSupport ツール
- 拡張機能
- Studio でのテスト
- トラブルシューティング

Studio ガイド
インポートしたライブラリ プロジェクトをコード化されたオートメーションで使用する
このチュートリアルでは、インポートしたライブラリ プロジェクトから取得したオブジェクトをコード化されたオートメーション内で使用する方法について説明します。この例では、インポートしたライブラリ プロジェクトから取得したオブジェクト リポジトリの要素とワークフローを使用する方法を示します。指定のシナリオでは、ACME Web サイトを自動化して、学生のスコア カードに必要事項を入力し、それをデータベースに追加します。
前提条件
- UI Automation アクティビティ パッケージのバージョン 23.10.13 以降をインストールします。
注:
使用しているメジャー バージョンに対応する最新のマイナー バージョンを使用することをお勧めします。たとえば、メジャー バージョン 23.10 のアクティビティ パッケージを使用している場合は、利用可能な最新のマイナー バージョン (
23.10.x) にアップグレードすることをお勧めします。 - ACME ライブラリのサンプルをパブリッシュし、作業中のプロジェクトにインストールします。
1. ライブラリ プロジェクトを作成する
ACME アプリの自動化 (厳密には学生のスコア カードへの入力) に不可欠な UI 要素を格納するライブラリ プロジェクトを作成します。さらに、ライブラリ プロジェクト内にローコード (.xaml) またはコード化されたワークフロー (.cs) を作成します。これは、後で別のコード化されたオートメーション内で使用するものです。
AcmeLibraryという名前のライブラリ プロジェクトを作成します。- [オブジェクト リポジトリ] と [記述子] セクション内で使用する、すべての UI 要素をキャプチャします。
- [ファイル] グループから、新しいコード化されたワークフローを作成します。 この手順は、別のプロジェクトにライブラリをインポートするときに、コード化されたオートメーション内のオブジェクト リポジトリにアクセスできるようにするために重要です。
- Main ローコード ワークフローの名前を
Send message boxに変更し、[メッセージ ボックス] アクティビティを、「You've added a new score card for a student in Acme. (ACME の学生用に新しいスコア カードを追加しました。)」というテキストと共に追加します。注:チュートリアルで説明されている手順に従って、[ メッセージ ボックス ] アクティビティをコード化されたワークフローとして再作成することもできます。
- ライブラリ プロジェクトを保存し、フィードにパブリッシュします。 このパブリッシュされたライブラリは、コード化されたオートメーション内の別のプロジェクトにインストールして使用します。
2. コード化されたオートメーションを作成する
ライブラリ プロジェクトの作成後、それを別のプロジェクトにインストールして、その再利用可能なアセット (オブジェクト リポジトリの要素やワークフローなど) を、それらがローコード (.xaml) かコード化 (.cs) かにかかわらず活用します。
UI Automation のコード化されたオートメーション API を使用する場合、 IScreenDescriptor または IElementDescriptor を含むオーバー ロードはオブジェクト リポジトリの要素を操作するためのものであるのに対し、 TargetAnchorableModel を含むオーバー ロードは UI Explorer で取得されたネイティブ セレクターで使用するためのものであることに注意してください。UI Automation のコード化されたオートメーション API でセレクターを活用する方法について詳しくは、 UI Automation のコード化されたオートメーション API をご覧ください。
-
[ファイル] グループから、新しいコード化されたワークフローを作成します。
-
[パッケージを管理] に移動し、以前に作成したライブラリ プロジェクトをインストールします。
-
[ファイル] グループから、新しいワークフローを作成します。
- ワークフローに
notifyStudentScoreCardAddedという名前を付けます。 - [アクティビティ] パネル、[インストール済み] セクションの順に移動します。
- インポートしたライブラリ プロジェクトの名前 (この例では
AcmeLibrary) を検索します。 - [
Send message box] アクティビティを [notifyStudentScoreCardAdded内にドラッグ アンド ドロップします。これで、notifyStudentScoreCardAddedの動作は、インポートしたライブラリ プロジェクトから取得したSend message boxワークフローと同じになります。
- ワークフローに
-
読みやすくするために、インポートしたオブジェクト リポジトリ アプリケーションを変数として定義し、ワークフローの先頭に
usingステートメントを適用できます。以下に例を示します。using app = <ProjectName>.ObjectRepository.Descriptors
この方法では、app.<AppName>.<ScreenName>.<UiElementName> 形式で記述子を簡単に呼び出すことができます。
この例では、ACME オブジェクト リポジトリを次のように定義します。
namespace UsingImportedLibraryProjects
{
using AcmeApp = AcmeLibrary.ObjectRepository.Descriptors;
namespace UsingImportedLibraryProjects
{
using AcmeApp = AcmeLibrary.ObjectRepository.Descriptors;
- これで、ACME 内で指定のシナリオを自動化できるようになりました。最初に、Open のコード化されたオートメーション API を使用して ACME のログイン画面を開きます。
[Workflow] public void Execute() { // 1.Open the Acme app on the Login screen var AcmeLoginScreen = uiAutomation.Open(AcmeApp.Acme.LoginScreen);[Workflow] public void Execute() { // 1.Open the Acme app on the Login screen var AcmeLoginScreen = uiAutomation.Open(AcmeApp.Acme.LoginScreen); - TypeInto のコード化されたオートメーション API を使用して、ACME にログインするために必要な資格情報を入力します。
// 2.Type in the necessary credentials AcmeLoginScreen.TypeInto(AcmeApp.Acme.LoginScreen.Email, "john.doe2023@uipath.com"); AcmeLoginScreen.TypeInto(AcmeApp.Acme.LoginScreen.Password, "12345678");// 2.Type in the necessary credentials AcmeLoginScreen.TypeInto(AcmeApp.Acme.LoginScreen.Email, "john.doe2023@uipath.com"); AcmeLoginScreen.TypeInto(AcmeApp.Acme.LoginScreen.Password, "12345678"); - Click のコード化されたオートメーション API とネイティブ セレクターを使用して、[Login] ボタンをクリックします。
// 3.Use a native selector to click the Login button AcmeLoginScreen.Click(Target.FromSelector("<webctrl tag='BUTTON' type='submit'/>"));// 3.Use a native selector to click the Login button AcmeLoginScreen.Click(Target.FromSelector("<webctrl tag='BUTTON' type='submit'/>")); - ログイン プロセスが実行されると、ACME Web アプリケーションの [Dashboard] 画面が表示されます。そのため、Attach のコード化されたオートメーション API を使用して新しい画面にフォーカスします。
// 4. Focus on the Dashboard screen var DashboardScreen = uiAutomation.Attach(AcmeApp.Acme.Dashboard);// 4. Focus on the Dashboard screen var DashboardScreen = uiAutomation.Attach(AcmeApp.Acme.Dashboard); - Click のコード化されたオートメーション API を使用して、Web サイトで [Students] エントリを選択します。
// 5. Click the Students entry DashboardScreen.Click(AcmeApp.Acme.Dashboard.Students);// 5. Click the Students entry DashboardScreen.Click(AcmeApp.Acme.Dashboard.Students); - Click のコード化されたオートメーション API を使用して、[Score card] を選択し、[Students - Score Card] フォームを開きます。
// 6. Click Score card, to start filling in a student score card DashboardScreen.Click(AcmeApp.Acme.Dashboard.Students.ScoreCard);// 6. Click Score card, to start filling in a student score card DashboardScreen.Click(AcmeApp.Acme.Dashboard.Students.ScoreCard); - Attach のコード化されたオートメーション API を使用して、[Students - Score Card] 画面にフォーカスします。
// 7. Focus on the Score Card screen where you fill in the necessary information var ScoreCardScreen = uiAutomation.Attach(AcmeApp.Acme.StudentsScoreCard);// 7. Focus on the Score Card screen where you fill in the necessary information var ScoreCardScreen = uiAutomation.Attach(AcmeApp.Acme.StudentsScoreCard); - TypeInto のコード化されたオートメーション API を使用して、[Students - Score Card] フォームのフィールドの半分と、オブジェクト リポジトリから取得した要素に入力します。
ScoreCardScreen.TypeInto(AcmeApp.StudentsScoreCard.StudentEmail, "john.doe@uipath.com"); ScoreCardScreen.TypeInto(AcmeApp.Acme.StudentsScoreCard.FirstName, "John"); ScoreCardScreen.TypeInto(AcmeApp.Acme.StudentsScoreCard.LastName, "Doe"); ScoreCardScreen.TypeInto(AcmeApp.Acme.StudentsScoreCard.ParentEmail, "johnny.doe@uipath.com"); ScoreCardScreen.TypeInto(AcmeApp.Acme.StudentsScoreCard.Tuition, "Private");ScoreCardScreen.TypeInto(AcmeApp.StudentsScoreCard.StudentEmail, "john.doe@uipath.com"); ScoreCardScreen.TypeInto(AcmeApp.Acme.StudentsScoreCard.FirstName, "John"); ScoreCardScreen.TypeInto(AcmeApp.Acme.StudentsScoreCard.LastName, "Doe"); ScoreCardScreen.TypeInto(AcmeApp.Acme.StudentsScoreCard.ParentEmail, "johnny.doe@uipath.com"); ScoreCardScreen.TypeInto(AcmeApp.Acme.StudentsScoreCard.Tuition, "Private"); - TypeInto のコード化されたオートメーション API と、UI Explorer で見つけたネイティブ セレクターを組み合わせて使用し、フォームの残りのフィールドに入力します。
ScoreCardScreen.TypeInto(Target.FromSelector("<webctrl id='mathematics' tag='INPUT' />"), "A"); ScoreCardScreen.TypeInto(Target.FromSelector("<webctrl id='physics' tag='INPUT' />"), "B"); ScoreCardScreen.TypeInto(Target.FromSelector("<webctrl id='biology' tag='INPUT' />"), "C"); ScoreCardScreen.TypeInto(Target.FromSelector("<webctrl id='chemistry' tag='INPUT' />"), "A"); ScoreCardScreen.TypeInto(Target.FromSelector("<webctrl id='geography' tag='INPUT' />"), "C"); ScoreCardScreen.TypeInto(Target.FromSelector("<webctrl id='history' tag='INPUT' />"), "A"); ScoreCardScreen.TypeInto(Target.FromSelector("<webctrl id='english' tag='INPUT' />"), "A"); ScoreCardScreen.TypeInto(Target.FromSelector("<webctrl id='computer Science' tag='INPUT' />"), "C"); ScoreCardScreen.TypeInto(Target.FromSelector("<webctrl id='professorComments' tag='INPUT' />"), "The student is doing okay, very hardworking and does its best");ScoreCardScreen.TypeInto(Target.FromSelector("<webctrl id='mathematics' tag='INPUT' />"), "A"); ScoreCardScreen.TypeInto(Target.FromSelector("<webctrl id='physics' tag='INPUT' />"), "B"); ScoreCardScreen.TypeInto(Target.FromSelector("<webctrl id='biology' tag='INPUT' />"), "C"); ScoreCardScreen.TypeInto(Target.FromSelector("<webctrl id='chemistry' tag='INPUT' />"), "A"); ScoreCardScreen.TypeInto(Target.FromSelector("<webctrl id='geography' tag='INPUT' />"), "C"); ScoreCardScreen.TypeInto(Target.FromSelector("<webctrl id='history' tag='INPUT' />"), "A"); ScoreCardScreen.TypeInto(Target.FromSelector("<webctrl id='english' tag='INPUT' />"), "A"); ScoreCardScreen.TypeInto(Target.FromSelector("<webctrl id='computer Science' tag='INPUT' />"), "C"); ScoreCardScreen.TypeInto(Target.FromSelector("<webctrl id='professorComments' tag='INPUT' />"), "The student is doing okay, very hardworking and does its best"); - Click のコード化されたオートメーション API を使用して、[Add score card details] を選択します。
// 10. Click the "Add score card details" button using an Object Repository descriptor ScoreCardScreen.Click(AcmeApp.Acme.StudentsScoreCard.AddScoreCardDetailsButton);// 10. Click the "Add score card details" button using an Object Repository descriptor ScoreCardScreen.Click(AcmeApp.Acme.StudentsScoreCard.AddScoreCardDetailsButton); RunWorkflow()メソッドを使用して、ライブラリ プロジェクトからインポートしたワークフローを呼び出します。このメソッドにプロジェクト内のワークフローのパスを指定します。// 11. Invoke imported workflow from library RunWorkflow("notifyStudentScoreCardAdded.xaml");// 11. Invoke imported workflow from library RunWorkflow("notifyStudentScoreCardAdded.xaml");Dispose()のコード化されたオートメーション API を使用して、シナリオを自動化するために開いたブラウザー タブを閉じます。// 12. Close the applications/browsers you opened, to finish he automation ScoreCardScreen.Dispose();// 12. Close the applications/browsers you opened, to finish he automation ScoreCardScreen.Dispose();
サンプル プロジェクトの
この手順に従ってチュートリアルをご自身で試してみるには、「Using imported library projects in coded automations (インポートしたライブラリ プロジェクトをコード化されたオートメーションで使用する)」というサンプル プロジェクトをご覧ください。このファイルには、ライブラリ プロジェクトも含まれています。