I have code that works shown below; however I would like to speed it up by removing my sleep command and replacing it with something like:
element =WebDriverWait(driver,20).until(EC.presence_of_element_located((By.ID,"myElement")))
from Python selenium: wait until element is clickable - not working
However, redoing time_element or review_element in this format gives the error: TypeError: object of type 'WebElement' has no len()
Is there an equivalent function that will let me wait for multiple elements and then let my code progress as normal?
while(True):
#finds the time element by searching all elements tagged with time
#finds the review element by searching all images and taking their
#description, this is then filtered to remove image tags not from reviews
try:
time_element=driver.find_elements(by=By.TAG_NAME, value="time")
review_element=driver.find_elements(by=By.TAG_NAME, value="img")
for ii in range(len(time_element)):
time_list.append(time_element[ii].text)
for iii in range(len(review_element)):
review_list.append(review_element[iii].get_attribute('alt'))
NEXT=driver.find_element(By.NAME, value='pagination-button-next')
actions=ActionChains(driver)
actions.click(NEXT)
actions.perform()
time.sleep(2)
except NoSuchElementException:
break