Selenium Notes
HTML DOM Structure:
================================
What is HTML DOM?
- Document Object Model of the page.
- constructed as a tree of Objects:
- it defines:
- HTML elements as objects
- Properties for all HTML elements
- Methods for all HTML elements
- Events for all HTML elements
Finding HTML Elements
When you want to access HTML elements, you have to find the elements first.
There are a couple of ways to do this:
HTML id Attributes:
HTML name attribute:
================================
What is HTML DOM?
- Document Object Model of the page.
- constructed as a tree of Objects:
- it defines:
- HTML elements as objects
- Properties for all HTML elements
- Methods for all HTML elements
- Events for all HTML elements
Finding HTML Elements
When you want to access HTML elements, you have to find the elements first.
There are a couple of ways to do this:
- Finding HTML elements by id
- Finding HTML elements by tag name
- Finding HTML elements by class name
- Finding HTML elements by CSS selectors
- Finding HTML elements by HTML object collections
HTML id Attributes:
- specifies a unique id for a HTML element
- Rules for id attribute:
- at least one character
- no space characters
- always case sensitive
- unique in the document
HTML name attribute:
- specifies a name for an HTML element
- does not have to be unique in an HTML document
- mostly used in forms to reference the element when the data is submitted
HTML XPath:
- stands for XML path language
- uses path expression to identify and navigate nodes in an XML document
- can be used to select one/more nodes in the document - by using absolute / relative path
HTML class Attribute:
- specifies one/more class names for an HTML element
- used to point to a class in a stylesheet
- used to locate elements when the class attribute of one/more element is known
Locating Elements: Summarized
- find_element_by_id
- find_element_by_name
- find_element_by_xpath
- find_element_by_link_text
- find_element_by_partial_link_text
- find_element_by_tag_name
- find_element_by_class_name
- find_element_by_css_selector
To find multiple elements (these methods will return a list):
- find_elements_by_name
- find_elements_by_xpath
- find_elements_by_link_text
- find_elements_by_partial_link_text
- find_elements_by_tag_name
- find_elements_by_class_name
- find_elements_by_css_selector