【问题标题】:testcafe await t.expect with timeout is flakytestcafe await t.expect 超时是不稳定的
【发布时间】:2020-05-05 08:46:12
【问题描述】:

我有一个场景,我等待元素不出现,一旦发生,我执行点击操作。 实际发生的情况是点击发生了,尽管对带有超时选项的元素的期望没有验证

await t.expect(StatusOnProgressIcon.exists).notOk('Unexistence of On progress status icon', { timeout: 120000 })
await t.click(someTab)

我希望只有在第一行被断言为肯定之后才会执行第二行

【问题讨论】:

    标签: testing automation automated-tests e2e-testing testcafe


    【解决方案1】:

    我尝试复制这种行为没有成功。 Smart Wait Mechanism for Assertions 正确等待,直到断言的实际值与预期值匹配:

    这是我的示例测试用例。

    61609192.html

    <!DOCTYPE html>
    <head>
    </head>
    <body>
    <p id="icon">Status Icon</p>
    <button id="button" type="button">Add to cart</button>
    </body>
    <script>
    
    setTimeout(() => {
        document.getElementById("icon").remove();
    }, 8000);
    
    </script>
    </html>
    

    61609192.js

    import { Selector} from 'testcafe';
    
    fixture('fixture')
        .page('./61609192.html');
    
    test('test', async t => {
    
        const icon = Selector("#icon");
        const button = Selector("button");
    
        await t.expect(icon.exists).notOk('Icon does not exist', { timeout: 120000 })
        await t.click(button)
    
    });
    

    请更新我的测试用例以说明问题或提供您自己的测试用例,以便我们可以看到问题的实际效果。

    【讨论】:

      【解决方案2】:

      试试

      await t.expect(await StatusOnProgressIcon.exists).notOk('Unexistence of On progress status icon', { timeout: 120000 })
      

      【讨论】:

        猜你喜欢
        • 2021-10-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-01-27
        • 1970-01-01
        • 2017-06-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多