WORK WITH THE BROWSER

The «Work with the browser» module is based on the Selenium WebDriver and allows implementing basic elements with working with a browser page – open tab, пgo to the tab, find the element on the page by its key and process it.

Module interface

The module window is divided into the part of creating a command for working with a browser, a group of action control buttons and a table containing a list of created commands. Part of creating a command consists of several fields to fill out, and the number of these fields varies depending on the selected action in the «Action» field. The group of buttons consists of the following buttons – «Add», «Edit» and «Delete».

![Screenshot](img/WB_1.png)

Creating a command starts with selecting an action. After selecting it, the list of available fields in the window may change. You need to fill out the fields that are required for the action to work and click «Add». The created action is gonna be listed in the «Action list» table. To edit a command you need to select it in the list, edit the desired fields and then press the «Edit» button. But if you press the «Add» button, a new action is gonna be added but with the changes you made while editing. You can simply not change anything and click «Add», then the command is gonna be copied.

To delete actions you need to select it in the list and press the «Delete» button.

You can change the order of the commands by pressing the arrow keys that are located in the top right corner. It's really simple to do, first select the row tje position of which you wanna change, then click the arrow keys to move it.

![Screenshot](img/WB_2.png)

For all actions these three fields never change «Driver», «Action» and «Note».

The «Driver» field is currently unavailable for editing and the default driver for the Chrome browser is selected in it, but in the future it is planned to supplement this list with other browsers.

The «Action» field — is a drop-down list with all possible actions for this module. More detailed review of them is gonna be in the next chapter.

The «Note» field — a row with a note for the command. ## Description of actions

Module offers 7 main actions – go to the page, reload the page, go back and forward, work with the page, work with tabs, and close the browser. Each action requires filling in some kind of fields

Please note that it is advisable to close the browser opened using this module, too, otherwise, if you close the browser yourself and then try to continue working with it using this module, an error will occur and you will have to restart the program. ### Go to

Action goes to the specified page. The «URL» field is added.

![Screenshot](img/WB_3.png)

If any page is already open, then it will go from it to the specified one, meaning that the original page will be replaced with a new one. If the browser has not yet been launched, it will be opened with this page. ### Reload the page

Action reloads the already opened page, before using the action make sure the page is opened. ### Go back

Goes to the page that was open before the current one. ### Go forward

Goes to the page that was opened after the current one. ### Working with a page

This action provides the ability to work with a specific item of the page. The following fields will appear when configuring the action – «Item search type», «Search line», «Page action», «Variable», «Waiting (sec)» и «Item number».

![Screenshot](img/WB_4.png)

The «Item search type» field is a drop-down list with a list of search methods for the element on the page, it is used in conjunction with the «Search line» field. Below will be listed all types of searches for an element with examples of filling the «Search line» field:

• GetElementsByName – search for elements by their name property.

![Screenshot](img/WB_5.png)

• GetElementsById – search for elements by their id property.

![Screenshot](img/WB_6.png)

• GetElementsByClass – search for elements by their class property.

![Screenshot](img/WB_7.png)

• GetElementsByCssSelector – search for elements by their css property.

![Screenshot](img/WB_8.png)

• GetElementByLinkText – search for link elements in text. Only items with a complete match are searched.

![Screenshot](img/WB_9.png)

• GetElementsByPartialLinkText - search for link elements by their text. All items containing the given line are searched.

![Screenshot](img/WB_10.png)

• GetElementsByTagName – search for elements by their tag.

![Screenshot](img/WB_11.png)

• GetElementsByXPath – search for elements by HTML – xpath query language.

![Screenshot](img/WB_12.png)

The «Page action» field offers a selection of an action from the drop-down list that must be performed on the found elements. The following actions are suggested:

● Record – enters specified text into the «Variable» field (for example, after clicking on a specific element to enter text);

● Get text - gets the value of the text properties of all found or specifically selected elements and returns the result as a list to the variable;

● Send - press ENTER - use the recorded data (for example, any text can be entered with actions «Record», and then «Send» it);

● Click – left-click on a specified element (filling out the «Item number» field is required);

● Hover over a cursor – hovers over a specific element(filling out the «Item number» field is required);

● Get Property – when choosing an action the «Property name» field appears - returns the value of the specified in the «Property name» field property of all found elements or the specified as a list into the variable;

● Get CSS property – when choosing an action the «CSS property» field appears - returns the value of the specified in the «CSS property» field property of all found elements or the specified as a list into the variable;

● Get Attribute – when choosing an action the «Attribute property» field appears - returns the value of the specified in the «Attribute property» field property of all found elements or the specified as a list into the variable;

In the «Variable» field the name of a variable is entered starting with «@», in which the result of the executed command is gonna be put in, or otherwise from which the values for executing a command are gonna be taken from.

The «Waiting (sec)» field – the amount of seconds robot needs to wait after executing a command.

The «Item number» field – one index of the found item to which the action must be applied

An example of the filled out action:

![Screenshot](img/WB_13.png)

Here, the element with the name «q» is searched and the text «search» is put in it. ### Work with tabs

This action allows manipulating with tabs in the browser window. For configuring at least one field is added – «Action», and other fields appear after you select the action.

![Screenshot](img/WB_14.png)

Available actions for working with tabs - add, close, go to the tab and get tab amount. More detailed description of them:

● Add tab - adds a new tab, the tab automatically becomes active;

● Close tab - closes the active tab;

● Go to the tab – when choosing this action the «Tab number» field will appear - goes to the tab the number of which is specified in the «Tab number» field (starting with 0);

● Get tab amount –when choosing this action the «Variable» field will appear - returns the amount of tabs into the specified variable. ### Close browser

Closes the browser.