TestCafe可见性检查不等待元素出现 [英] TestCafe visibilityCheck does not wait for element to appear

查看:98
本文介绍了TestCafe可见性检查不等待元素出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让TestCafe等待元素出现在dom中.目前,我正在使用{visibleCheck:true},但是它似乎什么也没做,因此测试将超时并被视为失败.

I am trying to get TestCafe to wait for an element to appear in the dom. Currently I am using { visibilityCheck: true } but it does not seem to do anything and the test will time out and be considered a failure.

目标:

  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);
});

推荐答案

尝试添加超时时间

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

这篇关于TestCafe可见性检查不等待元素出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆