Unable to locate element and TimeoutException when WebDriverWait is used

后端 未结 2 1135
无人共我
无人共我 2021-01-29 08:58

I\'m trying to automate the clicking of the \"SHOW MORE\" button at the bottom of the page to get all the reviews there is.

However, I\'m having some problems locating

2条回答
  •  野性不改
    2021-01-29 09:15

    As the element is JavaScript enabled element so to click() it you need to induce WebDriverWait for the element_to_be_clickable() and you can use the following Locator Strategy:

    • Using XPATH:

      WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@role='button']//span/span[text()='Show more']"))).click()
      
    • Note : You have to add the following imports :

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

提交回复
热议问题