gpt4 book ai didi

java - Selenium 3 InternetExplorer 驱动程序设置

转载 作者:行者123 更新时间:2023-12-01 09:20:40 26 4
gpt4 key购买 nike

我正在尝试为 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,那就太好了。

最佳答案

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

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

更改代码以导入 InternetExplorerDriver

关于java - Selenium 3 InternetExplorer 驱动程序设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40183139/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com