我在Win10(17134.471)计算机上使用VS2017,并且我刚刚安装了Selenium。我可以使Chrome,Firefox,Edge正常运行,但不能使IE11(11.471.171340)正常运行。我相信我已经完成了所有其他建议的更新,但是继续得到:
There are no more files.
我需要使用NuGet安装哪些版本尚不清楚,其版本为:
Selenium.Webdriver.MicrosoftDriver v17.17134.0
测试名称:IeMethod 测试全名:utLearn2018.FirstTestClass.IeMethod 测试源:C:\ Users \ stephan \ Documents \ Visual Studio 2017 \ Projects \ utLearn2018 \ utLearn2018 \ FirstTestClass.cs:第44行 测试结果:失败 测试时间:0:00:22.3336919
结果StackTrace:
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at OpenQA.Selenium.IE.InternetExplorerDriver..ctor(InternetExplorerDriverService service, InternetExplorerOptions options)
at OpenQA.Selenium.IE.InternetExplorerDriver..ctor()
at utLearn2018.FirstTestClass.IeMethod() in C:\Users\stephan\Documents\Visual Studio 2017\Projects\utLearn2018\utLearn2018\FirstTestClass.cs:line 53
结果消息:
Test method utLearn2018.FirstTestClass.IeMethod threw exception:
System.InvalidOperationException: Unexpected error launching Internet Explorer. IELaunchURL() returned HRESULT 80070012 ('There are no more files.') for URL 'http://localhost:50326/' (SessionNotCreated)
我的代码如下:
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Edge;
using OpenQA.Selenium.IE;
[TestMethod]
public void IeMethod()
{
InternetExplorerOptions options = new InternetExplorerOptions
{
IntroduceInstabilityByIgnoringProtectedModeSettings = true,
EnableNativeEvents = false,
EnsureCleanSession = true
};
IWebDriver driver = new InternetExplorerDriver();
driver.Navigate().GoToUrl("http://www.google.com");
driver.Manage().Window.Maximize();
driver.Close();
driver.Quit();
}
答案 0 :(得分:0)
某些版本的IE驱动程序和Selenium Webdriver不兼容。值得尝试使用不同版本的IE驱动程序和Selenium Webdriver来启动IE浏览器。