通过自定义标签设置午休选择器

Siesta selector by custom tags

本文关键字:选择器 设置 标签 自定义      更新时间:2023-09-26

我想问一下是否可以在午休时通过自定义标签编写选择器:

例如,我有组件:

<a class="x-btn x-unselectable x-box-item x-toolbar-item x-btn-default-small" style="min-width: 75px; right: auto; left: 232px; top: 0px; margin: 0px;" hidefocus="on" unselectable="on" id="button-1017" data-id="loginBtn" tabindex="0" componentid="button-1017" target="_blank">

,我可以从控制台使用css选择器选择:document.querySelector('a[data-id="loginBtn"]')

但是如果我在午休测试中写:t.chain({click: '>> a[data-id="loginBtn"]'},未发现组分

选择器应该如何查找组件?

组件的选择器应该是这样的:

t.chain(
    {click: 'a[data-id=loginBtn]'}
)

click方法正在接受ActionTarget,而您正在使用用于ExtJS组件查询的>>。你可以在docs页面找到更多关于如何指定目标类型的信息。

如果你正在测试ExtJS应用程序,你也应该能够直接点击ExtJS按钮组件。有多种方法如何定位这样的按钮,但如果你已经设置了配置itemId,这是组件的唯一id,查询将看起来类似:

t.chain(
    {click: '>> button[itemId=loginBtn]'}
)