【发布时间】:2021-07-08 19:06:03
【问题描述】:
我是 SpecFlow 的新手,并且正在使用 POC,因此我可以在我的项目中使用 VisualStudio+SpecFlow+Selenium 组合。我创建了一个功能文件并添加了两个场景。第一个用于登录,第二个用于页面创建。因此,我将使用一个用户登录并在同一会话中创建一个页面。我使用 SpecFlow 从功能文件生成了步骤定义文件。以下是我的 Feature 文件内容:
Feature: Login and create page configuration page
This feature will test the login and the page configuration page creation functionality:
@Login
Scenario Outline: Login into Minerva Cloud
Given User open up the "<URL>"
When User login using "<UserName>" and "<Password>"
Then User successfully logged into the Minerva Cloud
And User selects the "<ClientName>"
Examples:
|URL|UserName|Password|ClientName|
|https://####|####|####|## Global Services|
@PageConfigurationPageCreation
Scenario Outline: New Page Configuration page creation
Given User click on the new button
When User enters details like "<Name>" "<Type>" "<CRMtype>" "<URL>" "<Description>" "<AccessGroup>" in the creation page
And click on the Save button
Then the new page is created
Examples:
|Name|Type|CRMtype|URL|Description|AccessGroup|
|PageConfiguration_Sunil1|CRM|Vertex|URL|Description for my Page|Access Group to be selected|
附上生成的step文件sn-p:
Code Generated by SpecFlow and i added the required Selenium code
因此,每当我运行功能文件时,它都会毫无问题地执行登录场景,但一旦到达属于第二个场景的第二个 Given 语句(在所附图像中标记为红色),它就会失败并引发错误。错误是:
System.NullReferenceException : 对象引用未设置为对象的实例。
看起来它以某种方式丢失了我在第一个场景中初始化的 Webdriver 的当前实例。
请帮忙!
【问题讨论】:
-
请勿发布代码图片。在您的问题中包含编码为纯文本。
-
这能回答你的问题吗? Using ChromeDriver across SpecFlow Tests
-
当然,以后会处理的。不,我还没有找到任何答案。
标签: c# visual-studio selenium specflow