kif1205 / Selenium

0 stars 0 forks source link

Selenium wait - Explicit Waits #8

Open kif1205 opened 5 years ago

kif1205 commented 5 years ago

Official page : https://selenium-python.readthedocs.io/waits.html

Sample code :

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Firefox()
driver.get("http://somedomain/url_that_delays_loading")
try:
    element = WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.ID, "myDynamicElement"))
    )
finally:
    driver.quit()

There are some common conditions that are frequently of use when automating web browsers. Listed below are the names of each. Selenium Python binding provides some convenience methods so you don’t have to code an expected_condition class yourself or create your own utility package for them.

title_is
title_contains
presence_of_element_located
visibility_of_element_located
visibility_of
presence_of_all_elements_located
text_to_be_present_in_element
text_to_be_present_in_element_value
frame_to_be_available_and_switch_to_it
invisibility_of_element_located
element_to_be_clickable
staleness_of
element_to_be_selected
element_located_to_be_selected
element_selection_state_to_be
element_located_selection_state_to_be
alert_is_present
kif1205 commented 5 years ago

Need to check the corresponding tag , and then decides which EC can be used ,

Use the below link to find the corresponding tag https://www.w3schools.com/tags/tag_a.asp

Example : element_to_be_clickable is for button object , thus the tag function should be button too , so the EC can work as expected