3
  • 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)

Dev
  • 13,492
  • 19
  • 81
  • 174
  • is this working in interactive mode? – KunduK Jul 17 '19 at 16:21
  • 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 works – Anzel Jul 17 '19 at 16:28

1 Answers1

5

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');
KunduK
  • 32,888
  • 5
  • 17
  • 41
  • Looking at your other [answer](https://stackoverflow.com/a/55239162/3929393a) setting window-size did the trick for me. Maybe you wanna edit your answer. – Dev Jul 18 '19 at 06:19
  • If you see Comment section I have asked you is your code working with interactive mode.if yes, that means for headless you need to set window-size to perform an action. – KunduK Jul 18 '19 at 07:46
  • Oh I missed that. Thanks! – Dev Jul 18 '19 at 08:12