studio
latest
false
重要 :
このコンテンツの一部は機械翻訳によって処理されており、完全な翻訳を保証するものではありません。 新しいコンテンツの翻訳は、およそ 1 ~ 2 週間で公開されます。
UiPath logo, featuring letters U and I in white

Studio ガイド

最終更新日時 2025年5月29日

インポートしたライブラリ プロジェクトをコード化されたオートメーションで使用する

このチュートリアルでは、インポートしたライブラリ プロジェクトから取得したオブジェクトをコード化されたオートメーション内で使用する方法について説明します。この例では、インポートしたライブラリ プロジェクトから取得したオブジェクト リポジトリの要素とワークフローを使用する方法を示します。指定のシナリオでは、ACME Web サイトを自動化して、学生のスコア カードに必要事項を入力し、それをデータベースに追加します。

前提条件

  • UI Automation アクティビティ パッケージのバージョン 23.10.13 以降をインストールします。
    注: 使用しているメジャー バージョンに対応する最新のマイナー バージョンを使用することをお勧めします。たとえば、メジャー バージョン 23.10 のアクティビティ パッケージを使用している場合は、利用可能な最新のマイナー バージョン (23.10.x) にアップグレードすることをお勧めします。
  • ACME ライブラリのサンプルをパブリッシュし、作業中のプロジェクトにインストールします。

1. ライブラリ プロジェクトを作成する

ACME アプリの自動化 (厳密には学生のスコア カードへの入力) に不可欠な UI 要素を格納するライブラリ プロジェクトを作成します。さらに、ライブラリ プロジェクト内にローコード (.xaml) またはコード化されたワークフロー (.cs) を作成します。これは、後で別のコード化されたオートメーション内で使用するものです。
  1. AcmeLibrary という名前のライブラリ プロジェクトを作成します。
  2. [オブジェクト リポジトリ][記述子] セクション内で使用する、すべての UI 要素をキャプチャします。
  3. [ファイル] グループから、新しいコード化されたワークフローを作成します。

    この手順は、別のプロジェクトにライブラリをインポートするときに、コード化されたオートメーション内のオブジェクト リポジトリにアクセスできるようにするために重要です。

  4. Main ローコード ワークフローの名前を Send message box に変更し、[メッセージ ボックス] アクティビティを、「You've added a new score card for a student in Acme. (ACME の学生用に新しいスコア カードを追加しました。)」というテキストと共に追加します。
    注: チュートリアルで説明されている手順に従って、[メッセージ ボックス] アクティビティをコード化されたワークフローとして再作成することもできます。
  5. ライブラリ プロジェクトを保存し、フィードにパブリッシュします。

    このパブリッシュされたライブラリは、コード化されたオートメーション内の別のプロジェクトにインストールして使用します。

2. コード化されたオートメーションを作成する

ライブラリ プロジェクトの作成後、それを別のプロジェクトにインストールして、その再利用可能なアセット (オブジェクト リポジトリの要素やワークフローなど) を、それらがローコード (.xaml) かコード化 (.cs) かにかかわらず活用します。
Tip: When using UI Automation coded automation APIs, remember that the overloads with IScreenDescriptor or IElementDescriptor are intended to work with Object Repository elements, while the overloads with TargetAnchorableModel are meant for use with native selectors obtained through the UI Explorer. Visit UI Automation coded automation APIs to learn how to leverage selectors with UI Automation coded automation APIs.
  1. [ファイル] グループから、新しいコード化されたワークフローを作成します。
  2. [パッケージを管理] に移動し、以前に作成したライブラリ プロジェクトをインストールします。
  3. [ファイル] グループから、新しいワークフローを作成します。
    1. ワークフローに notifyStudentScoreCardAdded という名前を付けます。
    2. [アクティビティ] パネル、[インストール済み] セクションの順に移動します。
    3. インポートしたライブラリ プロジェクトの名前 (この例では AcmeLibrary) を検索します。
    4. Send message box アクティビティを notifyStudentScoreCardAdded 内にドラッグ アンド ドロップします。
      これで、notifyStudentScoreCardAdded の動作は、インポートしたライブラリ プロジェクトから取得した Send message box ワークフローと同じになります。
  4. 読みやすくするために、インポートしたオブジェクト リポジトリ アプリケーションを変数として定義し、ワークフローの先頭に 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;
  5. Now you can automate the given scenario within Acme. Start by opening the Acme login screen using the Open coded automation API.
    [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);
  6. Type in the necessary credentials for logging into Acme, using the TypeInto coded automation API.
    // 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");
  7. Use the Click coded automation API, along with a native selector, to click the Login button.
    // 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'/>"));
  8. The login process takes you to the Dashboard screen in the Acme web application. Therefore, use the Attach coded automation API to focus on the new screen.
    // 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);
  9. Select the Students entry on the website, using the Click coded automation API.
    // 5. Click the Students entry
    DashboardScreen.Click(AcmeApp.Acme.Dashboard.Students);// 5. Click the Students entry
    DashboardScreen.Click(AcmeApp.Acme.Dashboard.Students);
  10. Select Score card to open the Students - Score Card form, using the Click coded automation API.
    // 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);
  11. Focus on the Students - Score Card screen, using the Attach coded automation API.
    // 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);
  12. Fill in half of the fields in the Students - Score Card form using the TypeInto coded automation API, and elements from the Object Repository.
    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");
  13. Fill in the rest of the fields in the form using the TypeInto coded automation API in combination with native selectors that you discover through the 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");
  14. Select Add score card details using the Click coded automation API.
    // 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);
  15. RunWorkflow() メソッドを使用して、ライブラリ プロジェクトからインポートしたワークフローを呼び出します。このメソッドにプロジェクト内のワークフローのパスを指定します。
    // 11. Invoke imported workflow from library
    RunWorkflow("notifyStudentScoreCardAdded.xaml");// 11. Invoke imported workflow from library
    RunWorkflow("notifyStudentScoreCardAdded.xaml");
  16. Close the browser tabs you opened to automate the scenario, using the Dispose() coded automation 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();

サンプル プロジェクト

To follow the steps and try out the tutorial yourself, see the following sample project: Using imported library projects in coded automations. The file contains the library project, as well.

このページは役に立ちましたか?

サポートを受ける
RPA について学ぶ - オートメーション コース
UiPath コミュニティ フォーラム
Uipath Logo White