【问题标题】:I am trying to find an element within a <frame> using testcafe but i am unable to do so. is there a method to get this done please?我正在尝试使用 testcafe 在 <frame> 中找到一个元素,但我无法这样做。请问有没有办法做到这一点?
【发布时间】:2020-08-16 09:28:46
【问题描述】:

我尝试了以下方法:

t.switchTo("frameID");
var ele = Selector("#ele");
await t.click(ele);

又一次尝试:

Selector(() =>{return document.getElementById("frameId").contentDocument.getElementById("#ele")});

这会引发以下错误:选择器的函数应返回 DomElement、NodeList、HtmlCollection、NULL 或未定义。

HTML DOM 如下:

<html>
<body>
<frameset>
<frame id='frame1'>
#document
<html>
<body>
<p id='ele1'>Hello World</p>
</body>
</html>
</frame>
</frameset>
</body>
</html>

【问题讨论】:

  • 能否分享您要测试的页面的 HTML DOM?
  • 嗨 Rahul,我已经编辑了我的问题以包含页面的 HTML DOM。
  • 我希望你使用 t.switchTo("frame1") 而不是 t.switchTo("frameID") 因为 frame id 的实际值是 frame1。除此之外,我看不到任何其他错误。

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


【解决方案1】:

frameframeset 功能在 W3C 建议中标记为 obsolete。由于TestCafe 基于不支持frameset 的HTML5 标准,因此TestCafe 也不支持frameset。因此,我们希望专注于最新功能,这将为测试现代 Web 应用程序提供最佳体验。

至于你分享的例子,可以用这个测试:

test('test', async t => {
    await t.click('#ele1');
})

【讨论】:

    猜你喜欢
    • 2011-10-04
    • 2021-07-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-16
    • 1970-01-01
    相关资源
    最近更新 更多