Identifying HTML elements in order to interact with them within you tests can be done by using CSS Selectors, which use pattern matching to easily find these elements. Below are the most used patterns to identify the elements on a page and examples of their usage: Continue reading CSS Selectors
To select HTML elements from your page, you can use XPath selectors, which are basically a set of expressions that will extract the nodes you require. The nodes are obtained by following a path in the HTML document, either downwards from a known node, or upwards (it searches for descendants or ancestors of a known element). To find elements using XPATH, find below what suits your search: Continue reading XPATH selectors
An HTML element has the following syntax:
<element [attribute="value"|...] />
An HTML element in enclosed within a preceding ‘<‘ and a trailing ‘/>’ characters. An HTML element can have none, one or many attributes, depending on its’ type. The attribute has pairs of keys and values to define additional information about the element.
There are a few attributes that can be assigned to any HTML element. Two of them are described here:
- ID – to specify a unique identifier for the element.
- CLASS – an element can have one or more classes.
There are a great number of HTML elements, but for the purpose of Selenium testing, the most commonly used ones are presented below.