简体   繁体   中英

Selenium Webdriver 3- URL is not getting entered into the Firefox Browser

Windows 10 - 32 bit

Selenium Version:

3.0.0 beta 3 Browser:

Firefox 48.02 Eclipse Luna 32 bit

 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);
}


}

Error:

org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output: les":[],"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"1.5","maxVersion":"9.9"}],"targetPlatforms":[],"multiprocessCompatible":false,"signedState":0,"seen":true}

This kind of issues are coming in selenium 3.0 beta version.

If you are using using Selenium Standalone jar then you have to pass marionette as capabilities and initialize FirefoxDriver as follows:

DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
WebDriver driver = new FirefoxDriver(capabilities);

Tried with 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();
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM