gpt4 book ai didi

java - 如何在 Cucumber Selenium 中迭代特征文件

转载 作者:行者123 更新时间:2023-12-01 18:09:47 24 4
gpt4 key购买 nike

我想在我的应用程序中输入 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.

最佳答案

您正在使用场景大纲。您需要了解场景大纲的工作原理。基本上,场景大纲是编写几个单独场景的紧凑方式。因此,您的大纲将为示例表中的每个日期创建一个场景。这意味着您的步骤只有一个可用日期,因此无需迭代。

关于java - 如何在 Cucumber Selenium 中迭代特征文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60487981/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com