gpt4 book ai didi

java - InternetExplorerDriver 实例化时出现奇怪的错误

转载 作者:行者123 更新时间:2023-12-02 06:03:23 28 4
gpt4 key购买 nike

我在尝试即时 InternetExplorerDriver 时遇到奇怪的错误。我编写了以下代码:

public static void main(String[] args) {
System.setProperty("webdriver.ie.driver", "C:\\Program Files\\Internet Explorer\\iexplore.exe");
WebDriver driver = new InternetExplorerDriver();
driver.get("http://www.google.com");
}

Internet Explorer 出现,设置为 http://--port=26290,如下所示:

Internet Explorer behaving strangely

它永远不会像我编码的那样最终进入谷歌。

大约十秒后,我在控制台中看到了这个堆栈跟踪:
(TestBase.main(TestBase.java:358) 是我实例化驱动程序的行。)

    Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.40.0', revision: '4c5c0568b004f67810ee41c459549aa4b09c651e', time: '2014-02-19 11:13:01'
System info: host: 'LT10387', ip: '192.168.0.82', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_45'
Driver info: driver.version: InternetExplorerDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:567)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:218)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:203)
at org.openqa.selenium.ie.InternetExplorerDriver.run(InternetExplorerDriver.java:193)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:183)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:154)
at com.gdit.fwa.informant.webui.base.selenium.TestBase.main(TestBase.java:358)
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '2.40.0', revision: '4c5c0568b004f67810ee41c459549aa4b09c651e', time: '2014-02-19 11:13:01'
System info: host: 'LT10387', ip: '192.168.0.82', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_45'
Driver info: driver.version: InternetExplorerDriver
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:165)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:62)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:546)
... 6 more
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:26290/status] to be available after 20002 ms
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:104)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:163)
... 8 more
Caused by: com.google.common.util.concurrent.UncheckedTimeoutException: java.util.concurrent.TimeoutException
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:143)
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:79)
... 9 more
Caused by: java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask.get(FutureTask.java:201)
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:130)
... 10 more

这可能是什么原因造成的?

最佳答案

问题存在于此:

System.setProperty("webdriver.ie.driver", "C:\\Program Files\\Internet Explorer\\iexplore.exe");

此属性是 IEDriver 的位置,不是 IE 本身的位置:

https://code.google.com/p/selenium/wiki/InternetExplorerDriver

下载 IEDriver,将其放置在合理的位置,并将该位置放置在该属性中。

关于java - InternetExplorerDriver 实例化时出现奇怪的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22485749/

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