【发布时间】:2016-02-04 20:02:38
【问题描述】:
我正在为一个名为 CodeSpec 的框架做出贡献,它建立在 SpecFlow 之上。
使用ScenarioContext 我可以获得当前正在执行的场景的标题。但我也想获得步骤定义。
说场景是
Scenario: Google for Cats
Given I navigate to "http://google.com"
And I enter value "Cats" to the "searchBox" with the "id" of "lst-ib"
And I click on element "searchButton" with the "xpath" of "id('sblsbb')/button" and wait "4" seconds
Then The page contains text pattern "The domestic cat is"
我可以用下面的代码得到标题,
[AfterScenario("UIAutomationReport")]
public static void AfterScenario()
{
var title = ScenarioContext.Current.ScenarioInfo.Title;
//title now is "Google for Cats"
}
我也想获得步骤定义
Given I navigate to "http://google.com"、And I enter value "Cats" to the "searchBox" with the "id" of "lst-ib"等
我该怎么做?
【问题讨论】: