我刚开始使用Java, Selenium和Webdriver
我使用:selenium 3 beta3, Java jdk1.8.0_101和firefox 48.01我还使用了Geckodriver,因为这是处理sel3所需要的。
我正在尝试打开一个url。打开浏览器工作。我使用的代码如下。
package AutomatedScripts;
import org.openqa.selenium.WebDriver; // driver for Webdriver
import org.openqa.selenium.firefox.FirefoxDriver; //driver for Firefox
public class GoogleSearchOneTime {
public static void main(String[] agrs) {
System.setProperty("webdriver.firefox.marionette","C:\selenium-3.0.0\geckodriver\geckodriver.exe");
// Launch a firefox browser
WebDriver driver = new FirefoxDriver();
// go to Google.com
driver.get("http://www.google.com");
// go to google.com
// driver.navigate().to("http://www.google.com");
//Enter search terms
//driver.findElement(By.id("lst-ib")).clear();
//driver.findElement(By.id("lst-ib")).sendKeys("Google");
//Click on the searh button
//driver.findElement(By.name("btnG")).click();
//check page title contacts the search term
}
}
更换您的系统。setProperty如下
System.setProperty("webdriver.gecko.driver", "C:\selenium-3.0.0\geckodriver\geckodriver.exe");
这里有一个示例链接,您可以参考使用Geckodriver启动firefox浏览器