Automation 动态内容的选择器问题
我尝试从react生成的列表中选择一个列表项。TestCafe Studio将选择:Automation 动态内容的选择器问题,automation,css-selectors,selector,e2e-testing,testcafe,Automation,Css Selectors,Selector,E2e Testing,Testcafe,我尝试从react生成的列表中选择一个列表项。TestCafe Studio将选择: .click(Selector('#cat_220518').find('.cl-folder-list-element-arrow')) 但这是一个动态值,可能会随着下一次运行而改变。所以我尝试使用来选择文本,但失败了。我使用: .click(Selector('span').withExactText('test1234').find('.cl-folder-list-element-arrow'))
.click(Selector('#cat_220518').find('.cl-folder-list-element-arrow'))
但这是一个动态值,可能会随着下一次运行而改变。所以我尝试使用来选择文本,但失败了。我使用:
.click(Selector('span').withExactText('test1234').find('.cl-folder-list-element-arrow'))
元素是一个箭头按钮,用于打开子项列表。但是点击永远不会发生。Testcafe正在等待元素cl文件夹列表元素箭头。
从文档中,我了解到withExactText将选择元素的主节点。在我看来,要找到工作是必须的。我的想法怎么了
页面上的元素是:
<div class="category-tree-node" id="cat_220518" style="padding-left: 2%; width: 98%;">
<div class="category-tree-node-property" draggable="true">
<div class="cl-drop-sensors top"></div>
<div class="cl-folder-list-element-name">
<div class="cl-folder-list-element-arrow"></div>
<span>test1234</span>
</div>
<div class="cl-drop-sensors bottom"></div>
</div>
</div>
find方法不起作用,因为选择器“span”。选择器的ExactText“test1234”部分精确返回span元素。但如果将“span”替换为“div”,则选择器应能正常工作: 选择器'div'。使用ExactText'test123'。查找'.cl文件夹列表元素箭头' 还可以使用类别树节点类使选择器更安全: 选择器“div.category-tree-node”。使用ExactText“test1234”。查找“.cl文件夹列表元素箭头” 另见: