我有一个场景,其中在步骤定义文件中随机生成一个策略编号,该策略编号需要显示在报告中(我使用protractor-multiple-cucumber-html-reporter-plugin进行报告)。由于报告正在从功能文件中的Examples关键字读取数据,因此我需要将在步骤定义文件中生成的策略编号返回到功能文件
示例: policyNumber | |
我在步骤定义文件中的代码
否则if(string2 ==“策略号”){ await browser.wait(waitCondition.visibilityOf(applicationDataEntryPagePE.policyNumberTextBox),2000).then(async(textboxVisible)=> { policyNumber =等待字符串+ timestamp.getHours()+ timestamp.getMinutes()+ timestamp.getMilliseconds(); 等待applicationDataEntryPagePE.policyNumberTextBox.sendKeys(policyNumber); 等待console.log(“在“策略号”字段中输入值” + policyNumber +“); 返回policyNumber; }) }
我需要将policyNumber返回到功能文件中的“示例”值
答案 0 :(得分:0)
这是简单的解决方案。
将policy number
添加到全局变量,然后直接在step_def中使用它(简单方法)。这也会在结果中显示策略编号。