Skip to main content
 首页 » 编程设计

python之selenium.common.exceptions.ElementClickInterceptedException : Message: element click intercepted: Element is not clickable with Selenium and Python

2025年05月04日14kenshinobiy

我目前正在从事一个自动填写表格的项目。填写表格后会出现下一个按钮,这就是它给我错误的原因。

我试过:

WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH,"//input[@type='button' and @class='button']"))) 
Next = driver.find_element_by_xpath("//input[@type='button' and @class='button']") 
Next.click() 

HTML:

<span class="btn"> 
    <input type="button" value="Next" class="button" payoneer="Button" data-controltovalidate="PersonalDetails" data-onfieldsvalidation="ToggleNextButton" data-onclick="UpdateServerWithCurrentSection();" id="PersonalDetailsButton"> 
     </input> 
     <div class="clearfix"></div> 
</span> 

错误:

selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element is not clickable at point (203, 530). Other element would receive the click: ... (Session info: chrome=76.0.3809.132)

请您参考如下方法:

如果xpath的路径是正确的,也许你可以试试这个方法来解决这个问题。用以下代码替换旧代码:

button = driver.find_element_by_xpath("xpath") 
driver.execute_script("arguments[0].click();", button) 

我以前解决过这个问题,但老实说,我不知道原因。