Python 如何使selenium不断重新加载页面,直到找到正确的类名?
如何使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(
类名
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代码吗?我的意思是按钮被锁定了,并且会在特定时间解锁。非常感谢