selenium - 这是 Cucumber 中 table.raw 的当前方法
问题描述
IDEA 不允许我使用 table.raw();
我是黄瓜新手,所以在学习/练习时,我尝试通过以下代码从 DataTable 获取数据
public void iEnterTheFollowingForLogin(DataTable table) {
List<List<String>> data = table.raw();
System.out.println("The value is : "+ data.get(1).get(0).toString());
System.out.println("The value is : "+ data.get(1).get(1).toString());
}
我意识到 IDEA 将原始方法输入为红色,所以我认为它可能已经过时,现在我应该使用更新的方法。
解决方案
只是想详细解释 MP 的答案以便其他人容易理解 - 是的,您将无法再使用 raw() 方法,因为黄瓜 api 不支持具有较新版本的黄瓜,即 io.cucumber。但是,仍然可以将它与旧的 info.cukes 依赖项一起使用。
因此,MP 回答了 raw() 的替代方案。
例如-假设您有以下-样品小黄瓜步骤:
Then I should see following sections in my app detail page
|Basic Details|Bank Details|Reconciliation|Summarised Options|Currency Code|
>> The Cucumber step definition for above step should be like belwo-
@Then("I should see following sections in my app detail page")
public void verifySectionsOnDetailPageUI(List<List<String>> dTable) {
//Create your table as below (notice- dataTable declared as- List<List<String>> in method argument above)
DataTable data= DataTable.create(dTable);
// to get number of rows from DataTable
int i=data.cells().size();
// To print entire row's column (iterate via for loop using size if u have more than one row defined in data table
System.out.println("All Cells Data: "+data.cells());
//Read cell by cell data as below, row index to be started from 1 if you have column headings provided in ur table
System.out.println(data.cell(0,0));
System.out.println(data.cell(0,1));
System.out.println(data.cell(0,2));
.....
......... so On .. to be used as per your step's objective .....
O/P:
Basic Details
Bank Details
Reconciliation
推荐阅读
- angular - 为什么我不能将 node_modules 文件上传到 GitHub 存储库?
- samsung-smart-tv - 如何编译TAL项目(SMART TV)?
- katalon-studio - 如何从表中的特定列中提取数据,然后使用循环将其分配给变量数组?
- amazon-s3 - ffmpeg h.246 在 Safari 中本地播放,但在托管在 s3 存储桶上时不播放
- javascript - D3plus最大矩形需要什么格式的多边形?
- angular - Angular 4 - 显示复杂的 Json 值
- tensorflow - 没有 NCCL 的 MirroredStrategy
- asp.net-core - 从 aspnet 核心应用程序到 cloudwatch 的详细应用程序日志
- javascript - 第三方脚本设置第一方 cookie
- sql - T-SQL WHERE NOT EXISTS - 结果不一致