Selenium webdriver 上下文菜单中缺少Specflow生成步骤定义
我在要素文件上单击鼠标右键,应该可以获得生成步骤定义的选项。它不在上下文菜单中。 我做了一个搜索,它说要为nunit安装specrun。 我尝试从Manage NuGet软件包安装SpecRun.Nunit 我得到一个错误:Selenium webdriver 上下文菜单中缺少Specflow生成步骤定义,selenium-webdriver,visual-studio-2013,specflow,Selenium Webdriver,Visual Studio 2013,Specflow,我在要素文件上单击鼠标右键,应该可以获得生成步骤定义的选项。它不在上下文菜单中。 我做了一个搜索,它说要为nunit安装specrun。 我尝试从Manage NuGet软件包安装SpecRun.Nunit 我得到一个错误: Severity Code Description Project File Line Suppression State Error Unable to load the service index for source http:/
Severity Code Description Project File Line Suppression State
Error Unable to load the service index for source
http://packagesource.
An error occurred while sending the request.
The remote name could not be resolved: 'packagesource' 0
我已安装Visual Studio Enterprise 2017。
我已经安装了SeleniumWebDriver,Specflow
请告诉我如何解决此问题,谢谢。您需要从菜单项“工具”->“扩展和更新…”安装specflow nuget软件包以及Visual Studio集成软件包。以下是我要做的事情,以使该选项显示在VS2019的上下文菜单中
- 删除所有步骤,将主类保留为空
using System;
using TechTalk.SpecFlow;
namespace SpecflowFirst
{
[Binding]
public class SpecFlowFeature1Steps
{
}
}
using System;
using TechTalk.SpecFlow;
namespace SpecflowFirst
{
[Binding]
public class SpecFlowFeature1Steps
{
[Given(@"I navigated to the github login page")]
public void GivenINavigatedToTheGithubLoginPage()
{
ScenarioContext.Current.Pending();
}
}
}
- 然后将从对话框中获得的代码片段粘贴到主 阶级
using System;
using TechTalk.SpecFlow;
namespace SpecflowFirst
{
[Binding]
public class SpecFlowFeature1Steps
{
}
}
using System;
using TechTalk.SpecFlow;
namespace SpecflowFirst
{
[Binding]
public class SpecFlowFeature1Steps
{
[Given(@"I navigated to the github login page")]
public void GivenINavigatedToTheGithubLoginPage()
{
ScenarioContext.Current.Pending();
}
}
}
这将触发编译中的错误。如果您指向“ScenarioContext”中的错误并显示“可能的修复”,其中一个修复将是安装“Sprecflow extension”。使用此选项,您将安装剩余的集成,该集成现在将在关联菜单中显示该选项
这解决了我的问题,现在我可以在上下文菜单中看到“生成步骤定义”我遵循了Kyon的出色演练,但这对我不起作用。尽管SpecFlow安装正确,但它没有识别以下库,也没有提出任何“修复此问题”的建议: 然后我注意到,有了一个全新的MsTest项目和最新的VS2019(截至2020年10月),您需要安装稍早版本的SpecFlow(v2.1比v2.4) 因此,如果您在显示这个虚幻的“生成步骤定义”菜单项时遇到问题,请查看您的Dependencies\Packages中是否有感叹号