我已将IE驱动程序更新为3.12.0.0并且无法正常工作。我收到以下错误消息
代码:
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
System.setProperty("webdriver.ie.driver", "C:\\iedriver\\IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver(cap);
driver.manage().window().maximize();
driver.manage().deleteAllCookies();
来自控制台的错误消息
Unable to create new remote session. desired capabilities = Capabilities [{ie.ensureCleanSession=true}], required capabilities = Capabilities [{}]
答案 0 :(得分:0)
你快到了。您需要使用merge()
类中的方法MutableCapabilities方法将 DesiredCapabilities 类型的对象合并到 InternetExplorerOptions 类型对象中并启动 WebDriver 和 WebClient 实例通过传递 InternetExplorerOptions 对象,如下所示:
System.setProperty("webdriver.ie.driver", "C:\\iedriver\\IEDriverServer.exe");
DesiredCapabilities cap = DesiredCapabilities.internetExplorer();
cap.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
InternetExplorerOptions options = new InternetExplorerOptions()
options.merge(cap);
WebDriver driver = new InternetExplorerDriver(options);
PS:作为参考,您可以查看mutablecapabilities
代码