2
votes
  • selenium - 3.141.0
  • headless chrome=75.0.3770.142

Sample code:

from selenium import webdriver

options = Options()
options.add_argument('--headless')
driver = webdriver.Chrome(CHROME_DRIVER_LOCATION, options=options)
driver.set_page_load_timeout(timeout)

driver.find_element_by_id("keywords").send_keys("some keywords to search")

"keywords" is of <input> type

The last line is failing in headless chrome and working fine otherwise.

Error:

driver.find_element_by_id("keywords").send_keys("some keywords to search") File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webelement.py", line 479, in send_keys 'value': keys_to_typing(value)}) File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webelement.py", line 633, in _execute return self._parent.execute(command, params) File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable (Session info: headless chrome=75.0.3770.142)

1
is this working in interactive mode?KunduK
try opening the page in chrome browser and inspect the element associated with that id. it may be just a wrapper to the child which you want to interact with. alternatively you can try using driver.execute_script("use JS code to interact with your element") and see if that worksAnzel

1 Answers

4
votes

for headless browser you have to set the window size to fire on event.Because headless browser can't recognise where to click without window size.

 options= Options()
 options.add_argument('--headless')
 options.add_argument('window-size=1920x1080');