Windows 10 - 32位
Selenium版本:
3.0.0 beta 3 浏览器:
Firefox 48.02 Eclipse Luna 32位
package newpackage;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class MyClass {
public static void main(String[] args) {
// declaration and instantiation of objects/variables
System.setProperty "webdriver.firefox.marionette","D:\\Selenium\\geckodriver.exe");
//System.setProperty("webdriver.gecko.driver","D:\\Selenium\\geckodriver.exe");
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);
}
}
错误:
org.openqa.selenium.firefox.NotConnectedException:无法连接 在45000 ms后在端口7055上托管127.0.0.1。 Firefox控制台输出: LES":[]," targetApplications":[{" ID":" {ec8030f7-C20A-464f-9b0e-13a3a9e97384}"&# 34; MINVERSION":" 1.5"" MAXVERSION":" 9.9"}]," targetPlatforms":[], " multiprocessCompatible":假," signedState":0,"看出":真}
答案 0 :(得分:0)
这种问题将在selenium 3.0测试版中出现。
如果您正在使用Selenium Standalone jar,那么您必须将marionette作为功能传递并按如下方式初始化FirefoxDriver:
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
WebDriver driver = new FirefoxDriver(capabilities);
尝试使用geckodriver v 0.10.0。
String driverPath = "<path to gecko driver executable>";
public WebDriver driver;
public void launchBrowser() {
System.out.println("launching firefox browser");
System.setProperty("webdriver.gecko.driver", driverPath+"geckodriver.exe");
driver = new FirefoxDriver();
}