Locators

Before describing the WEB related commands, it is necessary to know how to create a locator and connect it to a scenario.

Available types of locators:

  • id
  • class
  • xpath
  • cssSelector
  • text

Locator for commands can be written in two types:

  1. locator - locators are created in special folders with names that can be used in different scenarios without duplicating the entire locator.
  2. Directly in the field for the locator - the locator is entered in the field in its entirety each time.

To create locators for the l__ocator field you need:

  • To create a file in the locators folder with the name of the page or component (e.g: loginPages.xml)

    • component folder - contains files from page components that do not change according to the page (it can be a footer, a header). Also, for use, these locators must be included in the pages file required for use;
    • pages folder - contains files of different pages that change according to the link.
  • All files with locators have the required scheme format inside this file.

XML
Copy
  • Fill in the <details> tag, enter the name, URL, and description information about this page.
XML
Copy
  • You can also use a component locator file inside a page locator file:
XML
Copy
  • After the <details> block, open the <locators> tag where you can write an unlimited number of <locator>.
XML
Copy
  • To give a unique name to the locator’s element, which must start with a lowercase letter (e.g: emailField).
XML
Copy
  • To set a type of the locator ( id, xpath, class, etc.).
XML
Copy
  • Fill in the selected locator type.
XML
Copy

Now you can use your locator -loginPages.emailFieldfor any command you need, and for any test.

An example of using locatorId in a command:

XML
Copy

After the element locator= "" - we’re paving the way to the locator we need in the format filename.locatorId.

To write locators directly in the field for the locator you need:

  • Use the locatorStrategy attribute in each command that you need.
XML
Copy
  • Select the required locator type (locatorId - is default value, which there is no need to write).
XML
Copy
  • Write locator in the 'locator' field.
XML
Copy
Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard