首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何使用TestCafe与ag-Grid进行交互

如何使用TestCafe与ag-Grid进行交互
EN

Stack Overflow用户
提问于 2020-09-09 01:41:12
回答 1查看 331关注 0票数 1

我想在没有任何框架的情况下使用TestCafe与ag-Grid数据进行交互,有什么方法吗?

任何帮助都将不胜感激。

提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2020-09-09 15:42:44

我检查了the ag-Grid demo page,它在TestCafe上工作正常:

代码语言:javascript
运行
复制
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();
});

更新

我想点击属于英语的名字

代码语言:javascript
运行
复制
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();
});
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63799051

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档