Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使selenium不断重新加载页面,直到找到正确的类名?_Python_Selenium - Fatal编程技术网

Python 如何使selenium不断重新加载页面,直到找到正确的类名?

Python 如何使selenium不断重新加载页面,直到找到正确的类名?,python,selenium,Python,Selenium,如何使selenium不断重新加载页面(循环),直到找到正确的类名 browser.find_element_by_class_name('login').click(); 我正在使用js重新加载: driver.execute_script("location.reload()") 您可以尝试使用如下所示的显式等待: try: element = driver.execute_script("location.reload()").until(

如何使selenium不断重新加载页面(循环),直到找到正确的
类名

browser.find_element_by_class_name('login').click();
我正在使用js重新加载:

driver.execute_script("location.reload()")

您可以尝试使用如下所示的显式等待:

try:
element = driver.execute_script("location.reload()").until(
    EC.element_to_be_clickable((By.XPATH, "some id"))
)
最后: 元素。单击() 不完全确定语法是否一切正常,但我假设你明白我的意思,你会一直这样做直到元素可以点击为止。您需要导入以下tho:

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

我希望这能起作用,如果能起作用,请告诉我你的确切意思是什么?我怀疑一个网站的html会随着重新加载而改变,你能更具体一点或者添加url/html代码吗?我的意思是按钮被锁定了,并且会在特定时间解锁。非常感谢