0
votes

I'm using selenium 3.0.0-beta4 version. Tried to configure settings for geckoDriver on my project. I used Maven and TestNG along with java.

import java.util.concurrent.TimeUnit;
import org.testng.annotations.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.WebDriver;

public class GmailSignupAutomation {
    private WebDriver driver;
      private String baseUrl;

 @BeforeClass(alwaysRun = true)
      public void setUp() throws Exception {System.setProperty("webdriver.gecko.driver","D://software_/geckodriver-v0.11.1-win64/geckodriver.exe");

      DesiredCapabilities capabilities = DesiredCapabilities.firefox();
      capabilities.setCapability("marionette", true);
      **driver = new FirefoxDriver(capabilities);**

        baseUrl = "https://accounts.google.com/";
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
      }

@Test
      public void testGoogleAccountLoginForm() throws Exception {
        driver.get(baseUrl + "//SignUp?service=mail&continue=https://mail.google.com/mail/?pc=topnav-about-en");
        driver.findElement(By.id("FirstName")).clear();
        driver.findElement(By.id("FirstName")).sendKeys("HOSSAIN");
      }

@AfterClass(alwaysRun = true)
      public void tearDown() throws Exception {
        driver.quit();
      }

}

And here is the output:

1476438749160 geckodriver INFO Listening on 127.0.0.1:39530 Oct 14, 2016 3:52:29 PM org.openqa.selenium.remote.ProtocolHandshake createSession

INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end

1476438749613 mozprofile::profile INFO Using profile path C:\Users\HOSSAI~1.MAH\AppData\Local\Temp\rust_mozprofile.e9aWwalq9rWK

1476438749656 geckodriver::marionette INFO Starting browser C:\Program Files\Mozilla Firefox\firefox.exe

1476438749683 geckodriver::marionette INFO Connecting to Marionette on localhost:61519 Oct 14, 2016 3:52:32 PM org.openqa.selenium.remote.ProtocolHandshake createSession

INFO: Falling back to straight W3C remote end connection

1476438752490 mozprofile::profile INFO Using profile path C:\Users\HOSSAI~1.MAH\AppData\Local\Temp\rust_mozprofile.D6FkME6daU3V

1476438752499 geckodriver::marionette INFO Starting browser C:\Program Files\Mozilla Firefox\firefox.exe

1476438752535 geckodriver::marionette INFO Connecting to Marionette on localhost:61527 Oct 14, 2016 3:52:37 PM org.openqa.selenium.remote.ProtocolHandshake createSession

INFO: Falling back to original OSS JSON Wire Protocol. 1476438757062 mozprofile::profile INFO Using profile path

C:\Users\HOSSAI~1.MAH\AppData\Local\Temp\rust_mozprofile.FHKHmYIM3lXI

1476438757069 geckodriver::marionette INFO Starting browser C:\Program Files\Mozilla Firefox\firefox.exe

1476438757127 geckodriver::marionette INFO Connecting to Marionette on localhost:61557

[Utils] Attempting to create D:\Projects\Automation\GoogleSignupAutomation\test-output\Default suite\Default test.xml

[Utils] Directory D:\Projects\Automation\GoogleSignupAutomation\test-output\Default suite exists: true

FAILED CONFIGURATION: @BeforeClass setUp org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{marionette=true, browserName=firefox, version=, platform=ANY}], required capabilities = Capabilities [{}]

Build info: version: 'unknown', revision: '3169782', time: '2016-09-29 10:24:50 -0700' System info: host: 'XYZ', ip: '101.140.178.123', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_102'

Driver info: driver.version: FirefoxDriver at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:80) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:602) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:129) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:247) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:235) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:230) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:226) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:124) at SeleniumAutomation.GoogleSignupAutomation.GmailSignupAutomation.setUp(GmailSignupAutomation.java:39) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:100) at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:515) at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:216) at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:143) at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:169) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108) at org.testng.TestRunner.privateRun(TestRunner.java:746) at org.testng.TestRunner.run(TestRunner.java:600) at org.testng.SuiteRunner.runTest(SuiteRunner.java:366) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319) at org.testng.SuiteRunner.run(SuiteRunner.java:268) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1264) at org.testng.TestNG.runSuitesLocally(TestNG.java:1189) at org.testng.TestNG.runSuites(TestNG.java:1104) at org.testng.TestNG.run(TestNG.java:1076) at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:152) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:57)

FAILED CONFIGURATION: @AfterClass tearDown java.lang.NullPointerException at SeleniumAutomation.GoogleSignupAutomation.GmailSignupAutomation.tearDown(GmailSignupAutomation.java:55) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:100) at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:515) at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:216) at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:143) at org.testng.internal.TestMethodWorker.invokeAfterClassMethods(TestMethodWorker.java:217) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:115) at org.testng.TestRunner.privateRun(TestRunner.java:746) at org.testng.TestRunner.run(TestRunner.java:600) at org.testng.SuiteRunner.runTest(SuiteRunner.java:366) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319) at org.testng.SuiteRunner.run(SuiteRunner.java:268) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1264) at org.testng.TestNG.runSuitesLocally(TestNG.java:1189) at org.testng.TestNG.runSuites(TestNG.java:1104) at org.testng.TestNG.run(TestNG.java:1076) at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:152) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:57)

SKIPPED: testGoogleAccountLoginForm

Default test
Tests run: 1, Failures: 0, Skips: 1

Configuration Failures: 2, Skips: 0

=============================================== Default suite Total tests run: 1, Failures: 0, Skips: 1 Configuration Failures: 2, Skips: 0

[TestNG] Time taken by org.testng.reporters.XMLReporter@3b938003: 50 ms [TestNG] Time taken by org.testng.reporters.EmailableReporter2@475e586c: 12 ms [Utils] Attempting to create D:\Projects\Automation\GoogleSignupAutomation\test-output\old\Default suite\toc.html [Utils] Directory D:\Projects\Automation\GoogleSignupAutomation\test-output\old\Default suite exists: true [Utils] Attempting to create D:\Projects\Automation\GoogleSignupAutomation\test-output\old\Default suite\Default test.properties [Utils] Directory D:\Projects\Automation\GoogleSignupAutomation\test-output\old\Default suite exists: true [Utils] Attempting to create D:\Projects\Automation\GoogleSignupAutomation\test-output\old\Default suite\index.html [Utils] Directory D:\Projects\Automation\GoogleSignupAutomation\test-output\old\Default suite exists: true [Utils] Attempting to create D:\Projects\Automation\GoogleSignupAutomation\test-output\old\Default suite\main.html [Utils] Directory D:\Projects\Automation\GoogleSignupAutomation\test-output\old\Default suite exists: true [Utils] Attempting to create D:\Projects\Automation\GoogleSignupAutomation\test-output\old\Default suite\groups.html [Utils] Directory D:\Projects\Automation\GoogleSignupAutomation\test-output\old\Default suite exists: true [Utils] Attempting to create D:\Projects\Automation\GoogleSignupAutomation\test-output\old\Default suite\classes.html [Utils] Directory D:\Projects\Automation\GoogleSignupAutomation\test-output\old\Default suite exists: true [Utils] Attempting to create D:\Projects\Automation\GoogleSignupAutomation\test-output\old\Default suite\reporter-output.html [Utils] Directory D:\Projects\Automation\GoogleSignupAutomation\test-output\old\Default suite exists: true [Utils] Attempting to create D:\Projects\Automation\GoogleSignupAutomation\test-output\old\Default suite\methods-not-run.html [Utils] Directory D:\Projects\Automation\GoogleSignupAutomation\test-output\old\Default suite exists: true [Utils] Attempting to create D:\Projects\Automation\GoogleSignupAutomation\test-output\old\Default suite\testng.xml.html [Utils] Directory D:\Projects\Automation\GoogleSignupAutomation\test-output\old\Default suite exists: true [Utils] Attempting to create D:\Projects\Automation\GoogleSignupAutomation\test-output\old\index.html [Utils] Directory D:\Projects\Automation\GoogleSignupAutomation\test-output\old exists: true [TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@780cb77: 95 ms [Utils] Attempting to create D:\Projects\Automation\GoogleSignupAutomation\test-output\junitreports\TEST-SeleniumAutomation.GoogleSignupAutomation.GmailSignupAutomation.xml [Utils] Directory D:\Projects\Automation\GoogleSignupAutomation\test-output\junitreports exists: true [TestNG] Time taken by org.testng.reporters.JUnitReportReporter@3a079870: 106 ms [TestNG] Time taken by org.testng.reporters.jq.Main@17c1bced: 241 ms [Utils] Attempting to create D:\Projects\Automation\GoogleSignupAutomation\test-output\testng-failed.xml [Utils] Directory D:\Projects\Automation\GoogleSignupAutomation\test-output exists: true [Utils] Attempting to create D:\Projects\Automation\GoogleSignupAutomation\test-output\Default suite\testng-failed.xml [Utils] Directory D:\Projects\Automation\GoogleSignupAutomation\test-output\Default suite exists: true [TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 8 ms

2
Edited the coding section for adding updates. After debugging "driver = new FirefoxDriver(capabilities)", found that: 1. The step threw Invoker.class 2. Opened 3 firefox blank windowsHossain Mahmood Tuhin

2 Answers

1
votes

i think After Setting the Driver path, u need to set the DesiredCapabilities to MarionetteDriver as shown in the Below Code. Works for me Fine.

DesiredCapabilities capabilities = DesiredCapabilities.firefox();
                            capabilities.setCapability("marionette", true);
                            Driver = new MarionetteDriver(capabilities);
1
votes

You can try with the following steps:

  1. Download the marionette driver
  2. Unarchive it to a folder of your choice
  3. In your code set the "webdriver.gecko.driver" property to the location of the .exe
  4. Use the MarionetteDriver
  5. rename the file to ‘wires.exe’ and add it to your path.

I did rename it to wires.exe, mainly to keep the code consistent so I wouldn’t have to update the code every time I change the version of the marionette driver.

But I didn’t add it to the path. I’d rather control that in the code when the option is provided.

Firefox 47 and above my code looks like this:

String currentDir = System.getProperty("user.dir");
String marionetteDriverLocation = currentDir + "/tools/marionette/wires.exe";
System.setProperty("webdriver.gecko.driver", marionetteDriverLocation);
WebDriver driver = new MarionetteDriver();

You can check the code update from the following github sample code: https://github.com/kumrunnaharkeya/sample-automation-selenium