今日做了一个h5网站的下单流程的自动化脚本,到了最后一步提交订单一直报错,尝试了各种定位方式还是报错,报错内容如下:
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element ... is not clickable at point (304, 637). Other element would receive the click:...(Session info: chrome=84.0.4147.105)
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element … is not clickable at point (304, 637). Other element would receive the click:
…(Session info: chrome=84.0.4147.105)
原代码:
driver.find_element(By.link_TEXT, "确认提交").click()
后来找了解决办法尝试了一下成功了:
element1=driver.find_element(By.link_TEXT, "确认提交")
driver.execute_script("arguments[0].click();",element1)
也没有解释为什么会这样查看了execute_script 的用法如下:
def execute_script(self, script, *args):
"""
Synchronously Executes Javascript in the current window/frame.
:Args:
- script: The Javascript to execute.
- *args: Any applicable arguments for your Javascript.
:Usage:
driver.execute_script('return document.title;')
"""
converted_args = list(args)
command = None
if self.w3c:
command = Command.W3C_EXECUTE_script
else:
command = Command.EXECUTE_script
return self.execute(command, {
'script': script,
'args': converted_args})['value']
我理解就是应为我定位的元素需要先执行Javascript才能做操作,不知道理解对不对,希望有大神指出原理谢谢



