使用的代码:
package cucmberTest;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class SeleniumTest {
System.setProperty("webdriver.gecko.driver", "C:\\java\\geckoDriver\\geckodriver-v0.16.1-win64\\geckodriver.exe");
private static WebDriver driver = null;
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver", "C:\\java\\geckoDriver\\geckodriver-v0.16.1-win64\\geckodriver.exe");
// TODO Auto-generated method stub
driver = new FirefoxDriver();
//Put a Implicit wait, this means that any search for elements on the page could take the time the implicit wait is set for before throwing exception
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
//Launch the Onlinebank
//driver.get("https://tst-2015.moneyou.nl/hypotheek/berekenen/bereken-je-maximale-hypotheek#");
driver.get("https://www.google.com");
driver.quit();
}
}
错误:
Exception in thread "main" java.lang.Error: Unresolved compilation problem: at cucmberTest.SeleniumTest.main(SeleniumTest.java:15)
答案 0 :(得分:1)
你只需要在main方法
之前删除(System.setProperty)请尝试以下代码
package cucmberTest;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class SeleniumTest {
private static WebDriver driver = null;
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver", "C:\\java\\geckoDriver\\geckodriver-v0.16.1-win64\\geckodriver.exe");
// TODO Auto-generated method stub
driver = new FirefoxDriver();
//Put a Implicit wait, this means that any search for elements on the page could take the time the implicit wait is set for before throwing exception
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
//Launch the Onlinebank
//driver.get("https://tst-2015.moneyou.nl/hypotheek/berekenen/bereken-je-maximale-hypotheek#");
driver.get("https://www.google.com");
driver.quit();
}
}