Clicking on elements and associating tabs

Develop a script to navigate two web pages, associate tabs, and manipulate elements, such as assigning values ​​to fields and obtaining values ​​from a field.

Before you begin

To develop the script, you need:

  • IBM RPA Studio 20.12.0 or higher
  • One of the supported browsers:
    • Google Chrome
    • Mozilla Firefox
    • Internet Explorer
    • Microsoft Edge
  • Stable internet connection
  • Use the Designer tab in IBM RPA Studio

You can search commands in IBM RPA Studio's toolbox using the command's label or its verb.

Procedure

Starting the browser

You need to create a new instance of the browser to navigate to an web page:

  1. In the Home tab, click the New variable button to define a new variable.
    1. In the Name input parameter, insert the value instanceName.
    2. In the Variable Type input parameter, select the Text option.
    3. In the Value input parameter, insert the value browser-instance.
  2. Insert the Start Browser command into the script.
    1. In the Instance name input parameter, insert the variable ${instanceName}.
    2. In the Browser Type input parameter, select a browser available on your machine.

The Close Browser command closes the web automation scope. It is automatically inserted into the script when saving the Start Browser command definition.

  1. In the Close Browser command, insert the values:
    1. In the Instance name input parameter, insert the variable ${instanceName}.
    2. Toggle the Keep browser open input parameter on.
Note:Insert the commands to manipulate the elements of the web page between the Start Browser and Close Browser commands.

In this step, navigate to the web page of the W3Schools External page website:

  1. Insert the Navigate command inside the instruction block of the Start Browser and Close Browser commands.
    1. In the URL input parameter, insert the value https://www.w3schools.com/html/html_form_input_types.asp.

Manipulation of elements

Click the Try it yourself button in the Input Type Text topic. A new tab in the browser opens for you to associate the new tab context with the current browsing context:

  1. Insert the Wait for Webpage Requests command in the script.
    1. In the Timeout input parameter, insert the value 00:00:30.
  2. Insert the Click on Web Page command in the script.
    1. In the Search for input parameter, select the Css option.
    2. In the CSS input parameter, insert the value #main > div: nth-child (14) > a.
    3. In the Timeout input parameter, insert the value 00:01:00.
  3. Insert the Find or Attach Tab command into the script.
    1. In the Timeout input parameter, insert the value 00:00:30.

Setting value to the fields

Use the Set Value to Field command to assign​​ values to fields:

  1. Insert the Set Value to Field command in the script.
    1. In the Value input parameter, insert the value Your first name.
    2. In the Selector Type input parameter, select the Id option.
    3. In the ID input parameter, insert the value fname.
    4. In the Timeout input parameter, insert the value 00:00:30.
  2. Insert the Set Value to Field command again in the script.
    1. In the Value input parameter, insert the value Your last name.
    2. In the Selector Type input parameter, select the Id option.
    3. In the ID input parameter, insert the value lname.
    4. In the Timeout input parameter, insert the value 00:00:30.

Use the Click on Web Page command again to click on the Submit button of the form.

  1. Insert the Click on Web Page command in the script.
    1. In the Search for input parameter, select the Css option.
    2. In the CSS input parameter, insert the value body > form> input [type=submit]:nth-child (10).
    3. In the Timeout input parameter, insert the value 00:01:00.

Getting values

Use the Get Element Value command to get the value of the user input field in the form:

  1. Insert the Get Element Value command into the script.
    1. In the Selector type input parameter, select the Css option.
    2. In the CSS element input parameter, insert the value body > div.w3-container.w3-large.w3 -border.
    3. In the Timeout input parameter, insert the value 00:00:30.
    4. In the Value output parameter, insert the value valueObtained.

Finishing the navigation

  1. Insert the If command in the script.
    1. In the Left operator input parameter, insert the variable ${valueObtained}.
    2. In the Operator input parameter, select the option Is null or empty.
    3. Enable the Negate input parameter.

The End If command ends this block of instructions. It is automatically inserted into the script when saving the If command.

  1. Insert the Log message command in the If statement block.
    1. In the Message input parameter, insert the value Text input received: ${valueObtained}.
  2. Insert the Else command after the Log message command.
  3. Insert the Log message command after the Else command.
    1. In the Message input parameter, insert the value Problems while submitting the form.

What to do next

Run the script by clicking the Start button on IBM RPA Studio's Home tab.