-1

I'm using Firefox 45.8.0 version and I tried below code to open Firefox browser but i'm getting error that: "The path to the driver executable must be set by the webdriver.gecko.driver system property". Please sagest me how to set the path. Note:gecko driver will work for above firefox version 48.

package First;

    import org.openqa.selenium.firefox.FirefoxDriver;
    public class City {

        public static void main(String[] args) {
            // TODO Auto-generated method stub

            FirefoxDriver c1=new FirefoxDriver();
            c1.get("http://google.com");

        }

    }
Naresh Babu
  • 81
  • 1
  • 10

1 Answers1

3

Try this below code.

In your code you were not provide gecko driver path. You can download gecko driver from this link

public class City {

    public static void main(String[] args) {

        System.setProperty("webdriver.gecko.driver", "C:\\Drivers\\geckodriver.exe");
        WebDriver driver = new FirefoxDriver();
        driver.manage().window().maximize();
        driver.manage().timeouts().implicitlyWait(25, TimeUnit.SECONDS);
        driver.get("http://google.com");  
    }
}
Jainish Kapadia
  • 2,603
  • 5
  • 18
  • 29
  • 3
    Any specific reason to introduce ImplicitlyWait even before passing the url? – undetected Selenium Mar 31 '17 at 12:08
  • Yes, sometimes browser may take some time for open the browser. so it's better to first open the browser and then pass the url. If you will not provide implicit wait then sometimes you will get an error like `element not found` because browser is still not open and driver move to the next element. – Jainish Kapadia Mar 31 '17 at 12:12
  • 1
    @Dev implicit waits are set once for the driver and last the lifetime of the driver. It doesn't actually wait at the point that it's set so it doesn't matter whether it's set before or after the `.get()`. – JeffC Mar 31 '17 at 13:40