Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement #5078 - Allow :desired_capabilities capabilities to be speci... #8

Closed

Conversation

kuahyeow
Copy link

...fied for PhantomJS so that phantomjs.page.settings.* can be specified

The phantomjs.page.settings.* settings are passed in as part of the Capabilties object, so e.g. we now can change the user-agent like so:

capabilities = Selenium::WebDriver::Remote::Capabilities.phantomjs("phantomjs.page.settings.userAgent" => "Custom Agent/1.0")
Selenium::WebDriver.for :phantomjs, :desired_capabilities => capabilities

…s to be specified for PhantomJS so that phantomjs.page.settings.* can be specified

The phantomjs.page.settings.* settings are passed in as part of the Capabilties object, so e.g. we now can change the user-agent like so:

  capabilities = Selenium::WebDriver::Remote::Capabilities.phantomjs("phantomjs.page.settings.userAgent" => "Custom Agent/1.0")
  Selenium::WebDriver.for :phantomjs, :desired_capabilities => capabilities
@detro
Copy link
Contributor

detro commented Jan 29, 2013

Can I suggest to also implement https://github.com/detro/ghostdriver/blob/master/binding/java/src/main/java/org/openqa/selenium/phantomjs/PhantomJSDriverService.java#L250? This allows an array of string passed for Capability phantomjs.cli.args to be passed down to the PhantomJS executable.

@jarib
Copy link
Member

jarib commented Jan 29, 2013

@kuahyeow: Thanks for this. Have you signed the CLA? http://goo.gl/qC50R I've thought about this for a while, and would eventually like to make the same change for all the drivers.

@detro: I'll put that on the TODO as well.

@detro
Copy link
Contributor

detro commented Jan 29, 2013

Cool ;)
On 29 Jan 2013 14:42, "Jari Bakken" notifications@github.com wrote:

@kuahyeow https://github.com/kuahyeow: Thanks for this. Have you signed
the CLA? http://goo.gl/qC50R I've thought about this for a while, and
would eventually like to make the same change for all the drivers.

@deStrO https://github.com/destro: I'll put that on the TODO as well.


Reply to this email directly or view it on GitHubhttps://github.com//pull/8#issuecomment-12837422.

@kuahyeow
Copy link
Author

@jarib Yes, I have signed the CLA. Nice!

@detro Cool, I did not know about those.

@kuahyeow
Copy link
Author

kuahyeow commented Feb 3, 2013

So, urm. Do you want to implement for all drivers now, or later ? :)

To cherry-pick some examples : Chrome, and opera can accept various arguments using create_capabilities. Android allows a straight :desired_capabilities option. Which one would it be ?

@jarib
Copy link
Member

jarib commented Feb 4, 2013

I'd like to implement :desired_capabilities for all drivers in time for the next release. create_capabilities is not part of any public API IIRC.

@kuahyeow
Copy link
Author

kuahyeow commented Feb 4, 2013

@jarib Cool, just trying understand how it works. One other patch for PhantomJs , which @sj26 did include in #11 was the ability to specify a :port. Would that be included in : desired_capabilities or is that an option on it's own ?

@ghost ghost assigned jarib Feb 8, 2013
@jarib
Copy link
Member

jarib commented Feb 20, 2013

This won't be in 2.30 (which I need to get out for Firefox 19 support), but I'll get it into 2.31.

@jarib
Copy link
Member

jarib commented Mar 2, 2013

I'm going to get this done and push 2.31 today.

@jarib
Copy link
Member

jarib commented Mar 2, 2013

@kuahyeow I added a :port argument you can pass directly to the driver (similar to what you already can do for Firefox). However if you need this much control over the driver, you may consider using Selenium::WebDriver::PhantomJS::Service + the remote driver directly.

@jarib jarib closed this Mar 2, 2013
@kuahyeow
Copy link
Author

kuahyeow commented Mar 3, 2013

Thanks ! The :port and the phantomjs.page.settings.* are really two different use cases. Yes, that's what I'm currently using, e.g.:

@service = Selenium::WebDriver::PhantomJS::Service.new Selenium::WebDriver::PhantomJS::Service.executable_path, $webdriver_port
@service.start

at_exit do
  # Try to ensure it stops
  @service.stop
end

@driver = Selenium::WebDriver.for :phantomjs, :url => @service.uri

As a workaround currently it works great. Of course I would prefer passing in port, etc just like FirefoxDriver :)

@jarib
Copy link
Member

jarib commented Mar 3, 2013

Right. In case it wasn't clear, since 2.31 you can:

caps = Selenium::WebDriver::Remote::Capabilities.phantomjs(
  "phantomjs.page.settings.userAgent" => "Custom Agent/1.0"
)

driver = Selenium::WebDriver.for :phantomjs, :port => 1111, :desired_capabilities => caps

@kuahyeow
Copy link
Author

kuahyeow commented Mar 3, 2013

@jarib Brilliant, upgrading to 2.31 now

@chenillen
Copy link

Thanks @jarib solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants