【发布时间】:2020-07-11 19:47:06
【问题描述】:
我正在开发一个基于硒的 python 自动化项目。该代码通过连接到公司的内部网页 url 来自动执行一些常规任务。但是,代码偶尔会在两个按钮单击操作之间引发相同的异常。你能帮我弄清楚我错过了什么吗?提前致谢。 你可以在这里找到我的代码 sn-p 和错误截图:
selenium.common.exceptions.ElementClickInterceptedException:消息: 元素点击被拦截:元素......在点(180, 447)。其他元素会收到点击:...
pycharm_error_output_screenshot
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
timeout = 200
options = Options()
options.headless = False
driver = webdriver.Chrome(options=options)
driver.implicitly_wait(3)
wait = WebDriverWait(driver, timeout)
driver.get("https://internal_web_appplication_page_for_company_x")
apply_button_v4 = wait.until(EC.visibility_of_element_located((By.XPATH, "//body//button[2]")))
apply_button_v4.click()
both_button = wait.until(EC.element_to_be_clickable((By.XPATH, "// label[3] // span[1]")))
wait.until_not(EC.element_to_be_clickable((By.CLASS_NAME, "map-mask")))
wait.until_not(EC.element_to_be_clickable((By.XPATH, "// *[ contains( @ class, 'map-mask')]")))
both_button.click()
截获的元素是全屏“加载”通知,在任何点击操作后短时间内可见。 此外,如果我在单击“both_button”之前放置 time.sleep(5),我的代码将按预期工作。
【问题讨论】:
标签: python selenium pycharm webdriver selenium-chromedriver