【问题标题】:How to interact with ag-Grid using TestCafe如何使用 TestCafe 与 ag-Grid 进行交互
【发布时间】:2020-09-08 17:41:11
【问题描述】:

我想使用 TestCafe 与 ag-Grid 数据进行交互,没有任何框架,如 Mocha、Jasmine 等,有什么办法吗?

任何帮助将不胜感激。

提前致谢。

【问题讨论】:

    标签: testing automated-tests ag-grid e2e-testing testcafe


    【解决方案1】:

    我检查了the ag-Grid demo page,它与 TestCafe 一起正常工作:

    import { Selector } from 'testcafe';
    
    fixture `Fixture`
        .page `https://www.ag-grid.com/example.php`;
    
    test('test', async t => {
        const filterInput       = Selector('#myGrid > div > div.ag-root-wrapper-body.ag-layout-normal.ag-focus-managed > div.ag-root.ag-unselectable.ag-layout-normal > div.ag-header.ag-focus-managed.ag-pivot-off > div.ag-header-viewport > div > div.ag-header-row.ag-header-row-floating-filter > div:nth-child(1) > div.ag-floating-filter-body > div > input');
        const selectAllCheckbox = Selector('#ag-input-id-63');
    
        const cellTonySmith     = Selector('#myGrid').find('span').withText('Tony Smith');
        const checkboxTonySmith = cellTonySmith.parent().child(1);
    
        const cellTonyGunner     = Selector('#myGrid').find('span').withText('Tony Gunner');
        const checkboxTonyGunner = cellTonyGunner.parent().child(1);
    
        await t
            .typeText(filterInput, 'Tony')
            .hover(cellTonySmith)
            .click(checkboxTonySmith)
            .hover(cellTonyGunner)
            .click(checkboxTonyGunner);
    
        await t
            .debug();
    });
    
    
    

    UPD:

    我想点击属于英文的名字

    import { Selector } from 'testcafe';
    
    fixture `Fixture`
        .page `https://www.ag-grid.com/example.php`;
    
    test('test', async t => {
        const englishCells = Selector('div').withAttribute('col-id', 'language').withText('English');
    
        const firstEnglishCell              = englishCells.nth(0);
        const nameRelatedToFirstEnglishCell = firstEnglishCell.parent().child(0).child(0).child(-1);
    
        const secondEnglishCell              = englishCells.nth(1);
        const nameRelatedToSecondEnglishCell = secondEnglishCell.parent().child(0).child(0).child(-1);
    
        await t
            .click(nameRelatedToFirstEnglishCell)
            .click(nameRelatedToSecondEnglishCell)
            .debug();
    });
    
    

    【讨论】:

    • 谢谢您的回复。我想处理 ag-grid 中特定列的值,例如我想单击属于英语的名称,您能否建议在这种情况下如何遍历 ag-grid?谢谢
    猜你喜欢
    • 2018-09-21
    • 1970-01-01
    • 2019-03-02
    • 2021-01-08
    • 2021-01-30
    • 1970-01-01
    • 2020-08-19
    • 1970-01-01
    • 2016-11-26
    相关资源
    最近更新 更多