1
votes

Below is my code. I am using FF version 49.0.1 and am using selenium server 3.0 beta version .Have added geckodriver.exe in my code using system.setProperty. Also i have my FF.exe in my system PATH variable too. Even though i am getting below error . Anyone help to resolve this

Exception in thread "main" org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: VISTA Build info: version: 'unknown', revision: 'c7b525d', time: '2016-09-01 14:52:30 -0700' os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_77' Driver info: driver.version: FirefoxDriver at org.openqa.selenium.firefox.internal.Executable.(Executable.java:75) at org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:60) at org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:56) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:123) at Learning.Day1.main(Day1.java:13)

package Learning;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Day1 {

    public static void main(String[] args)
    {
        System.setProperty("webdriver.gecko.driver","PATH OF geckodriver.exe");
        WebDriver driver = new FirefoxDriver();
        driver.get("URL ");
        if(driver.getTitle().equals(" Home Page "))
        {
            System.out.print("Welcome to page");
        }
        else 
        {
            System.out.println("We are not in required page");
        }
        driver.findElement(By.name("uid")).sendKeys("username");
        driver.findElement(By.name("password")).sendKeys("pwd");
        driver.findElement(By.name("btnLogin")).click();
    }
}
2

2 Answers

2
votes

Type this:

"System.setProperty("webdriver.firefox.bin", "C:\\Program Files\\Mozilla Firefox\\firefox.exe");"

before your set property for Gecko driver.

This issue is for some systems who cannot find the path for the installed Firefox.

0
votes

Take a look at this post:

https://stackoverflow.com/a/23910165/5729951

It seems that your firefox installation dir isn't the typical one. You have to tell selenium where the firefox binary file is.