簡體   English   中英

無法使用Internet Explorer驅動程序運行Selenium WebDriver測試

[英]Unable to run Selenium WebDriver tests with Internet Explorer Driver

使用Java運行硒測試期間,我在控制台選項卡中遇到了以下錯誤。

Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.ie.driver system property; for more information, see http://code.google.com/p/selenium/wiki/InternetExplorerDriver. The latest version can be downloaded from http://selenium-release.storage.googleapis.com/index.html
    at com.google.common.base.Preconditions.checkState(Preconditions.java:177)
    at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:105)
    at org.openqa.selenium.ie.InternetExplorerDriverService.access$1(InternetExplorerDriverService.java:1)
    at org.openqa.selenium.ie.InternetExplorerDriverService$Builder.build(InternetExplorerDriverService.java:230)
    at org.openqa.selenium.ie.InternetExplorerDriver.setupService(InternetExplorerDriver.java:251)
    at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:172)
    at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:146)
    at superadminmodule.LoginInPage.main(LoginInPage.java:11)

您需要在PC上設置InternetExplorerDriver 。從該位置下載並按需解壓縮IEDriverServer.zip。該位置位於PC PATH中 。請從此處查看更多詳細信息

如果您將Selenium Web驅動程序與JUnit或其他測試框架一起使用,則需要在代碼中設置InternetExplorerDriver路徑。

@Before
public void setUp() throws Exception {
    File file = new File("C:\\IEDriverServer\\IEDriverServer.exe");
    System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
    driver = new InternetExplorerDriver();
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}

博客提供了一些硒junit教程。您也可以使用google.com搜索許多教程:D

確保設置IE驅動程序的路徑。 在此之前,您需要從SeleniumHQ網站下載IE驅動程序。 您可以從以下鏈接下載Seleniumhq下載

System.setProperty("webdriver.ie.driver","path/chromedriver.exe");
WebDriver driver = new InternetExplorerDriver();

您必須先設置屬性。

System.setProperty("webdriver.ie.driver", "D:\\Eclipse  Workspace\\MultiBrowser\\IEDriverServer.exe");

WebDriver obj = new InternetExplorerDriver();

obj.get("http://www.google.com/");

obj.close();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM