Selenium Flashcards
what are the values for document.readyState
- loading - still loading
- interactive - document has finished loading and the document has been parsed but sub-resources such as scripts, images, stylesheets and frames are still loading. The state indicates that the DOMContentLoaded event is about to fire.
- complete - The document and all sub-resources have finished loading. The state indicates that the load event is about to fire.
what are the 3 page load strategies
options = Options()
options.page_load_strategy = …
- ‘normal’ (default) - waits for DOM and all resources to load (document.readyState = ‘complete’)
- ‘eager’ - DOM access is ready, but other resources like images may still be loading
(document.readyState = ‘loading’) - none - Does not block WebDriver at all
what is implicit wait
driver.implicitly_wait(10)
1. tell WebDriver to poll the DOM for a certain amount of time when trying to find an element or elements if they are not immediately available.
2. default is 0 (disabled)
3. set for the life of the session
4. shouldn’t me mixed with explicit wait
What is fluent wait.
wait = WebDriverWait(driver, timeout=10, poll_frequency=1, ignored_exceptions=[ElementNotVisibleException, ElementNotSelectableException])
element =wait.until(
EC.element_to_be_clickable((By.XPATH, “//div”)))
1. defines the maximum amount of time to wait for a condition
2. defines frequency with which to check the condition.
3. allows ignoring of specific types of exceptions whilst waiting, such as NoSuchElementException
what is explicit wait
halts program execution until the condition you pass it resolves. The condition is called with a certain frequency until the timeout of the wait is elapsed.
what are some of the expected conditions for waits
alert is present
element exists
element is visible
title contains
title is
element staleness
visible text
what is default polling frequency in explicit wait
0.5 sec
what are the 2 types of assertions
- hard assertions - exec
- soft assertions