0

我无法使用最新的 Selenium 版本(2.53,Selenium 3 beta)在Firefox 48上运行我的测试。

请解释在 Firefox 48 上成功运行测试所需的配置和代码。我已经指向 geckodriver 并尝试在我的代码中初始化它。

代码

System.setProperty("webdriver.gecko.driver","E:\\Work\\Selenium\\geckodriver-v0.9.0-win64\\geckodriver.exe");
WebDriver driver = null;
driver = new MarionetteDriver();

获得以下内容

org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
4

3 回答 3

1

为我工作:

System.setProperty("webdriver.gecko.driver", "PATH TO GECKO DRIVER");
DesiredCapabilities ffCapabilities = DesiredCapabilities.firefox();
ffCapabilities.setCapability("marionette",true);
WebDriver driver = new FirefoxDriver(ffCapabilities);
于 2016-09-07T10:35:47.583 回答
0

You can download geckodriver from the link https://github.com/mozilla/geckodriver/releases Then save the file in your local system. unzip the file and change the application name as "wires.exe". Then specify the path upto wires.exe in the code.

add selenium-2.53.0 jar files.

Try below code to start working on FF 47.0 or above.

package com.marionette.programs;

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

public class HandleLatestFirefox {

public static void main(String[] args) {
    String currentDir = System.getProperty("user.dir");
    System.out.println(currentDir);
    //String marionetteDriverLocation = currentDir + "G:\\ravik\\Ravi-Training\\Selenium\\Marionette for firefox\\wires.exe";
    System.setProperty("webdriver.gecko.driver", "G:\\ravik\\Ravi-Training\\Selenium\\Marionette for firefox\\wires.exe");
    WebDriver driver = new MarionetteDriver();
    driver.get("https://www.google.co.in/webhp?hl=en&sa=X&ved=0ahUKEwjdgc21jJHOAhVCvY8KHZ4aCdcQPAgD");
    System.out.println("marionette working fine....");

}

}

于 2016-09-07T09:50:31.493 回答
0

你需要写DesiredCapabilities。在驱动程序初始化之前添加此行。

DesiredCapabilities cap = DesiredCapabilities.firefox()

于 2016-09-07T07:11:36.033 回答