Skip to content

Commit

Permalink
Fixed: Unhelpful error message when PhantomJS exits. (#2173)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gtzampanakis authored and AutomatedTester committed Jun 3, 2016
1 parent e9928d6 commit f9c5ff8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion py/selenium/webdriver/common/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,23 @@ def start(self):
(os.path.basename(self.path), self.start_error_message, str(e))
)
count = 0
while not self.is_connectable():
while True:
self.assert_process_still_running()
if self.is_connectable():
break
count += 1
time.sleep(1)
if count == 30:
raise WebDriverException("Can not connect to the Service %s" % self.path)

def assert_process_still_running(self):
return_code = self.process.poll()
if return_code is not None:
raise WebDriverException(
'Service %s unexpectedly exited. Status code was: %s'
% (self.path, return_code)
)

def is_connectable(self):
return utils.is_connectable(self.port)

Expand Down

0 comments on commit f9c5ff8

Please sign in to comment.