Build a bot to extract and translate text
- Updated: 2020/05/12
Build a bot to extract and translate text
Build a bot to extract text from a page and use a prebuilt Bot Store bot to translate the text into English.
Prerequisites
- To capture UI objects from a web page, ensure you have installed the product-specific Automation Anywhere Enterprise extension to automate web applications in Google Chrome.
- Ensure that you are familiar with how to Build your first bot using Object Cloning command to follow the process in this procedure.
Procedure
- Log in to the Enterprise Client.
- Click New.
- In the Automate window, click Workbench.
-
Open the Variable Manager, click Add,
and add the following variable names:
- vExtractedText: stores the extracted text from the website.
- vOutputLanguage: stores the target language text.
- vTranslatedText: stores the translated English text.
- From the Commands tab, select and drag the Open Program/File command to the Actions List.
-
In the
Open Program/File
window, perform these
steps:
-
Step 1: Program/File Path: Browse and select the
Google Chrome executable file. Find the file location on your machine,
which can be: C:\Program Files
(x86)\Google\Chrome\Application. In the
Application folder, select
chrome.exe
. - Step 2: Start in Path: You can skip this step.
- Step 3: Parameters: Enter the URL for the Automation Anywhere translate page: https://www.automationanywhere.com/automationanywherelabs/translate.html
- Click Save to close the command.
The first command appears in the Actions List. -
Step 1: Program/File Path: Browse and select the
Google Chrome executable file. Find the file location on your machine,
which can be: C:\Program Files
(x86)\Google\Chrome\Application. In the
Application folder, select
-
Click Save to save your bot as
Tutorial2_Translate.atmx.
By default, the bot is saved in the My Tasks directory.
- Click Run to test it.
- From the Commands tab, select and drag the Object Cloning command to the Actions List.
- In the Object Cloning window, select Automation Anywhere Labs - Translate - Google Chrome. Verify that the target browser session is open in its own window.
-
With the
Object Cloning
window open, click and
hold the Capture button. While still holding the left
mouse button, highlight the Text to Decode block of text
until a red border blinks around it. Now release the button.
- In the Select Action to Perform drop-down list, select Get Property.
- In the Select Property drop-down list, select HTML InnerText .
- In the Assign to Variable drop-down list, select vExtractedText.
- Click Save.
-
From the Commands tab, select the
String Operation
, click the + sign, and select
and drag the Before-After command to the Actions List.
- In the String Operation window, in the Source String text box, enter vExtractedText.
- In the Before (Optional) field, enter Text to Decode.
- In the Assign the output to variable field, enter vExtractedText.
- Click Save.
- In a new browser window, navigate to http://botstore.automationanywhere.com. Search for the Bing Translate Bot, download and install it.
-
In Workbench, click the MetaBots
tab. Select and drag BingTranslate.mbot to the Actions
List. In the MetaBot window, set the following input and
output parameters:
-
In the Input Parameters field, add values for
the following parameters:
- vInputText: vExtractedText
- vOutputLanguage: vOutputLanguage
- In the Output Parameters field, add a value for the vOutputText: vTranslatedText.
- Click Save.
-
In the Input Parameters field, add values for
the following parameters:
- In the Object Cloning window, select Automation Anywhere Labs - Translate - Google Chrome.
-
With the
Object Cloning
window open, click and
hold the Capture button. While still holding the left
mouse button, highlight the Enter Translated Message Here to
Validate input field until a red border blinks around it. Now
release the button.
- In the Select Action to Perform drop-down list, select Set Text.
- In the Text to Set field, enter vTranslatedText.
- Click Save.
- In the Object Cloning window, select Automation Anywhere Labs - Translate - Google Chrome.
-
With the
Object Cloning
window open, click and
hold the Capture button. While still holding the left
mouse button, highlight the Submit button until a red
border blinks around it. Now release the button.
- In the Select Action to Perform field, select Left Click.
- Click Save.
- Save your bot and click Run.