package TestNG;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.sql.Driver;
import java.util.concurrent.TimeUnit;
import org.testng.annotations.AfterTest;
import org.openqa.selenium.support.FindBy;
public class TestNGClass {
WebDriver driver = new FirefoxDriver();
@FindBy(id="Email")
private WebElement gmailUserName;
@FindBy(id="Passwd")
private WebElement gmailPwd;
@FindBy(id="SignIn")
private WebElement logInbtn;
@Test
public void gmailLogin() {
System.setProperty("webdriver.geko.driver","C:\\Users\\Vivek\\Downloads\\geckodriver-v0.11.1-win32\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
gmailUserName.clear();
gmailUserName.sendKeys("hkj@gmail.com");
gmailPwd.clear();
gmailPwd.sendKeys("password");
logInbtn.click();
}
@BeforeTest
public void launchapp() {
System.setProperty("webdriver.geko.driver","C:\\Users\\Vivek\\Downloads\\geckodriver-v0.11.1-win32\\geckodriver.exe");
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
}
@AfterTest
public void afterTest() {
driver.close();
}
}
错误。
The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases
at com.google.common.base.Preconditions.checkState(Preconditions.java:199)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:109)
at org.openqa.selenium.firefox.GeckoDriverService.access$000(GeckoDriverService.java:37)
at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:95)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296)
at org.openqa.selenium.firefox.FirefoxDriver.createCommandExecutor(FirefoxDriver.java:277)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:247)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:242)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:238)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:127)
at TestNG.TestNGClass.<init>(TestNGClass.java:17)
... 30 more