-
Notifications
You must be signed in to change notification settings - Fork 407
Example - Setup proxy in Firefox with Marionette driver. #114
Conversation
@@ -286,11 +286,12 @@ As of this writing it is unknown how to set the proxy programmatically. | |||
.. #literalinclude:: /examples/Chapter4/ruby/ProxySetupChrome.rb | |||
.. :language: ruby | |||
|
|||
Firefox | |||
Firefox up to version 46 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
47.0.1
also rst is finicky... you need to make the ++++ below match up to the length of the line (we get warnings when building)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, got it!
@@ -304,6 +305,25 @@ that is created on the fly as is shown in the following example. | |||
.. literalinclude:: /examples/Chapter4/ruby/ProxySetupFirefox.rb | |||
:language: ruby | |||
|
|||
Firefox version 47 and newer - Marionette driver |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
48 and call it GeckoDriver (not marionette driver)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, got it!
+++++++ | ||
Firefox maintains its proxy configuration in a profile. You can preset the | ||
proxy in a profile and use that Firefox Profile or you can set it on profile | ||
that is created on the fly as is shown in the following example. | ||
that is created on the fly as is shown in the following example - | ||
deprecated, no longer working with Marionette driver. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Marionette/Gecko
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, got it!
Firefox maintains its proxy configuration in a profile. You can preset the | ||
proxy in a profile and use that Firefox Profile or you can set it on profile | ||
that is created on the fly as is shown in the following example. With | ||
Marionette driver the proxy has to be passed through the required capabilities. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Marionette/Gecko
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, got it!
DesiredCapabilities required = new DesiredCapabilities(); | ||
required.setCapability("proxy", json); | ||
|
||
driver = new FirefoxDriver(desired, required); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the only difference between this and the other is to pass in required capabilities...
So, why don't we just change that example to pass in the 'cap' to both desired and required and just put a comment like this:
// GeckoDriver currently needs the Proxy set in RequiredCapabilities, this will work for both
// GeckoDriver and Selenium's Firefox extension webdriver.xpi
WebDriver driver = new FirefoxDriver(cap, cap);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @lukeis,
You are right about this, but there is more. This example does not work with the constructor new FirefoxDriver(desired, required). It passes the capabilities through FirefoxDriver.extractProfile, that is calling populateProfile, that is adding "firefoxOptions" to capabilities.
desiredCapabilities=Capabilities [{marionette=true, firefoxOptions=org.openqa.selenium.firefox.FirefoxOptions@10dba097, browserName=firefox, version=, platform=ANY}]...
The response from the other side is
org.openqa.selenium.SessionNotCreatedException: Not all requiredCapabilities could be met: ["[object Object] does not equal undefined"]
It works with the service constructor
FirefoxDriver(GeckoDriverService driverService, Capabilities desiredCapabilities, Capabilities requiredCapabilities)
This does not change the capabilities, and it works.
So I will change the example to
GeckoDriverService service =new GeckoDriverService.Builder() .usingDriverExecutable(new File("path to geckodriver")) .usingAnyFreePort() .usingAnyFreePort() .build(); service.start(); WebDriver driver = new FirefoxDriver(service, cap, cap);
@lukeis , is it possible to add something like json.addProperty("noProxy", noProxy); I need to ignore some urls from the tests. Thanks! |
Hi @lukeis,
As you told me here
SeleniumHQ/selenium#2963
I have marked the old example as deprecated for Marionette and added my new example (only Java). When I have time I will try to write a python one too.
Please tell me if that needs any changes so that the pull request is accepted.
Best Regards,
Stefan Matei