FE Automation Flashcards
Selenium Webdriver
Is an API and protocol that defines a language-neutral interface for controlling the web browsers. This is as if a real user is operating the browser.
Xpath
Is the language to query XML documents using XML path expression
Methods in Xpath
- contains() - uses partial value
- starts-with()
- text() - has to be an absolute text, not partial
Implicit wait
The driver is asked to wait for a specific amount of time for the element to be available in the DOM page
Syntax for implicit wait
driver.implicitly_wait(2)
Explicit wait
The driver is asked to wait until a certain condition is satisfied
Locators
Are addresses that identify a web element uniquely within the page
Types of basic locators
- ID
- NAME
- LINK_TEXT, PARTIAL_LINK_TEXT
- CLASS_NAME
- TAG_NAME
Types of customized locators
- CSS Selector
- Tag and ID
- Tag and Class
- Tag and attribute
- Tag, class and attribute - XPath
- Absolute XPath
- Relative XPath
What is tag name
Input, select, head, body, div…
Attributes in html
Is a piece of markup language used to adjust the behavior or display of an HTML element.
Example: name, ID, class
linkText or partialLinkText
The text from the web page and not from the html
How to find multiple elements
driver.findElements
How to return the number of elements
With len method
Example: number=driver.findElements…..
print(len(number)
What elements being retuned as multiple
Tags, classes
Syntax to use locators
from selenium.webdriver.common.by import By
driver.findElement(By.ID(“name”)
Can also be used for CLASS_NAME, TAG_NAME, NAME, LINK_TEXT, PARTIAL_LINK_TEXT)
Syntax to use CSS selector
driver.findElement(By.CSS_SELECTOR(“#email))
tag# - id
tag. - class
attribute - “tag[name=email]”
tag, class, attribute- (“input.inputtext[data-testid=royal_email]”)
tag is always optional
DOM
Document object model is an API interface provided by the browser. When a web page is loaded, the browser created a DOM of the page.
Types of XPath
- absolute(full)
- relative(partial)
What is absolute XPath
The complete path beginning from the root to the element witch we want to identify. XPath becomes invalid if there are any changes in attributes from the root to the element.
Starts with single slash: /
What is relative XPath
Starts from the element. Works based on certain attributes and value.
Starts with double slash: //
Difference between absolute and relative XPath
- Absolute XPath starts from the root node and relative directly jumps to element in DOM
- Absolute starts with single slash /, relative with double slash //
- Absolute uses only tags/nodes, relative uses attributes
Fluent wait selenium
It’s the maximum amount of time for the driver to wait for a certain condition to become visible, as well as frequency with which to check the condition.
User may configure the wait to ignore specific type of exceptions.
Syntax to go forward with selenium
driver.navigate().forward()