ElementNotInteractableException:消息:在Python上使用Selenium将文本发送到Quora上的Email字段时,元素不可交互错误 [英] ElementNotInteractableException: Message: element not interactable error while sending text to Email field on Quora using Selenium with Python

查看:509
本文介绍了ElementNotInteractableException:消息:在Python上使用Selenium将文本发送到Quora上的Email字段时,元素不可交互错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:

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.

推荐答案

要将字符序列发送到登录部分中的电子邮件字段的 Quora ,您需要诱使 WebDriverWait 使元素可点击,您可以使用以下解决方案:

To send a character sequence to the Email field within Login section of Quora you need to induce WebDriverWait for the element to be clickable and you can use the following solution:

  • 代码块:

  • Code Block:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

options = webdriver.ChromeOptions() 
options.add_argument("start-maximized")
options.add_argument("--disable-extensions")
# options.add_argument('disable-infobars')
driver = webdriver.Chrome(chrome_options=options, executable_path=r'C:\Utility\BrowserDrivers\chromedriver.exe')
driver.get("https://www.quora.com/")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='title login_title' and text()='Login']//following::div[1]//input[@class='text header_login_text_box ignore_interaction']"))).send_keys("someemail@email.com")

  • 浏览器快照:

  • Browser Snapshot:

    这篇关于ElementNotInteractableException:消息:在Python上使用Selenium将文本发送到Quora上的Email字段时,元素不可交互错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆