LukeIS: [python] ghostdriver can now be kicked off via command line option.
git-svn-id: http://selenium.googlecode.com/svn/trunk/py@18204 07704840-8298-11de-bf8c-fd130f914ac9
diff --git a/selenium/webdriver/phantomjs/service.py b/selenium/webdriver/phantomjs/service.py
index 3fc3c92..21c5e5f 100644
--- a/selenium/webdriver/phantomjs/service.py
+++ b/selenium/webdriver/phantomjs/service.py
@@ -24,13 +24,12 @@
Object that manages the starting and stopping of PhantomJS / Ghostdriver
"""
- def __init__(self, executable_path, ghostdriver_path, port=0, service_args=None):
+ def __init__(self, executable_path, port=0, service_args=None):
"""
Creates a new instance of the Service
:Args:
- executable_path : Path to PhantomJS binary
- - ghostdriver_path : Path to ghostdriver/src/main.js
- port : Port the service is running on
- service_args : A List of other command line options to pass to PhantomJS
"""
@@ -43,8 +42,7 @@
if self.service_args is None:
self.service_args = []
self.service_args.insert(0, self.path)
- self.service_args.append(ghostdriver_path)
- self.service_args.append("%d" % self.port)
+ self.service_args.append("--webdriver=%d" % self.port)
self._log = open("ghostdriver.log", 'w')
def start(self):
@@ -56,11 +54,10 @@
or when it can't connect to the service
"""
try:
- print "Starting process:", self.path
self.process = subprocess.Popen(self.service_args,
stdout=self._log, stderr=self._log)
- except:
- raise WebDriverException("Unable to start phantomjs with ghostdriver.")
+ except Exception, e:
+ raise WebDriverException("Unable to start phantomjs with ghostdriver.", e)
count = 0
while not utils.is_connectable(self.port):
count += 1
diff --git a/selenium/webdriver/phantomjs/webdriver.py b/selenium/webdriver/phantomjs/webdriver.py
index b10e319..62f8d19 100644
--- a/selenium/webdriver/phantomjs/webdriver.py
+++ b/selenium/webdriver/phantomjs/webdriver.py
@@ -30,7 +30,7 @@
https://github.com/detro/ghostdriver
"""
- def __init__(self, ghostdriver_path, executable_path="phantomjs",
+ def __init__(self, executable_path="phantomjs",
port=0, desired_capabilities=DesiredCapabilities.PHANTOMJS):
"""
Creates a new instance of the PhantomJS / Ghostdriver.
@@ -38,13 +38,12 @@
Starts the service and then creates new instance of the driver.
:Args:
- - ghostdriver_path - path to ghostdriver/src/main.js
- executable_path - path to the executable. If the default is used it assumes the executable is in the $PATH
- port - port you would like the service to run, if left as 0, a free port will be found.
- desired_capabilities: Dictionary object with non-browser specific
capabilities only, such as "proxy" or "loggingPref".
"""
- self.service = Service(executable_path, ghostdriver_path, port=port)
+ self.service = Service(executable_path, port=port)
self.service.start()
try: