无法启动浏览器

时间:2020-08-19 07:46:54

标签: selenium selenium-webdriver browser webdriver

公共类LaunchBrowser {

public static void main(String[] args) {
    WebDriver driver = new FirefoxDriver();
    System.setProperty("webdriver.gecko.driver", "/Users/spectra/Drivers/geckodriver");
    driver.manage().window().maximize();
    driver.manage().timeouts().implicitlyWait(40,TimeUnit.SECONDS);
    driver.manage().timeouts().pageLoadTimeout(90, TimeUnit.SECONDS);
    driver.get("https://www.seleniumhq.org");
    
    
}

}

线程“ main”中的异常java.lang.Error:未解决的编译问题: WebDriver无法解析为一种类型 FirefoxDriver无法解析为类型

at com.simplilearn.day2.oops.LaunchBrowser.main(LaunchBrowser.java:16)

1 个答案:

答案 0 :(得分:1)

驱动程序初始化之前的

setProperty应该是

 public static void main(String[] args) {
      System.setProperty("webdriver.gecko.driver", "/Users/spectra/Drivers/geckodriver");
      WebDriver driver = new FirefoxDriver();
      driver.manage().window().maximize();
      driver.manage().timeouts().implicitlyWait(40,TimeUnit.SECONDS);
      driver.manage().timeouts().pageLoadTimeout(90, TimeUnit.SECONDS);
      driver.get("https://www.seleniumhq.org");
 }