Skip to content

Commit 051c8b1

Browse files
gtzampanakislukeis
authored andcommitted
Fixed: Unhelpful error message when PhantomJS exits. (#2173)
Selenium does not check that the PhantomJS process is running prior to checking connectivity. This results in unhelpful error message when the subprocess unexpectedly exits. The solution is to assert that the process is still running before connectivity is checked. Fixes #2168.
1 parent 8d83cc9 commit 051c8b1

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

py/selenium/webdriver/common/service.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,23 @@ def start(self):
8181
(os.path.basename(self.path), self.start_error_message, str(e))
8282
)
8383
count = 0
84-
while not self.is_connectable():
84+
while True:
85+
self.assert_process_still_running()
86+
if self.is_connectable():
87+
break
8588
count += 1
8689
time.sleep(1)
8790
if count == 30:
8891
raise WebDriverException("Can not connect to the Service %s" % self.path)
8992

93+
def assert_process_still_running(self):
94+
return_code = self.process.poll()
95+
if return_code is not None:
96+
raise WebDriverException(
97+
'Service %s unexpectedly exited. Status code was: %s'
98+
% (self.path, return_code)
99+
)
100+
90101
def is_connectable(self):
91102
return utils.is_connectable(self.port)
92103

0 commit comments

Comments
 (0)