OStack程序员社区-中国程序员成长平台

标题: python - Selenium - wait until element is present, visible and interactable [打印本页]

作者: 菜鸟教程小白    时间: 2022-4-10 16:04
标题: python - Selenium - wait until element is present, visible and interactable

I have a Selenium script (Python) that clicks a reply button to make the class anonemail appear. The time it takes for the class anonemail to appear varies. Because of that I have to use sleep until the element has appeared.

I want to wait until the class has appeared instead of using sleep. I have heard about wait commands, but I don't know how to use them.

This is what I have thus far:

browser.find_element_by_css_selector(".reply-button").click()
sleep(5)
email=browser.find_element_by_css_selector(".anonemail").get_attribute("value")


Best Answer-推荐答案


As per the best practices:


References

You can find a couple of detailed discussion in:






欢迎光临 OStack程序员社区-中国程序员成长平台 (http://ostack.cn/) Powered by Discuz! X3.4