gpt4 book ai didi

testing - 用 TestCafe 点击 child

转载 作者:行者123 更新时间:2023-11-28 20:10:48 24 4
gpt4 key购买 nike

我需要一个关于点击 testCafe 的非常简单的帮助。

我有一个简单的元素,里面有 10 个

  • 。我必须单击第一个或最后一个或从索引 0 到索引 10 的随机 li。

    我该怎么做?

  • 最佳答案

    使用 nth(index)通过索引选择元素的方法:

    function getRandomInt(min, max) {
    return Math.floor(Math.random() * (max - min + 1)) + min;
    }

    const ul = Selector('ul');
    const li = ul.find('li');

    const liCount = await li.count;
    const index = getRandomInt(0, liCount);

    await t.click(li.nth(index));

    关于testing - 用 TestCafe 点击 child ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48228282/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com