python - 出现错误 :(Element not interactable) when sending keys into the input field in selenium python

标签 python selenium webdriver

当我尝试将 key 发送到输入字段时,出现错误(元素不可交互)。当我尝试仅单击输入字段时,我可以执行此操作,但是在提供文本时,它显示错误,我有很多事情可以解决此问题,但我只收到此错误。

我的代码:

from selenium import webdriver

Driver=webdriver.Chrome() 
Driver=get('https://YouTube.com') 
Box=Driver.find_element_by_xpath('//*[@id="search-input"]')
Box.send_keys('music') ```

最佳答案

搜索栏是 div 类(search-input)中的 input(id=search)。试试这个;

from selenium import webdriver

Driver=webdriver.Chrome() 
Driver.get('https://YouTube.com') 
Box=Driver.find_element_by_id('search-input').find_element_by_id('search')
Box.send_keys('music') 

关于python - 出现错误 :(Element not interactable) when sending keys into the input field in selenium python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64306572/

相关文章:

python - 如何使用 Python 调用 TCL 过程

python - 输入/输出 python : Handling output and variable

Python gettext - 不翻译

c# - 如何使用 Selenium webdriver 使用 MouseOver 测试工具提示文本

java - 无法使用 Xpath 找到元素

python - 确定当前在顶部的 tkinter 窗口

python - Selenium-python 中的 css 选择器中的括号 [?] 有问题

java - 使用java获取 cucumber 中未定义的场景和步骤

Python - 使用 Selenium 单击按钮

python - 如何在 Selenium for Python 中切换到新窗口?