gpt4 book ai didi

java - 如何在 Selenium 中使用 IEDriver?

转载 作者:行者123 更新时间:2023-11-29 04:33:42 25 4
gpt4 key购买 nike

我一直在尝试使用 selenium 并尝试运行 Internet Explorer 11,但出现以下错误。

Started InternetExplorerDriver server (32-bit) 
3.1.0.0
Listening on port 25172
Only local connections are allowed
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl. java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.pccw.bpss.qa.automation.Application.execute_Actions(Application.java:79)
at com.pccw.bpss.qa.automation.Application.executeTestCase(Application.java:71)
at com.pccw.bpss.qa.automation.Application.main(Application.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: org.openqa.selenium.SessionNotCreatedException: Unable to
create new remote session. desired capabilities = Capabilities
[{ie.ensureCleanSession=true}], required capabilities = Capabilities [{}]
Build info: version: '3.1.0', revision: 'b94c902', time: '2017-02-16
12:21:31 -0800'
System info: host: 'PC81013161', ip: '10.37.210.32', os.name: 'Windows
10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_92'
Driver info: driver.version: InternetExplorerDriver at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:91)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:227)
at org.openqa.selenium.ie.InternetExplorerDriver.run(InternetExplorerDriver.java:182)
at org.openqa.selenium.ie.InternetExplorerDriver.<init> (InternetExplorerDriver.java:174)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:150)
at com.pccw.bpss.qa.automation.execution.ActionKeywords.openBrowser(ActionKeywords.java:45)
... 12 more

我试过它运行 Firefox 并且运行良好。我也试过修改 IE 的安全功能,但我仍然遇到同样的错误。

下面是发生错误的代码片段。该错误发生在 InternetExplorerDriver() 初始化时

 System.setProperty(KEY_IE_DRIVE, FILE_PATH_DRIVER_IE_X32_EXE);
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
driver = new InternetExplorerDriver(cap);
driver.manage().window().maximize();

最佳答案

看看以下内容是否有帮助:

  1. 转到 Internet 选项
  2. 安全
  3. 点击:“将所有区域重置为默认级别”
  4. 为所有区域勾选“启用保护模式”复选框

关于java - 如何在 Selenium 中使用 IEDriver?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42661646/

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