Unable to locate element and TimeoutException when WebDriverWait is used

后端 未结 2 1094
无人共我
无人共我 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:19

    Your yDmH0d, fcxH9b, etc. seems to be dynamically generated and change each time you load/reload the page. The only thing which doesn't change is span tag text.

    So I would recommend using the following simple selector:

    WebDriverWait(driver, 15).until(EC.presence_of_element_located((By.XPATH, "//span[text()='Show more']"))).click()
    

    Also consider using Page Object Model design pattern, it will make your life easier when it comes to test support when/where UI changes and lets you write tests much faster.

    See Page Objects page of Selenium Python documentation for more information if needed.

提交回复
热议问题