假设我有一个测试用例,如-
Scenario: Scenario to verify Title Matched
When Navigate to the App "Facebook"
Then verify the "TitleName" Field
如何从与“当导航到应用程序Facebook时”和“然后验证“ TitleName”字段”相对应的步骤定义方法中获得方案名称。>
步骤定义方法是-
:我正在使用带打字稿的cypres黄瓜When('Navigate to the App {string} for demo',(AppURL:string)=>{ if(AppURL=="FaceBook"){ } }); Then('verify the Title of the page for demo',()=> { SampleAPPUI.verfiyTitledemo(''); });
注意
[假设我有一个测试用例,例如-场景:导航到应用程序“ Facebook”时验证标题匹配的场景,然后验证“ TitleName”字段如何从...中获取场景名称?]
我正在Java-Selenium-Gherkin测试套件中进行此操作。它可能不是您需要的解决方案,但是它将为您提供有关如何获取值的指导:
@BeforeStep
public void doSomethingBeforeStep(Scenario scenario) throws Exception {
testScenario = scenario.getName().toString();
scenarioObj = scenario;
Field f = scenario.getClass().getDeclaredField("testCase");
f.setAccessible(true);
TestCase r = (TestCase) f.get(scenario);
List<PickleStepTestStep> stepDefs = r.getTestSteps()
.stream()
.filter(x -> x instanceof PickleStepTestStep)
.map(x -> (PickleStepTestStep) x)
.collect(Collectors.toList());
PickleStepTestStep currentStepDef = stepDefs.get(currentStepIndex);
testCase = currentStepDef.getStepText();
}