Selenium 3 InternetExplorer 驱动程序设置

Selenium 3 InternetExplorerDriver Setup

我正在尝试为 WebDriver 设置一种样板代码,我可以将其提供给我的 QA 团队中的任何人以帮助他们进行测试。我的问题是我似乎无法让 Internet Explorer 工作。它抛出错误,我不知道如何修复它们或者它是否存在某种命名问题。 驱动程序文件都在我的 C:\ 驱动器中。

chromedriver.exe、geckodriver.exe、IEDriverServer.exe

以下代码中的错误 //已注释

  import org.openqa.selenium.By;
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.WebElement;
  import org.openqa.selenium.chrome.ChromeDriver;
  import org.openqa.selenium.firefox.FirefoxDriver;
  import org.openqa.selenium.ie.IEDriverService; //The import org.openqa.selenium.ie.IEDriverService cannot be resolved

public class Loginmethod {

public static void main(String[] args) throws InterruptedException {
    System.setProperty("webdriver.gecko.driver", "C:\\geckodriver.exe");
    System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
    System.setProperty("webdriver.ie.driver", "C:\\IEDriverServer.exe");
    WebDriver driver = new InternetExplorerDriver(); //InternetExplorerDriver cannot be resolved to a type
    driver.get("http://www.google.com/");

    Thread.sleep(100);


}
}

此外,如果有人知道使用 windows 10 和 selenium 测试 Safari 的方法,那就太好了。

您尝试导入的 class 不是您正在使用的 class。

您正在导入 IEDriverService 但使用 InternetExplorerDriver class。

更改您的代码以导入 InternetExplorerDriver