URL无法使用WebDriver打开

时间:2015-10-05 06:31:48

标签: java selenium selenium-webdriver

我的代码是

package mentor.qa.selenium;

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class WDDemo1 {

    public static void main( String[] args){
        WebDriver driver = new FirefoxDriver();         
        driver.get("http://www.google.com");
    }
}

我使用的是最新的java jar文件2.47.1和Firefox 41.0.1。它启动Firefox但不会转到链接。我该如何解决?

2 个答案:

答案 0 :(得分:0)

代码正在运行,但优化了导入。

我用微小的编辑来运行你的代码。它打开谷歌网站。如果您已在构建路径中导入selenium-java和selenium-server-stand独立jar文件,请重新验证。

package com.jayant.selenium;

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

public class SampleSelenium {
    public static void main( String[] args){
        WebDriver driver = new FirefoxDriver();
        driver.get("http://www.google.com");
    }
}

答案 1 :(得分:-1)

您的代码非常完美。它可能是配置问题,即使用相同代码的较低版本的Firefox。它会起作用