7

When I am running python scripts to test a website on Headless Chrome Broswer (Webdriver + Selenium), we often get a timeout error, I found out the problem occurred when script interacted with browser by .click() or .send_keys() methods. Can anyone know what the kind of problem it is? Sometimes it is working fine but sometimes I have got timeout error. Please give a solution for the same

Stack trace:

 15:01:48,194 root:ERROR: ERROR occurred: Message: timeout
   (Session info: headless chrome=60.0.3112.101)
   (Driver info: chromedriver=2.31.488763 
   (092de99f48a300323ecf8c2a4e2e7cab51de5ba8),platform=Windows NT 6.1.7601 SP1 
    x86)

    Traceback (most recent call last):
  File "c:\autotest\x.py", line 148, in main
    func(nik)
  File "c:\autotest\lib\support.py", line 126, in wrapper
    raise ret
  File "c:\autotest\lib\support.py", line 113, in newFunc
    res[0] = func(*args, **kwargs)
  File "c:\autotest\testcases\1001.py", line 15, in testcase
    "documents_approved ASC", generateError=True)  
  File "c:\autotest\lib\support.py", line 51, in wrapper
    f_result = func(*args, **kwds)
  File "c:\autotest\pageobjects\web\segment_header.py", line 184, in login
    + Keys.ENTER)
  File "C:\Python36\lib\site-packages\selenium\webdriver\remote\webelement.py", line 350, in send_keys
    'value': keys_to_typing(value)})
  File "C:\Python36\lib\site-packages\selenium\webdriver\remote\webelement.py", line 499, in _execute
    return self._parent.execute(command, params)
  File "C:\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 297, in execute
    self.error_handler.check_response(response)
  File "C:\Python36\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: timeout
  (Session info: headless chrome=60.0.3112.101)
  (Driver info: chromedriver=2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8),platform=Windows NT 6.1.7601 SP1 
    x86) 
3
  • Can you share your work please? Aug 21, 2017 at 14:14
  • Dealing with our problem was to run less testing browsers in parallel on a virtual machine. Timeout Error disappeared nowhere.
    – Ghost
    Aug 31, 2017 at 7:44
  • If the problem still persists with Headless Chrome I would suggest you to try Headless Mozilla Firefox Aug 31, 2017 at 7:46

2 Answers 2

4

I was having a similar problem, normal Chrome driver worked fine, but headless chrome always timed out.

I found out that for responsive web pages, you need to set the window size:

driver.set_window_size(1200, 600)

It worked after adding this line just after initialization of the driver itself.

I hope this helps!

2

I faced same issue and was able to resolve it after updating my chromedriver and adding chrome_options.add_argument("--window-size=1920,1080") to the chrome options. The options I currently apply are:

chrome_options = Options()  
chrome_options.add_argument("--headless") 
chrome_options.add_argument("--window-size=1920,1080")
chrome_options.add_argument('--start-maximized')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument("--disable-extensions")
chrome_options.add_argument('disable-infobars')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.