帮助 - 我是Selenium Webdriver的新手。我已经在VS 2015上安装了selenium weddriver。
当我尝试并运行时
IWebDriver driver = new FirefoxDriver();
我总是得到一个
system.collections.generic.KeyNotFoundException“在字典中找不到密钥”。
我知道我需要一个webdriver.json文件,这是我的:
{
"capabilities":
[
{
"browserName": "firefox",
"version": "48.0.2",
"platform": "WINDOWS",
"maxInstances": 1
},
{
"browserName": "internet explorer",
"version": "11",
"platform": "WINDOWS",
"maxInstances": 1
}
],
"configuration":
{
"nodeTimeout":120,
"port":5555,
"hubPort":4444,
"hubHost":"localhost",
"nodePolling":2000,
"registerCycle":10000,
"register":true,
"cleanUpCycle":2000,
"timeout":30000,
"maxSession":1,
}
}
我有两个主要问题: 1)我不知道缺少哪个密钥 2)我试图在没有运气的情况下搜索这个json文件的文档和示例。
我的Selenium安装,参考和使用声明似乎都符合安装说明。
Result StackTrace:
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at OpenQA.Selenium.Firefox.FirefoxProfile.ReadDefaultPreferences()
at OpenQA.Selenium.Firefox.FirefoxProfile..ctor(String profileDirectory, Boolean deleteSourceOnClean)
at OpenQA.Selenium.Firefox.FirefoxDriver.CreateExtensionConnection(FirefoxBinary binary, FirefoxProfile profile, TimeSpan commandTimeout)
at OpenQA.Selenium.Firefox.FirefoxDriver..ctor(FirefoxBinary binary, FirefoxProfile profile)
at WebTest.BasicCalculatorSteps.GivenThatTheSimpleCalulatorIsOpen() in C:\Users\Patrick\Documents\Visual Studio 2015\Projects\hf_regulator_emulator_BDD\WebTest\BasicCalculatorSteps.cs:line 18
at TechTalk.SpecFlow.Bindings.BindingInvoker.InvokeBinding(IBinding binding, IContextManager contextManager, Object[] arguments, ITestTracer testTracer, TimeSpan& duration)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStepMatch(BindingMatch match, Object[] arguments)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStep(StepInstance stepInstance)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnAfterLastStep()
at WebTest.BasicCalculatorFeature.ScenarioCleanup()
at WebTest.BasicCalculatorFeature.ShowThatAdditionWorks_() in C:\Users\Patrick\Documents\Visual Studio 2015\Projects\hf_regulator_emulator_BDD\WebTest\BasicCalculator.feature:line 15
Result Message: System.Collections.Generic.KeyNotFoundException : The given key was not present in the dictionary.