Selenium Webdriver错误:已添加具有相同密钥的项目

时间:2017-11-16 23:56:27

标签: c# selenium selenium-webdriver webdriver

有人可以建议我如何防止此错误:"已经添加了具有相同密钥的项目。"?

我有两个单独运行时运行良好的测试,但是当我"运行全部"在visual studio中,我收到了这个错误。

[Binding]
public sealed class Steps
{
    private Squish squish = new Squish();
    private Tools tools = new Tools();

    [Given(@"I navigated to the Squish homepage")]
    public void GivenINavigatedToTheSquishHomepage()
    {
        squish.NavigateToURL("Squish.com");
        ScenarioContext.Current["siteTitle"] = squish.GetPageTitle();
    }

FeatureContext.Current.Add(键,值)还有其他选择吗?所以我不必直接存储任何东西?

1 个答案:

答案 0 :(得分:1)

我想您应该阅读有关并行测试运行的specflow文档http://specflow.org/documentation/Parallel-Execution/ 它说:

  

您可能没有使用静态上下文属性   ScenarioContext.Current,FeatureContext.Current或   ScenarioStepContext.Current。

实际上您的错误是自我描述性的 - 您已使用键" siteTitle"

在字典中创建了项目