selenium.common.exceptions.TimeoutException:消息:

时间:2019-12-27 08:31:01

标签: python selenium-webdriver webdriverwait

在这种情况下,我使用下面的代码单击一个按钮,我理解这意味着在10秒钟内,如果出现按钮,则程序将执行该单击,如果我输入错误,请更正

WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH,dropmenu))).click()

但事实并非如此,错误有时会发生,

selenium.common.exceptions.TimeoutException: Message:

或其他类似错误

selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <a class="chAccount" onmouseup="DropDownSelected('TabMasterContent','N','sub_1');">...</a> is not clickable at point (365, 528). Other element would receive the click: <div id="totalContentWait"
style="height: 1712px; display: block;"></div>

并非总是如此,但这是我无法理解的,我猜该元素在代码执行该行时未加载,如果我添加

time.sleep(2)

该错误永远不会发生,但这意味着我的程序会变慢,并且单击处于17次循环中,您可以理解这是最差的效率

所以即使我使用WebDriverWait函数,有人还能告诉我为什么会发生错误

0 个答案:

没有答案