I using Win7, IE11, Python 3.5, Selenium 3.5.0, IEDriverServer 3.5.0(dowloaded from seleniumhq.org download page) and faced with problem with webdriver.implicitly_wait() method:
from selenium import webdriver
driver = webdriver.Ie('IEDriverServer.exe')
driver.implicitly_wait(10)
driver.close()
Code above causing crash with error:
Traceback (most recent call last):
File "C:/Users/myuser/Documents/workspace/py_proj/qa/test.py", line 28, in <module>
driver.implicitly_wait(10)
File "C:\Users\myuser\Documents\Python3.5\lib\site-packages\selenium-3.5.0-py3.5.egg\selenium\webdriver\remote\webdriver.py", line 767, in implicitly_wait
'implicit': int(float(time_to_wait) * 1000)})
File "C:\Users\myuser\Documents\Python3.5\lib\site-packages\selenium-3.5.0-py3.5.egg\selenium\webdriver\remote\webdriver.py", line 295, in execute
response = self.command_executor.execute(driver_command, params)
File "C:\Users\myuser\Documents\Python3.5\lib\site-packages\selenium-3.5.0-py3.5.egg\selenium\webdriver\remote\remote_connection.py", line 464, in execute
return self._request(command_info[0], url, body=data)
File "C:\Users\myuser\Documents\Python3.5\lib\site-packages\selenium-3.5.0-py3.5.egg\selenium\webdriver\remote\remote_connection.py", line 526, in _request
resp = opener.open(request, timeout=self._timeout)
File "C:\Users\myuser\Documents\Python3.5\lib\urllib\request.py", line 466, in open
response = self._open(req, data)
File "C:\Users\myuser\Documents\Python3.5\lib\urllib\request.py", line 484, in _open
'_open', req)
File "C:\Users\myuser\Documents\Python3.5\lib\urllib\request.py", line 444, in _call_chain
result = func(*args)
File "C:\Users\myuser\Documents\Python3.5\lib\urllib\request.py", line 1282, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "C:\Users\myuser\Documents\Python3.5\lib\urllib\request.py", line 1257, in do_open
r = h.getresponse()
File "C:\Users\myuser\Documents\Python3.5\lib\http\client.py", line 1198, in getresponse
response.begin()
File "C:\Users\myuser\Documents\Python3.5\lib\http\client.py", line 297, in begin
version, status, reason = self._read_status()
File "C:\Users\myuser\Documents\Python3.5\lib\http\client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "C:\Users\myuser\Documents\Python3.5\lib\socket.py", line 576, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
Log file of IEDriverServer (TRACE level) ends on:
T 2017-08-21 17:43:56:887 server.cc(183) Process request with: URI: /session/58f37907-d593-45df-a8ff-7e77e10f260d/timeouts HTTP verb: POST
body: {"implicit": 10000, "sessionId": "58f37907-d593-45df-a8ff-7e77e10f260d"}
T 2017-08-21 17:43:56:887 server.cc(272) Entering Server::DispatchCommand
T 2017-08-21 17:43:56:887 server.cc(583) Entering Server::LookupCommand
D 2017-08-21 17:43:56:887 server.cc(281) Command: POST /session/58f37907-d593-45df-a8ff-7e77e10f260d/timeouts {"implicit": 10000, "sessionId": "58f37907-d593-45df-a8ff-7e77e10f260d"}
T 2017-08-21 17:43:56:887 server.cc(378) Entering Server::LookupSession
T 2017-08-21 17:43:56:887 IESession.cpp(191) Entering IESession::ExecuteCommand
T 2017-08-21 17:43:56:887 IECommandExecutor.cpp(122) Entering IECommandExecutor::OnSetCommand
T 2017-08-21 17:43:56:887 command.cc(31) Entering Command::Deserialize
D 2017-08-21 17:43:56:887 command.cc(36) Raw JSON command: { "name" : "setTimeouts", "locator" : { "sessionid" : "58f37907-d593-45df-a8ff-7e77e10f260d" }, "parameters" : {"implicit": 10000, "sessionId": "58f37907-d593-45df-a8ff-7e77e10f260d"} }
T 2017-08-21 17:43:56:887 IECommandExecutor.cpp(133) Entering IECommandExecutor::OnExecCommand
T 2017-08-21 17:43:56:887 IESession.cpp(212) Beginning wait for response length to be not zero
T 2017-08-21 17:43:56:887 IECommandExecutor.cpp(454) Entering IECommandExecutor::DispatchCommand
T 2017-08-21 17:43:56:887 IECommandExecutor.cpp(567) Entering IECommandExecutor::GetCurrentBrowser
T 2017-08-21 17:43:56:887 IECommandExecutor.cpp(573) Entering IECommandExecutor::GetManagedBrowser
T 2017-08-21 17:43:56:887 IECommandExecutor.cpp(523) Entering IECommandExecutor::IsAlertActive
T 2017-08-21 17:43:56:887 Browser.cpp(713) Entering Browser::GetActiveDialogWindowHandle
T 2017-08-21 17:43:56:887 Browser.cpp(206) Entering Browser::GetContentWindowHandle
D 2017-08-21 17:43:56:888 IECommandExecutor.cpp(537) No alert handle is found
I'm not found any simmilar issues at selenium bugtracker. While trying to find the cause of crash I found that setTimeouts requests to IEDriverServer contains this data:
'{"implicit": 10000, "sessionID": "some_session_id_as_string"}'
Also in selenium/cpp/iedriver/CommandHandlers/SetTimeoutsCommandHandler.cpp line 39 asInt() method from jsoncpp lib used and it looks like for "sessionId" value this method should raise error in
selenium/third_party/cpp/json-cpp/src/jsoncpp.cpp line 2141 (JSON_FAIL_MESSAGE which #define JSON_FAIL_MESSAGE(message) throw std::runtime_error(message);)
This code works correct(problem relate only with implicitly_wait / script_wait / page_load_wait):
from selenium import webdriver
driver = webdriver.Ie('IEDriverServer.exe')
driver.get('http://any_host.com')
driver.close()
I suppose that real problem may be not in IEDriver, but in some environment things(otherway many people should have faced it). If enyone have any thoghts about where I can find root of issue described above?