How to fix the "Timed out" problem with running IE and chrome browsers on Windows using Remote driver

1.5k Views Asked by At

I need to run some tests on remote Windows in IE and Chrome browsers. But I get the Timeout error on the main computer and Exit value: -1073741819 on remote. I have the latest version of drivers and server. I use 32bit Selenium Server on 64 Windows (it is recommended)

I've added all to PATH, but if I run chromedriver via cmd I get nothing. I have no idea why (the same in admin mode)

If I run the tests locally on Windows via Pycharm I don't have any issues even I run it via Server using localhost:4444 as a remote URL The problem only with running remotely.

Is there any solution how to fix that problem?

I have in my Python code:

desired_capabilities: DesiredCapabilities = {
            'chrome': DesiredCapabilities.CHROME,
            'firefox': DesiredCapabilities.FIREFOX,
            'IE': DesiredCapabilities.INTERNETEXPLORER,}.get(browser, DesiredCapabilities.CHROME)

driver = webdriver.Remote(command_executor=remote_url, desired_capabilities=desired_capabilities)

I use command for run:

pytest tests/test.py --remote_url Remote_IP:4444/wd/hub --browser IE

The Selenium server can see my request and shows in the Windows terminal:

12:53:00.975 INFO [ActiveSessionFactory.apply] - Capabilities are: {
  "browserName": "internet explorer",
  "platform": "WINDOWS",
  "version": ""
}
12:53:00.975 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.ie.InternetExplorerDriverService)
12:53:21.022 ERROR [OsProcess.checkForError] - org.apache.commons.exec.ExecuteException: Process exited with an error: -1073741819 (Exit value: -1073741819)

Also in my local terminal, I see the error:

E selenium.common.exceptions.WebDriverException: Message: Timed out waiting for driver server to start.
E Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
E System info: host: 'HOST NAME', ip: 'REMOTE IP', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_191'
E Driver info: driver.version: unknown
E Stacktrace:
E at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable (DriverService.java:202)
E at org.openqa.selenium.remote.service.DriverService.start (DriverService.java:188)
E at org.openqa.selenium.grid.session.remote.ServicedSession$Factory.apply (ServicedSession.java:155)
E at org.openqa.selenium.remote.server.ActiveSessionFactory.lambda$apply$12 (ActiveSessionFactory.java:180)
E at java.util.stream.ReferencePipeline$3$1.accept (None:-1)
E at java.util.stream.ReferencePipeline$11$1.accept (None:-1)
E at java.util.stream.ReferencePipeline$2$1.accept (None:-1)
E at java.util.Spliterators$ArraySpliterator.tryAdvance (None:-1)
E at java.util.stream.ReferencePipeline.forEachWithCancel (None:-1)
E at java.util.stream.AbstractPipeline.copyIntoWithCancel (None:-1)
E at java.util.stream.AbstractPipeline.copyInto (None:-1)
E at java.util.stream.AbstractPipeline.wrapAndCopyInto (None:-1)
E at java.util.stream.FindOps$FindOp.evaluateSequential (None:-1)
E at java.util.stream.AbstractPipeline.evaluate (None:-1)
E at java.util.stream.ReferencePipeline.findFirst (None:-1)
E at org.openqa.selenium.remote.server.ActiveSessionFactory.apply (ActiveSessionFactory.java:183)
E at org.openqa.selenium.remote.server.NewSessionPipeline.lambda$null$2 (NewSessionPipeline.java:66)
E at java.util.stream.ReferencePipeline$3$1.accept (None:-1)
E at java.util.stream.ReferencePipeline$2$1.accept (None:-1)
E at java.util.Collections$2.tryAdvance (None:-1)
E at java.util.stream.ReferencePipeline.forEachWithCancel (None:-1)
E at java.util.stream.AbstractPipeline.copyIntoWithCancel (None:-1)
E at java.util.stream.AbstractPipeline.copyInto (None:-1)
E at java.util.stream.AbstractPipeline.wrapAndCopyInto (None:-1)
E at java.util.stream.FindOps$FindOp.evaluateSequential (None:-1)
E at java.util.stream.AbstractPipeline.evaluate (None:-1)
E at java.util.stream.ReferencePipeline.findFirst (None:-1)
E at org.openqa.selenium.remote.server.NewSessionPipeline.lambda$createNewSession$3 (NewSessionPipeline.java:69)
E at java.util.stream.ReferencePipeline$3$1.accept (None:-1)
E at java.util.stream.ReferencePipeline$3$1.accept (None:-1)
E at java.util.stream.ReferencePipeline$3$1.accept (None:-1)
E at java.util.stream.DistinctOps$1$2.accept (None:-1)
E at java.util.stream.ReferencePipeline$2$1.accept (None:-1)
E at java.util.stream.ReferencePipeline$3$1.accept (None:-1)
E at java.util.stream.ReferencePipeline$2$1.accept (None:-1)
E at java.util.stream.Streams$StreamBuilderImpl.tryAdvance (None:-1)
E at java.util.stream.Streams$ConcatSpliterator.tryAdvance (None:-1)
E at java.util.stream.ReferencePipeline.forEachWithCancel (None:-1)
E at java.util.stream.AbstractPipeline.copyIntoWithCancel (None:-1)
E at java.util.stream.AbstractPipeline.copyInto (None:-1)
E at java.util.stream.AbstractPipeline.wrapAndCopyInto (None:-1)
E at java.util.stream.FindOps$FindOp.evaluateSequential (None:-1)
E at java.util.stream.AbstractPipeline.evaluate (None:-1)
E at java.util.stream.ReferencePipeline.findFirst (None:-1)
E at org.openqa.selenium.remote.server.NewSessionPipeline.createNewSession (NewSessionPipeline.java:72)
E at org.openqa.selenium.remote.server.commandhandler.BeginSession.execute (BeginSession.java:65)
E at org.openqa.selenium.remote.server.WebDriverServlet.lambda$handle$0 (WebDriverServlet.java:235)
E at java.util.concurrent.Executors$RunnableAdapter.call (None:-1)
E at java.util.concurrent.FutureTask.run (None:-1)
E at java.util.concurrent.ThreadPoolExecutor.runWorker (None:-1)
E at java.util.concurrent.ThreadPoolExecutor$Worker.run (None:-1)
E at java.lang.Thread.run (None:-1) /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py:242: WebDriverException

Also I get logs (REMOTE_IP is the remote Windows address):

remote_connection.py 390 DEBUG POST REMOTE_IP:4444/wd/hub/session {"capabilities": {
"firstMatch": [{}], "alwaysMatch": {"browserName": "internet explorer", "platformName": "windows"}}, 
"desiredCapabilities": 
    {"browserName": "internet explorer", 
     "version": "", 
     "platform": "WINDOWS"}}

connectionpool.py 208 DEBUG Starting new HTTP connection (1): REMOTE_IP
connectionpool.py 396 DEBUG http://REMOTE_IP:4444 "POST /wd/hub/session HTTP/1.1" 500 14404
remote_connection.py 442 DEBUG Finished Request
2

There are 2 best solutions below

2
akshay patil On

You can use explicit wait to avoid timeout what it will do is wait 10 seconds until to found if not it will throw timeout error and you can increase time to 30 seconds as much you want

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Firefox()
driver.get("http://somedomain/url_that_delays_loading")
try:
    element = WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.ID, "myDynamicElement"))
    )
finally:
    driver.quit()

if this doesn't work then you can use sleep method from Thread using time

time.sleep(5)
0
Ankit Agrawal On

you can add implicit wait to let driver wait for element at every step. Default time for implicit wait is 0

driver.implicitly_wait(10) #timeout in seconds