ElementNotInteractableException:消息:在使用 Selenium 和 Python 将文本发送到 Quora 上的电子邮件字段时,元素不可交互错误
问题描述:
这是我的代码:
from selenium import webdriver
user = "someemail@email.com"
browser = webdriver.Chrome("/path/to/browser/")
browser.get("https://www.quora.com/")
username = browser.find_element_by_name("email")
browser.implicitly_wait(10)
username.send_keys(user)
错误信息如下:
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
我认为还有另一个线程有类似的问题.该线程中的解决方案对我不起作用,或者我不知道如何实施这些解决方案.
I think there is another thread with a similar issue. Either the solutions in that thread didn't work for me or I don't know how to implement the solutions.
答
find_element_by_name("email")
在 DOM 中多次出现.所以那行不通.
is present multiple times in DOM. So that wouldn't work.
你可以试试这个css选择器:
input[class*='header_login_text_box'][name='email']
代码:
username = browser.find_element_by_css_selector("input[class*='header_login_text_box'][name='email']")
username.send_keys("user@gmail.com")