我正在尝试使用Selenium将键发送到由javaScript创建的输入字段。我在chrome驱动程序和python中使用了硒Web驱动程序。
我尝试了以下方法,但是即使我也可以访问输入元素,它也会出现与“元素不可交互”相同的错误。
尝试以下功能:
browser.find_element_by_xpath("//li[@class='ui-menu-item']")[0]
browser.find_element_by_xpath("//li[@class='ui-menu-item']")
find_element_by_class()
find_element_by_id()
find_element_by_css_selector()
我的确切代码是:
print("Filling Engine Number")
input = browser.find_element_by_xpath("//*[@class='o_form_input ui-autocomplete-input']")
# input.clear()
time.sleep(2)
input.send_keys("Engine Numbers")
错误:
Traceback (most recent call last):
File "C:/Users/Oasis3/PycharmProjects/dataScrapping/ERP.py", line 309, in <module>
input.send_keys(product_title)
File "C:\Users\Oasis3\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 479, in send_keys
'value': keys_to_typing(value)})
File "C:\Users\Oasis3\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute
return self._parent.execute(command, params)
File "C:\Users\Oasis3\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\Oasis3\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotVisibleException: Message: element not interactable
(Session info: chrome=73.0.3683.103)
(Driver info: chromedriver=2.45.615291 (ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387),platform=Windows NT 10.0.17134 x86_64)
这个问题有解决方案吗? 屏幕截图已附上。