From e0a48599df8abc1e50613607f97d52c0fa1df078 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Fri, 9 Nov 2012 10:58:22 +0100 Subject: [PATCH 1/5] adding .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0d20b64 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.pyc From 1667763d54123cba92e70e2f9738bfc38b9470bc Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Fri, 9 Nov 2012 11:07:05 +0100 Subject: [PATCH 2/5] adding our readme --- README-feat | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 README-feat diff --git a/README-feat b/README-feat new file mode 100644 index 0000000..b60da62 --- /dev/null +++ b/README-feat @@ -0,0 +1,6 @@ +This is a mirror of the python module for selenium. + +This mirror was cloned with: + +git svn clone http://selenium.googlecode.com/svn/trunk/py python-selenium + From d1bdf7d0cedcaced1910bef1a010dbdd681b1812 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Fri, 9 Nov 2012 11:23:01 +0100 Subject: [PATCH 3/5] make sure we always kill the process --- selenium/webdriver/chrome/service.py | 29 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/selenium/webdriver/chrome/service.py b/selenium/webdriver/chrome/service.py index 2d5c25b..c55af85 100644 --- a/selenium/webdriver/chrome/service.py +++ b/selenium/webdriver/chrome/service.py @@ -80,19 +80,20 @@ def stop(self): #Tell the Server to die! import urllib2 - urllib2.urlopen("http://127.0.0.1:%d/shutdown" % self.port) - count = 0 - while not utils.is_connectable(self.port): - if count == 30: - break - count += 1 - time.sleep(1) - - #Tell the Server to properly die in case try: + urllib2.urlopen("http://127.0.0.1:%d/shutdown" % self.port) + count = 0 + while not utils.is_connectable(self.port): + if count == 30: + break + count += 1 + time.sleep(1) + finally: + #Tell the Server to properly die in case if self.process: - os.kill(self.process.pid, signal.SIGTERM) - os.wait() - except AttributeError: - # kill may not be available under windows environment - pass + try: + os.kill(self.process.pid, signal.SIGTERM) + os.wait() + except AttributeError: + # kill may not be available under windows environment + pass From 583e0751e2e937e194ee3d210580b107309b396e Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Fri, 9 Nov 2012 13:08:45 +0100 Subject: [PATCH 4/5] Make sure we raise even if quit() raises. Give us a reason for failing to start too. --- selenium/webdriver/chrome/webdriver.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/selenium/webdriver/chrome/webdriver.py b/selenium/webdriver/chrome/webdriver.py index 20e9f41..75dd604 100644 --- a/selenium/webdriver/chrome/webdriver.py +++ b/selenium/webdriver/chrome/webdriver.py @@ -64,9 +64,15 @@ def __init__(self, executable_path="chromedriver", port=0, RemoteWebDriver.__init__(self, command_executor=self.service.service_url, desired_capabilities=desired_capabilities) - except: - self.quit() - raise WebDriverException("The Driver was not able to start.") + except Exception, e: + try: + self.quit() + raise WebDriverException( + "The Driver was not able to start or communicate (%r)." % e) + except: + raise WebDriverException( + "The Driver was not able to start, communicate, or quit " \ + "(%r)." % e) def quit(self): """ From ba1d143909d5d3a63db6397e437854440a367106 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Wed, 26 Feb 2014 17:29:17 -0500 Subject: [PATCH 5/5] fix the logic; we should wait while the port is connectable --- selenium/webdriver/chrome/service.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/selenium/webdriver/chrome/service.py b/selenium/webdriver/chrome/service.py index c55af85..173bdae 100644 --- a/selenium/webdriver/chrome/service.py +++ b/selenium/webdriver/chrome/service.py @@ -82,8 +82,10 @@ def stop(self): import urllib2 try: urllib2.urlopen("http://127.0.0.1:%d/shutdown" % self.port) + + # make sure that shutdown worked by testing the port has gone away count = 0 - while not utils.is_connectable(self.port): + while utils.is_connectable(self.port): if count == 30: break count += 1