java - 如何在黄瓜硒中迭代特征文件
问题描述
我想在我的应用程序中输入 5 个不同的日期。为此,我将这些日期存储在功能文件中。我想一一迭代所有日期
Feature File:
Scenario Outline: To test feature file iteration
Given User is on login Screen
When user enters credentials "<User_ID>" and "<Password>"
Then user enters "<processing_date>"
And clicks on logout
Examples:
| User_ID | Password |processing_date|
| Abc | Abc. |28/11/2018|
| Abc. | Abc. |03/12/2018|
Method for entering date:
public void date(DataTable date) throws Exception {
List<List<String>> data = processing_date.asList(String.class);//I had to use asList as .raw was not available)
System.out.println("Size is :" +data.size() );
for(int i=1;i<data.size();i++)
{
Thread.sleep(3000);
String scriptText = "document.querySelector('.datafield').setAttribute('value','" + date.get(i).get(i)+ "')";
((JavascriptExecutor)driver).executeScript(scriptText);
log.info("date is entered");
}
But this is not working.Is there any method to iterate feature files.Getting error as Argument mismatch.If i change DataTable date to String date and remove for loop , it works fine.But every time it login and logouts.But i want to execute all 5 dates one after the other without logging out.
解决方案
您正在使用场景大纲。您需要了解场景大纲的工作原理。基本上,场景大纲是编写几个单独场景的紧凑方式。因此,您的大纲将为示例表中的每个日期创建一个场景。这意味着您的步骤将只有一个可用的日期,因此无需迭代。
推荐阅读
- javascript - 使用 AJAX 的 HTML 表更新未呈现
- python - 如何在二维列表的项目中追加?
- javascript - 为什么 Object.assign() 拆分字符串并创建具有多个键的对象?
- mysql - 为什么Mysql决定在Order By子句中指定的列上使用索引而不存在于where子句中?
- php - 包含php文件的正确方法是什么
- azure - 带有错误代码的天蓝色实体框架问题未知错误:0x80070057
- javascript - 是否可以在 PostgreSQL 中使用 knex 返回()方法来返回操作表中的所有行
- javascript - Google Tracking function(i,s,o,g,r,a,m) 代码是如何工作的?
- java - 如何从多个单选组传递单选按钮值?如何解决返回第一个值?
- pandas - 使用 groupby.tail 后如何创建数据框