如何在测试执行期间仅针对此特定测试覆盖 .testcaferc.json 选择器断言参数

问题描述 投票:0回答:1

您好,我遇到了一个小问题,我需要覆盖来自 .testcaferc.json 文件的默认选择器超时,该文件具有一些如下所示的属性 =>

"selectorTimeout": 20000,
"pageLoadTimeout": 30000,
"assertionTimeout": 20000,

现在,在测试执行过程中,为了精确进行可见性检查,即使元素在我的 DOM 中不可用,它也会等待 20 秒(我还通过将选择器超时和断言超时从 .testcaferc.json 调整到 5000 进行了检查,似乎工作正常) 。为什么我不能在测试执行期间覆盖这些超时属性,如下所示 =>

  await t.expect(await myTestPanel.saveButton.selector.visible).notOk('',  {timeout: 5000});

我当前使用的 testcafe 版本是“testcafe”:“2.5.0”和“testcafe-angular-selectors”:“0.4.1”。非常感谢任何形式的帮助。谢谢

testing automation selector testcafe
1个回答
0
投票

对于某个选择器,您可以使用方法

with
和选项
timeout
。例如:

const headerSelector = Selector('#article-header');

await t.expect(headerSelector.with({ timeout: 100 }).innerText).eql('Thank you, John Smith!');
© www.soinside.com 2019 - 2024. All rights reserved.