2

I am using a Mac as well as IntelliJ. I am trying to update Selenium from 2.53 as the website I am testing has functions that no longer work with older versions of Firefox (version 46). I am trying to update to Version 49 of Firefox. I am trying to update to Selenium 3.0.1 from 2.53.

I have downloaded the 0.11.1 Geckodriver and named it to geckodriver. I have included:

System.setProperty("webdriver.gecko.driver","/Users/jwhitmore/Downloads/WebDrivers/firefox/geckodriver");. 

I have set the folder geckodriver is in in the PATH. No matter what I do I cannot seem to get selenium webdriver 3.0.1 to work in IntelliJ.

public class MultiSelect {

    WebDriver driver;
    Actions actions = new Actions(driver);

    @Before
    public void login() throws Exception {
        System.setProperty("webdriver.gecko.driver","/Users/jwhitmore/Downloads/WebDrivers/firefox/geckodriver");
        driver = new FirefoxDriver();
    }

        @After
    public void close() {
        driver.close();
    }

    public void loginTest() throws Exception {
        driver.get("http://192.168.1.23:8080");
        driver.findElement(By.id("name-inputEl")).sendKeys("user");
        driver.findElement(By.id("textfield-1009-inputEl")).sendKeys("pass" + Keys.ENTER);
            driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        driver.findElement(By.xpath("/html/body/span[1]/div/div[2]/div/div/a[5]/span/span/span[2]")).click();
    }
}

I still get this error:

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/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases
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$000(GeckoDriverService.java:37)
at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:95)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296)
at org.openqa.selenium.firefox.FirefoxDriver.createCommandExecutor(FirefoxDriver.java:277)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:247)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:242)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:238)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:127)
at com.compusoft.synoptixServer.Scheduler.MultiSelect.<init>(MultiSelect.java:17)
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.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:217)
at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:266)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

I have been wondering if this is a syntax issue with Mac? Please any suggestions would be helpful. Let me know if there is any additional information you need.

  • try using "/Users/jwhitmore/Downloads/WebDrivers/firefox/" this path – Vel Guru Dec 29 '18 at 5:01
0

In order to avoid not having permission to access into a Download folder on your computer, you can add the geckodriver executable into your project. I usually do the following:

/******** The driver selected is Local: Firefox  ********/      
         if ("FIREFOX".equalsIgnoreCase(browser)) {
             if("WINDOWS".equalsIgnoreCase(os)){
                 System.setProperty("webdriver.gecko.driver", resourceFolder+os+"/geckodriver.exe");    
             }
             else{
                 System.setProperty("webdriver.gecko.driver", resourceFolder+os+"/geckodriver");    
             }
             driver = new FirefoxDriver();  
}

I usually have a WebDriverFactory in order to open the instance on the OS you choose. I save all the executable files (geckodriver, chromedriver..) in the resourceFolder of my project.

Also, remember (on MacOSX) to give executable permission into the geckodriver file:

chmod +x geckodriver

If you want to see an example, you can see my repository here: https://github.com/estefafdez/selenium-cucumber/blob/master/src/main/java/com/selenium/configure/environment/WebDriverFactory.java

I hope it works for you now!

0

You can let Webdriver try to locate the geckodriver executable from the system PATH but you will need to add the directory containing the executable to the system path.

This can be done from the shell with the following command:

  • export PATH=$PATH:/path/to/geckodriver

Then in @before:

  • System.setProperty("webdriver.gecko.driver", "path/to/geckodriver");

  • WebDriver driver = new FirefoxDriver();

https://firefox-source-docs.mozilla.org/testing/geckodriver/geckodriver/Usage.html

-1

try adding .exe to geckodriver. it may work - you also can move the driver somewhere specific and reference it explicitly:

System.setProperty("webdriver.gecko.driver","/home/exeter/D‌​ownloads/geckodriver‌​");
DesiredCapabiliti‌​es capabilities=DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true); 
WebDriver driver = new FirefoxDriver(capabilities);
  • I figured that Mac couldn't use .exe's? In any case I add the .exe and now it just throws a NullPointerException. Not sure if that moves me in the right or wrong direction. java.lang.NullPointerException at org.openqa.selenium.interactions.Actions.<init>(Actions.java:44) at com.compusoft.synoptixServer.Scheduler.MultiSelect.<init>(MultiSelect.java:17) – Senator1891 Nov 15 '16 at 14:16
  • Mate am using intellij in ubuntu, it works fine for me. one thing i could suggest you try to place your geckodriver into a different path – Harri Nov 16 '16 at 3:57
  • after moving geckodriver to a new location try this – Harri Nov 16 '16 at 3:59
  • ` System.setProperty("webdriver.gecko.driver","/home/exeter/Downloads/geckodriver"); DesiredCapabilities capabilities=DesiredCapabilities.firefox(); capabilities.setCapability("marionette", true); WebDriver driver = new FirefoxDriver(capabilities);` – Harri Nov 16 '16 at 4:00
  • sorry for previous responses try this code `System.setProperty("webdriver.gecko.driver","/home/exeter/Downloads/geckodriver");DesiredCapabilities capabilities=DesiredCapabilities.firefox(); capabilities.setCapability("marionette", true); WebDriver driver = new FirefoxDriver(capabilities); – Harri Nov 16 '16 at 4:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.