【问题标题】:TestCafe visibilityCheck does not wait for element to appearTestCafe visibilityCheck 不等待元素出现
【发布时间】:2020-07-12 22:17:55
【问题描述】:

我试图让 TestCafe 等待一个元素出现在 dom 中。目前我正在使用 { visibilityCheck: true } 但它似乎没有做任何事情,测试将超时并被视为失败。

目标:

  1. 转到页面
  2. 等待 searchIconElement 加载

代码:

fixture`Library /all`.page(page.libraryScreen).beforeEach(async t => {
  await t.useRole(page.adminUser);
});

test('Search Bar', async t => {
  const searchIcon = Selector('div').withAttribute('class', 'CampaignsPage-fab1');
  const searchIconElement = searchIcon.with({ visibilityCheck: true })();
  const microAppNameInput = Selector('input').withAttribute('placeholder', 'Search');
  const microAppTitle = Selector('div').withAttribute('class', 'SetCard-title ').innerText;
  
  await t
    .click(searchIconElement)
    .typeText(microAppNameInput, testMicroAppTitle)
    .expect(microAppTitle)
    .eql(testMicroAppTitle);
});

【问题讨论】:

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


    【解决方案1】:

    When a selector is passed to a test action as the target element's identifier, the target element should be visible regardless of the visibilityCheck option.如果目标元素变得可见太晚,可以尝试增加选择器timeout

    【讨论】:

      【解决方案2】:

      尝试添加超时

      const searchIconElement = searchIcon.with({ visibilityCheck: true }).with({ timeout: 10000 });
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-05-09
        • 2013-01-12
        • 1970-01-01
        • 1970-01-01
        • 2019-03-16
        • 2021-01-21
        • 2020-03-29
        相关资源
        最近更新 更多