我在尝试即时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
,如下所示:
它永远不会最终进入谷歌,因为我已将其编码为。
大约十秒钟后,我在控制台中得到了这个堆栈跟踪:
(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
导致这种情况的原因是什么?
答案 0 :(得分:2)
这里存在问题:
System.setProperty("webdriver.ie.driver", "C:\\Program Files\\Internet Explorer\\iexplore.exe");
此属性是 IEDriver ,不是 IE本身的位置:
https://code.google.com/p/selenium/wiki/InternetExplorerDriver
下载IED驱动程序,将其放置在合理的位置,然后 位于该属性中。