弄了半小时,把网上的代码考下来试试吧:
还挺好用,java调用火狐,试验成功;
”package testWebdriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class testFirefox {
public static void main(String[] args) throws InterruptedException {
System.out.print("begin");
//D:\cert\geckodriver.exe
String driverPath=System.getProperty("user.dir")+"/geckodriver-v0.28.0-win64/geckodriver.exe";
System.setProperty("webdriver.gecko.driver",driverPath);
System.setProperty("webdriver.firefox.bin", "C:/Program Files/Mozilla Firefox/firefox.exe");
WebDriver driver = new FirefoxDriver();
driver.get("http://www.baidu.com");
WebElement loginLink = driver.findElement(By.partialLinkText("登录"));
loginLink.click();
}
}