Permalink
Browse files

updated for Marionette and Firefox 46

  • Loading branch information...
1 parent 0a1698e commit f9eef60293cbde0bcdb7f20bb04a1af78e9374d3 eviltester committed Apr 25, 2016
Showing with 44 additions and 3 deletions.
  1. +2 −1 .gitignore
  2. +10 −0 README.md
  3. +32 −2 src/test/java/com/eviltester/webdriver/MyFirstTest.java
View
@@ -1,4 +1,5 @@
/target
*.iml
-/.idea
+/.idea
+/tools
View
@@ -9,6 +9,16 @@ You can find the Free Online course here:
The source code has only really been uploaded in case people encounter problems following the instructions or make a very simple mistake that they cannot figure out.
+## Update 25th April 2016
+
+Firefox 46 changes the way that WebDriver has to interact with it. So the built in `FirefoxDriver` will not work. You need to install Firefox 45 from [Firefox Extended Support Release](https://www.mozilla.org/en-US/firefox/organizations/all/) to continue using `FirefoxDriver`.
+
+If you want to use Firefox 46 and later then you need to use the [Marionette](https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver) driver.
+
+Follow the instructions on the Marionette page to download it. You do not need to add it to your path, you can control that through a system property - see the code in this project for more detail.
+
+## Pre April 2016 updates
+
The code has changed slightly because we now need to do a .close and a .quit to exit Firefox
And I've updated the version of WebDriver.
@@ -3,14 +3,44 @@
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.firefox.FirefoxDriver;
+import org.openqa.selenium.firefox.MarionetteDriver;
public class MyFirstTest {
@Test
public void startWebDriver(){
- WebDriver driver = new FirefoxDriver();
+ /** NOTE: For Firefox 45 and below
+ * The following code will work on Firefox version 45 and below
+ * It will not work on Firefox 46 released in the week of 25th April 2016
+ * If you want to keep using version 45 then you can download it from here:
+ * https://www.mozilla.org/en-US/firefox/organizations/all/
+ */
+
+ //WebDriver driver = new FirefoxDriver();
+
+ /** NOTE: If the test does not work
+ * Check your Firefox version. If you are on version 46 or above then
+ * you need to use the Marionette driver.
+ *
+ * Download the Marionette driver from here
+ * https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver
+ *
+ * I assume you have unarchived the file into a /tools directory which would be a peer to
+ * the pom.xml file e.g.
+ * pom.xml
+ * /tools
+ * /marionette
+ * wires.exe
+ *
+ * The code below assumes a code structure like that. You will need to change
+ * the marionetteDriverLocation below if you choose a different location
+ */
+
+ String currentDir = System.getProperty("user.dir");
+ String marionetteDriverLocation = currentDir + "/tools/marionette/wires.exe";
+ System.setProperty("webdriver.gecko.driver", marionetteDriverLocation);
+ WebDriver driver = new MarionetteDriver();
driver.navigate().to("http://seleniumsimplified.com");

7 comments on commit f9eef60

@sandeepjain1987

Hi @eviltester ,
Thanks for sharing your code on github. I followed your steps to use marionette webdriver but I am getting the following error. can you please help ?

Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'JAINS13-L3', ip: '192.168.1.4', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_92'
Driver info: driver.version: MarionetteDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:665)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:234)
at org.openqa.selenium.firefox.MarionetteDriver.run(MarionetteDriver.java:79)
at org.openqa.selenium.firefox.MarionetteDriver.(MarionetteDriver.java:73)
at org.openqa.selenium.firefox.MarionetteDriver.(MarionetteDriver.java:45)
at demo.main(demo.java:29)
Caused by: org.openqa.selenium.WebDriverException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:38020 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'JAINS13-L3', ip: '192.168.1.4', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_92'
Driver info: driver.version: MarionetteDriver
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:91)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)
... 6 more
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to localhost:38020 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:158)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:144)
at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:90)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
... 7 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:74)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:141)
... 20 more

@eviltester
Owner

The only way I could recreate your issue was to try and instantiate Firefox 47 with new FirefoxDriver().

Are you sure your code uses the Marionette code and doesn't try and instantiate Firefox 47 directly with FirefoxDriver?

@sandeepjain1987

Thanks for your reply. Yes. It did work when I downgraded marionette jar file to 0.6.2. While it doesn't work when used on remotewebdriver. for instance:

                  System.setProperty("webdriver.gecko.driver", "/.....n//wires-0.6.2-win.exe");
                   URL server = new URL("http://10.121.64.185:4444/wd/hub");
            DesiredCapabilities capabilities = DesiredCapabilities.firefox();
            capabilities.setCapability("marionette", true);
             driver = new RemoteWebDriver(server, capabilities);
            driver.get("https://www.google.co.in");

I get the following error:

Exception in thread "main" org.openqa.selenium.WebDriverException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/jgraham/wires. The latest version can be downloaded from https://github.com/jgraham/wires
Command duration or timeout: 284 milliseconds
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'JAINS13-L3', ip: '10.121.65.215', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_92'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:158)
at demo.main(demo.java:64)
Caused by: java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/jgraham/wires. The latest version can be downloaded from https://github.com/jgraham/wires
at com.google.common.base.Preconditions.checkState(Preconditions.java:199)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:109)
at org.openqa.selenium.firefox.GeckoDriverService.access$0(GeckoDriverService.java:1)
at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:80)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296)
at org.openqa.selenium.firefox.MarionetteDriver.setupService(MarionetteDriver.java:94)
at org.openqa.selenium.firefox.MarionetteDriver.(MarionetteDriver.java:71)
at org.openqa.selenium.firefox.MarionetteDriver.(MarionetteDriver.java:49)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.server.FirefoxDriverProvider.callConstructor(FirefoxDriverProvider.java:91)
at org.openqa.selenium.remote.server.FirefoxDriverProvider.newInstance(FirefoxDriverProvider.java:66)
at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:60)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:222)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:1)
at java.util.concurrent.FutureTask.run(Unknown Source)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

@eviltester
Owner

Your wires.exe needs to be on the hub machine. Setting the property in the @Test will not impact the hub. You'll want to add the folder that contains wires.exe to the path on the hub machine or set this as a property when starting the hub - path might be easier.

@sandeepjain1987

Thanks for the suggestion. This is how hub will be set ?
java -classpath "selenium-server-standalone-2.48.2.jar;servlet.jar;" org.openqa.grid.selenium.GridLauncher -role hub -servlets com.seleniumgrid2api.servlet.AllProxiesJsonServlet -Dwebdriver.gecko.driver="C:\bin\Selenium\wires.exe"

@eviltester
Owner

That looks about right. Did you try it? If it doesn't work then experiment with adding c:\bin\selenium to the path on the hub machine.

@sandeepjain1987

Yes and it works when I downgrade Marionette driver file to 0.6.2 from v0.8.0. Latest version of the file was the problem

Please sign in to comment.