【问题标题】:How to get all <a> tag under the <div> in testcafe如何获取testcafe中<div>下的所有<a>标签
【发布时间】:2021-04-28 06:50:33
【问题描述】:
在选择器的 selenium 查询中,如果我的选择器值为 (#div-id a)。它返回所有标签。
在 testcafe 中是否可以使用选择器功能?我只是想避免循环获取所有标签。
代码示例
const element = selector('#div-id').find()
var get = await brandUrls.hasAttribute();
console.log(get);
附加的实际元素
【问题讨论】:
标签:
testing
automation
automated-tests
e2e-testing
testcafe
【解决方案1】:
是的,也可以通过 TestCafè 以类似的方式实现所需的行为:
import { Selector } from "testcafe";
// one option
const firstLinkSelector = Selector("#directoryLink-1 a");
// another option
const secondLinkSelector = Selector("#directoryLink-1").find("a");
阅读有关 find() 方法的更多信息here。