i need assistance web driver using python. trying iterate through dropdown list using wait. selected dropdown item automatically updates page webdriverwait needed give page time update. need iterate through dropdown of 10 items , wait between each item. examples on how done?
general pattern of want be:
- create list of pairs
item select, condition wait after selection
- loop on list
i not of python developer, take code below pseudo-code python flavour:
from selenium import webdriver selenium.webdriver.common.by import selenium.webdriver.support.ui import webdriverwait selenium.webdriver.support import expected_conditions ec selenium.webdriver.support.ui import select # first item in tuple value of select, # second value wait after selecting item verify_list = [('item1', '//xpath1'),('item2', '//xpath2'),...] wait = webdriverwait(driver, 10) item,condition in verify_list: # select (since page refreshes, may need after each select) select = select(driver.find_element_by_xpath("xpath")) # select value (for example visible text) select.select_by_visible_text(item) # wait condition. example presence of element # try/catch can added here, if want run options, # if 1 of them fails. wait.until(ec.presence_of_element_located((by.xpath, condition))
Comments
Post a Comment