studio
2023.10
false
Wichtig :
Es kann 1–2 Wochen dauern, bis die Lokalisierung neu veröffentlichter Inhalte verfügbar ist.
UiPath logo, featuring letters U and I in white

Studio-Benutzerhandbuch

Letzte Aktualisierung 4. Juni 2025

Verwenden importierter Bibliotheksprojekte in codierten Automatisierungen

Dieses Tutorial zeigt Ihnen, wie Sie Objekte aus importierten Bibliotheksprojekten in codierten Automatisierungen verwenden. Das Beispiel veranschaulicht, wie Object Repository-Elemente und Workflows aus einem importierten Bibliotheksprojekt verwendet werden. Das angegebene Szenario beinhaltet die Automatisierung der Acme-Website, um eine Bewertungskarte für Studenten auszufüllen und zur Datenbank hinzuzufügen.

Voraussetzungen

  • Installieren Sie die UIAutomation-Aktivitäten Version 23.10.13 oder höher.
    Hinweis: Wir empfehlen Ihnen, die neueste Nebenversion zu verwenden, die der Hauptversion entspricht, mit der Sie arbeiten. Wenn Sie beispielsweise die Hauptversion 23.10 der Aktivitätspakete verwenden, empfehlen wir Ihnen, diese auf die neueste verfügbare Nebenversion (23.10.x) zu aktualisieren.
  • Veröffentlichen Sie das Acme-Bibliotheksbeispiel, und installieren Sie es in dem Projekt, in dem Sie arbeiten.

1. Erstellen Sie das Bibliotheksprojekt

Erstellen Sie ein Bibliotheksprojekt, um die wesentlichen UI-Elemente für die Automatisierung der Acme-App zu speichern, insbesondere zum Ausfüllen einer Bewertungskarte für einen Studenten. Erstellen Sie außerdem einen Low-Code (.xaml) oder codierten Workflow (.cs) innerhalb des Bibliotheksprojekts, den Sie später in einer anderen codierten Automatisierung verwenden werden.
  1. Erstellen Sie ein Bibliotheksprojekt namens AcmeLibrary.
  2. Erfassen Sie alle UI-Elemente, die Sie im Object-Repository und im Abschnitt Deskriptoren verwenden möchten.
  3. Erstellen Sie einen neuen codierten Workflow aus der Gruppe Datei.

    Dieser Schritt ist entscheidend, um den Zugriff auf das Object-Repository innerhalb einer codierten Automatisierung zu ermöglichen, wenn die Bibliothek in ein anderes Projekt importiert wird.

  4. Benennen Sie den Low-Code-Hauptworkflow in Send message box um und fügen Sie eine Aktivität Message Box mit dem folgenden Text hinzu: „Sie haben eine neue Bewertungskarte für einen Studenten in Acme hinzugefügt.“
    Hinweis: Sie können die Aktivität Message Box auch als codierten Workflow neu erstellen, indem Sie die im Tutorial beschriebenen Schritte ausführen.
  5. Speichern und veröffentlichen Sie das Bibliotheksprojekt in einem Feed.

    Sie installieren und verwenden diese veröffentlichte Bibliothek in einem anderen Projekt innerhalb einer codierten Automatisierung.

2. Erstellen Sie die codierte Automatisierung

Nachdem Sie das Bibliotheksprojekt erstellt haben, installieren Sie es in einem anderen Projekt, um dessen wiederverwendbare Assets zu nutzen, einschließlich Object Repository-Elementen und Workflows, ob Low-Code (.xaml) oder codiert (.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. Erstellen Sie in der Gruppe Datei einen neuen codierten Workflow.
  2. Wechseln Sie zu Pakete verwalten und installieren Sie das zuvor erstellte Bibliotheksprojekt.
  3. Erstellen Sie in der Gruppe Datei einen neuen Workflow.
    1. Nennen Sie den Workflow notifyStudentScoreCardAdded.
    2. Navigieren Sie zum Bereich Aktivitäten zum Abschnitt Installiert.
    3. Suchen Sie nach dem Namen des importierten Bibliotheksprojekts (zum Beispiel AcmeLibrary).
    4. Ziehen Sie die Aktivität Send message box in notifyStudentScoreCardAddedund legen Sie sie dort ab.
      Jetzt hat notifyStudentScoreCardAdded das gleiche Verhalten wie derSend message box-Workflow aus dem importierten Bibliotheksprojekt.
  4. Um die Lesbarkeit zu verbessern, können Sie die importierte Object Repository-Anwendung als Variable definieren, indem Sie eine using-Anweisung zu Beginn Ihres Workflows anwenden. Hier ist ein Beispiel: using app = <ProjectName>.ObjectRepository.Descriptors.
    Mit diesem Ansatz können Sie Deskriptoren einfach im folgenden Format aufrufen: app.<AppName>.<ScreenName>.<UiElementName>
    In diesem Beispiel definieren wir das Acme Object-Repository wie folgt:
    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. Rufen Sie den Workflow auf, den Sie mit der RunWorkflow()-Methode aus dem Bibliotheksprojekt importiert haben. Geben Sie die Methode mit dem Pfad des Workflows innerhalb des Projekts an.
    // 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();

Beispielprojekt

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.

War diese Seite hilfreich?

Hilfe erhalten
RPA lernen – Automatisierungskurse
UiPath Community-Forum
Uipath Logo White