[英]Selenium Element not interactable - python
I wrote a simple application in python, but when trying to click a button, I get an error Element not interactable.我在 python 中编写了一个简单的应用程序,但是当尝试单击一个按钮时,我得到一个错误 Element not interactable。 Here is a part of the code where it happens.这是发生它的代码的一部分。 I did wait for the element to render.我确实等待元素渲染。
WebDriverWait(driver, 60).until(EC.presence_of_element_located((By.XPATH, '//*[@id="root"]/div[2]/div/div/div[2]/ul/li/button')))
driver.find_element(By.XPATH, '//*[@id="root"]/div[2]/div/div/div[2]/ul/li/button').click()
The error happens on this website: https://magiceden.io/ when clicking Connect Wallet in the top right corner and then trying to click Phantom in the opening window.该错误发生在此网站上: https ://magiceden.io/ 单击右上角的连接钱包,然后尝试在打开的窗口中单击 Phantom。
Reason behind this exception:此异常背后的原因:
“ element not interactabe
” exception may occur due to various reason.由于各种原因,可能会发生“ element not interactabe
”异常。
For your case it's locator, you can use below locator to click on it.对于您的情况,它是定位器,您可以使用下面的定位器单击它。
XPATH路径
//header/nav[1]/div[2]/div[2]/div[1]/button[2]
OR或者
//button[contains(@xpath,'1')]
OR或者
(//button[contains(.,'Connect Wallet')])[1]
The Syntax should be like语法应该像
element = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "myXpath")))
element.click();
Imports进口
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
I have tested with First and third XPATH
, it's working for me, let me know if this does not solve your issue.我已经使用First和third XPATH
进行了测试,它对我有用,如果这不能解决您的问题,请告诉我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.