类型错误:table.rows不是一个函数--当从protractor中的特征文件中访问实例时。

问题描述 投票:0回答:1

我使用的是 量角器-黄瓜-框架。

以下是功能文件

Feature: welcome to protractor cucumber

    Scenario Outline: DataTable
        Given I am learning
        Then I print following table

        Examples:
            | First | Middle |
            | qwerty   | xyz  | 

在步骤定义文件中,我想打印表格数据。

    Given(/^I am learning$/, async () => {
        console.log("I am learning");   
    });

    Then(/^I print following table$/, (table: TableDefinition) => {
        const tableData = table.rows();
        console.log(tableData[0][0]);

      });

但得到以下错误信息

TypeError: table.rows is not a function
    at World.(anonymous) (/.../Protr_cucumber/stepDef/Sample_stepDef.ts:9:29)
typescript protractor cucumberjs
1个回答
0
投票

你把情景大纲和数据表搞混了。

场景大纲是在你想执行一个有多个测试数据的场景时使用的。

数据表有助于将多个测试数据传递给场景中的一个步骤。hashesrows.

你可以找到文档 此处 和例子 此处.

关于黄瓜的更详细的文件可以在以下网站找到 此处.

© www.soinside.com 2019 - 2024. All rights reserved.