java如何在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.
# 1 楼答案
您正在使用场景大纲。您需要了解场景大纲是如何工作的。基本上,场景大纲是编写多个单独场景的一种紧凑方式。因此,您的大纲将为示例表中的每个日期创建一个场景。这意味着您的步骤将只有一个可用日期,因此没有任何内容可重复