Constructing Element IDs
Once the web inspector for a given web browser is open, most (but not all) Element ID information can be found directly in the HTML, while others require an extra click or two. You can easily copy a given element name by double-clicking it to highlight it, and then right-clicking the highlighted text and selecting Copy. Element IDs for all locator types will be described in this section.
As a general rule, you will have the simplest time constructing your Element IDs by using the following order of preference:
- ID/Name/Text/LinkText
- Class
- Tag/CSS selector
- XPath
Element IDs for locator types "className", “name”, and “id” are formatted:
-
In web page HTML as: locatorType="elementName”
-
In Cycle web Steps as: "locatorType:elementName"
The following Element IDs could be constructed using the HTML highlighted in the figure below: "className:name_first", "name:input_1.3", and "id:input_1_1_3".
HTML containing className, name, and id
Element IDs for the "linkText" locator type will exist between hyperlink HTML tags, < a >
and < /a >
, as illustrated in the figure below. The Element ID “linkText:Request a Demo” could be constructed using the HTML in the example.
HTML containing linkText
Element ID information for the "text" locator type can exist between a number of different types of tags. In the example below, we see text that exists between < h1 >
or “Header 1” tags, which define and format that text as a header on the web page. The Element ID “text:Overview” could be created using this information.
HTML containing text information
The remaining three locator types--"xPath