我的代码是
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,但不会转到该链接。我该如何解决这个问题?
最佳答案
代码正在运行,但优化了导入。
我通过微小的编辑来运行你的代码。它打开谷歌网站。重新验证您是否已在构建路径中导入 selenium-java 和 selenium-server-standalone 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");
}
}
关于java - URL 无法使用 WebDriver 打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32942524/