【问题标题】:UI-Grid 3.0 E2E protractor testingUI-Grid 3.0 E2E量角器测试
【发布时间】:2017-12-01 01:27:53
【问题描述】:

我正在尝试在我的 E2E 测试中执行选择行,以便在选择行时查看我的一个按钮是否工作。我的测试进入页面,但是当我尝试 selectRow 时,它给了我一个错误。目前的测试是这样的。

var GridTestUtils = require('./gridTestUtils.spec.js');

describe('Tests', function() {
    it('should switch to clients and add a client', function() {
        expect(element(by.id('table')).isPresent()).toBe(true);
        expect(element(by.id('sideNavLink')).getAttribute('class')).toEqual('active');
        GridTestUtils.expectRowCount('table', 2);
        element(by.id('addSubNavLink')).click();
        expect(element(by.model('modalData.name')).isPresent()).toBe(true);
        element(by.model('modalData.name')).sendKeys('Protractor Test Client');
        element(by.id('clientSubmit')).click();
        //GridTestUtils.expectRowCount('table', 3);
        GridTestUtils.selectRow('table', 3);
        element(by.id('deleteButton')).click();
    });
});

当我运行量角器时出现此错误:

Message:
 NoSuchElementError: No element found using locator: by.repeater((rowRenderIndex, row) in rowContainer.renderedRows track by $index").row("3")"

如果还有另一种突出显示行的方法,我还没有找到,但我一直在浏览 gridTestUtils.spec.js,这是我找到的第一个。

【问题讨论】:

    标签: protractor angular-ui-grid


    【解决方案1】:

    网格行和列使用从零开始的索引。

    这没有直接记录,但是当您将错误与gridTestUtils.spec.js 中的实现进行比较时很明显,行参数被传递给repeater.row() 定位器,根据示例该定位器为零。

    所以如果你的网格有 3 行

    GridTestUtils.expectRowCount('table', 3);

    你可以选择最后一行

    GridTestUtils.selectRow('table', 2);

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多