我正在尝试创建一个自动寻找Zoom可用空间的机器人(因为我很无聊,所以我可以拖拉)。
它可以工作,但有时会收到错误消息,即“提交”按钮的点击被拦截。我希望我的程序在出现错误后继续运行,但是只是停止了。我该如何解决?
这是代码:
browser.get("https://www.zoomus.cn/j/1313141151?_x_zm_rtaid=GJwf9jNWTHasYv14WqiBZg.1593889587120.4853db3668ae0d51573cd748d7f1ded4&_x_zm_rhtaid=338")
class Buttons:
ID_Box = browser.find_element_by_id("join-confno")
Submit_BTN = browser.find_element_by_id("btnSubmit")
def CheckElement_Exist():
try:
browser.find_element(By.ID, "join-confno")
except NoSuchElementException:
return False
pass
return True
while CheckElement_Exist():
Number_Random = choices(availableSymbols_Code, k=randint(9 + 5, 11 + 5))
attempts += 1
Buttons.ID_Box.send_keys(''.join(Number_Random))
Buttons.Submit_BTN.click()
time.sleep(0.5)
Buttons.ID_Box.clear()
time.sleep(3.5)
time_end = time.time()
time_took = round(time_end - time_end, 2)
Saved_Number = Number_Random
print(Fore.GREEN + "Room found in " + Style.RESET_ALL + Fore.RED + time_took + Style.RESET_ALL + Fore.GREEN
+ " seconds. Number is: " + Style.RESET_ALL + Fore.RED + Saved_Number + Style.RESET_ALL + Fore.GREEN + ".")
这是错误:
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <a id="btnSubmit" role="button" href="javascript:;" class="btn btn-primary user submit disabled" disabled="disabled">...</a> is not clickable at point (324, 357). Other element would receive the click: <div class="controls">...</div>
答案 0 :(得分:0)
正如错误明确指出的那样,
其他元素将获得点击:div class =“ controls”
它可能由于各种原因而发生,
actions = ActionChains(driver)
actions.move_to_element(Submit_BTN).perform()
或其他替代方法:
driver.execute_script("arguments[0].scrollIntoView();", Submit_BTN);
Submit_BTN.send_keys(u'\ue007');
希望这可以帮助您 ! ;)