WebDriverException:在PATH中找不到firefox二进制文件

时间:2015-02-16 05:02:17

标签: selenium automation webdriver

我已尝试运行此示例代码

package edsAutomation;

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

public class Example {

public static void main(String[] args) {
    // declaration and instantiation of objects/variables
    WebDriver driver = new FirefoxDriver();
    String baseUrl = "http://newtours.demoaut.com";
    String expectedTitle = "Welcome: Mercury Tours";
    String actualTitle = "";

    // launch Firefox and direct it to the Base URL
    driver.get(baseUrl);

    // get the actual value of the title
    actualTitle = driver.getTitle();

    /*
     * compare the actual title of the page witht the expected one and print
     * the result as "Passed" or "Failed"
     */
    if (actualTitle.contentEquals(expectedTitle)){
        System.out.println("Test Passed!");
    } else {
        System.out.println("Test Failed");
    }

    //close Firefox
    driver.close();

    // exit the program explicitly
    System.exit(0);
}

}

但是当我运行我的程序时,它会显示以下错误:

Exception in thread "main" org.openqa.selenium.WebDriverException: Cannot 
find firefox binary in PATH. Make sure firefox is installed. OS appears to 
be: XP
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', 
java.version: '1.8.0_25'

1 个答案:

答案 0 :(得分:-1)

确保firefox安装在默认位置:

(Windows)C:\ Program Files \ Mozilla Firefox \

(64位Windows)C:\ Program Files(x86)\ Mozilla Firefox \