你好,当我使用以下代码时
IWebDriver _webDriver = new RemoteWebDriver(new Uri("http://127.0.0.1:4444/wd/hub"),
DesiredCapabilities.Chrome());
我收到以下错误
System.InvalidOperationException :驱动程序可执行文件的路径必须由 webdriver.chrome.driver 系统属性设置;有关更多信息,请参阅http://code.google.com/p/selenium/wiki/ChromeDriver。最新版本可以从以下位置下载http://code.google.com/p/chromedriver/downloads/listTearDown:System.NullReferenceException:未将对象引用设置为对象的实例。
在 OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(响应 errorResponse)
在 OpenQA.Selenium.Remote.RemoteWebDriver.Execute(字符串 driverCommandToExecute,字典`2 参数)
在 OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor 命令Executor,ICapability 所需功能)
在 Browser.cs 中的 Testframework.Browser.RemoteGoto(String browser, String url) 处:第 86 行
在 CommonAction.cs 中的 Testframework.CommonAction.RemoteBrowser(String browser) 处:第 70 行
在RegistrationTest.cs中的Test.RegistrationTest.InvalidRegistrationTest(字符串浏览器,字符串用户名,字符串密码,字符串confirmPassword,字符串securityQuestion,字符串securityAnswer,字符串errorMessageText,字符串字符串名字,字符串姓氏):第50行
- 拆除
在 CommonAction.cs 中的 Testframework.CommonAction.CaptureScreen(String fileName) 处:第 121 行
在 RegistrationTest.cs 中的 Test.RegistrationTest.SnapshotOnFailure() 处:第 590 行
线索确实就在错误中。
Chrome 应安装在运行测试或指向测试的系统上。
退一步,看看文档:
https://code.google.com/p/selenium/wiki/ChromeDriver
此外,如果 Chrome 安装在特殊位置,您需要将 Selenium 指向它的位置。同样,文档中对此进行了解释。
In C#:
DesiredCapabilities capabilities = DesiredCapabilities.Chrome();
capabilities.SetCapability("chrome.binary", this.binaryLocation);
or:
ChromeOptions options = new ChromeOptions();
options.BinaryLocation = "pathtogooglechrome";
capabilities.SetCapability(ChromeOptions.Capability, options);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)