Error: locator.hover: Unsupported token "@class" while parsing selector
Error: locator.hover: Unsupported token "@class" while parsing selector
我正在使用浏览器关键字 'Hover' 让机器人 select 一个位于下拉列表底部的值。
测试用例:
*** Settings ***
Library Browser
*** Test Cases ***
Upload New Dual Channel Audio
Fill Text ${TextField-Job-Name} ${RandomNumber}
click //input[contains(@type,'search')]
Hover //div[@class='ant-select-item-option-content'][contains(.,'train-again-v1-16k')]
更正脚本后,// 在 selector 和错误现在由 selector not found 引起:
001-upload-single-audios TimeoutError: locator.hover: Timeout 30000ms exceeded.
===========================日志================= ==========
等待 select 或“//div[@class='ant-select-item-option-content'][包含(.,'train-again-v1-16k')]”
外HTML:
<div class="rc-virtual-list" style="outline: green dotted 2px !important;">
<div class="rc-virtual-list-holder" style="max-height: 256px; overflow-y: hidden; overflow-anchor: none;">
<div style="height: 352px; position: relative; overflow: hidden;">
<div class="rc-virtual-list-holder-inner" style="display: flex; flex-direction: column; transform: translateY(64px); position: absolute; left: 0px; right: 0px; top: 0px;">
<div aria-selected="false" class="ant-select-item ant-select-item-option" title="autotestmodel-3126-v2-8k">
<div class="ant-select-item-option-content">autotestmodel-3126-v2-8k</div>
<span class="ant-select-item-option-state" unselectable="on" aria-hidden="true" style="user-select: none;"></span>
</div>
<div aria-selected="false" class="ant-select-item ant-select-item-option" title="autotestmodel-6716-v2-8k">
<div class="ant-select-item-option-content">autotestmodel-6716-v2-8k</div>
<span class="ant-select-item-option-state" unselectable="on" aria-hidden="true" style="user-select: none;"></span>
</div>
<div aria-selected="false" class="ant-select-item ant-select-item-option" title="Singapore Codeswitch 16k">
<div class="ant-select-item-option-content">Singapore Codeswitch 16k</div>
<span class="ant-select-item-option-state" unselectable="on" aria-hidden="true" style="user-select: none;"></span>
</div>
<div aria-selected="false" class="ant-select-item ant-select-item-option" title="manualtest8020-v1-8k">
<div class="ant-select-item-option-content">manualtest8020-v1-8k</div>
<span class="ant-select-item-option-state" unselectable="on" aria-hidden="true" style="user-select: none;"></span>
</div>
<div aria-selected="false" class="ant-select-item ant-select-item-option" title="mmlntu-v1-8k">
<div class="ant-select-item-option-content" style="">mmlntu-v1-8k</div>
<span class="ant-select-item-option-state" unselectable="on" aria-hidden="true" style="user-select: none;"></span>
</div>
<div aria-selected="false" class="ant-select-item ant-select-item-option" title="semicolon:test123-v1-8k">
<div class="ant-select-item-option-content">semicolon:test123-v1-8k</div>
<span class="ant-select-item-option-state" unselectable="on" aria-hidden="true" style="user-select: none;"></span>
</div>
<div aria-selected="false" class="ant-select-item ant-select-item-option" title="sourcemodel8k8020-v1-8k">
<div class="ant-select-item-option-content" style="">sourcemodel8k8020-v1-8k</div>
<span class="ant-select-item-option-state" unselectable="on" aria-hidden="true" style="user-select: none;"></span>
</div>
<div aria-selected="false" class="ant-select-item ant-select-item-option" title="test2-16000-7030-v13-16k" style="">
<div class="ant-select-item-option-content" style="">test2-16000-7030-v13-16k</div>
<span class="ant-select-item-option-state" unselectable="on" aria-hidden="true" style="user-select: none;"></span>
</div>
<div aria-selected="true" class="ant-select-item ant-select-item-option ant-select-item-option-active ant-select-item-option-selected" title="train-again-v1-16k">
<div class="ant-select-item-option-content" style="">train-again-v1-16k</div>
<span class="ant-select-item-option-state" unselectable="on" aria-hidden="true" style="user-select: none;"></span>
</div>
</div>
</div>
</div>
<div class="rc-virtual-list-scrollbar rc-virtual-list-scrollbar-show" style="width: 8px; top: 0px; bottom: 0px; right: 0px; position: absolute; display: none;">
<div class="rc-virtual-list-scrollbar-thumb" style="width: 100%; height: 128px; top: 128px; left: 0px; position: absolute; background: rgba(0, 0, 0, 0.5); border-radius: 99px; cursor: pointer; user-select: none;"></div>
</div>
</div>
您的 xpath 缺少“//”。 xpath 应始终以 // 开头,除非您从 html 元素开始。
如果您的 xpath 的其余部分是正确的,那么像这样添加 // 应该会起作用。
Hover //div[@class='ant-select-item-option-content'][contains(.,'mmlntu-v1-8k')]
如果你能提供你的html,我可以根据你的情况给你一个更具体的答案。
添加后更新html
试试这个:
Hover //div[@class='ant-select-item-option-content' and contains(text(),'mmlntu-v1-8k')]
对于 xpaths 的未来参考,您可以使用此备忘单:https://devhints.io/xpath
我正在使用浏览器关键字 'Hover' 让机器人 select 一个位于下拉列表底部的值。
测试用例:
*** Settings ***
Library Browser
*** Test Cases ***
Upload New Dual Channel Audio
Fill Text ${TextField-Job-Name} ${RandomNumber}
click //input[contains(@type,'search')]
Hover //div[@class='ant-select-item-option-content'][contains(.,'train-again-v1-16k')]
更正脚本后,// 在 selector 和错误现在由 selector not found 引起:
001-upload-single-audios TimeoutError: locator.hover: Timeout 30000ms exceeded.
===========================日志================= ========== 等待 select 或“//div[@class='ant-select-item-option-content'][包含(.,'train-again-v1-16k')]”
外HTML:
<div class="rc-virtual-list" style="outline: green dotted 2px !important;">
<div class="rc-virtual-list-holder" style="max-height: 256px; overflow-y: hidden; overflow-anchor: none;">
<div style="height: 352px; position: relative; overflow: hidden;">
<div class="rc-virtual-list-holder-inner" style="display: flex; flex-direction: column; transform: translateY(64px); position: absolute; left: 0px; right: 0px; top: 0px;">
<div aria-selected="false" class="ant-select-item ant-select-item-option" title="autotestmodel-3126-v2-8k">
<div class="ant-select-item-option-content">autotestmodel-3126-v2-8k</div>
<span class="ant-select-item-option-state" unselectable="on" aria-hidden="true" style="user-select: none;"></span>
</div>
<div aria-selected="false" class="ant-select-item ant-select-item-option" title="autotestmodel-6716-v2-8k">
<div class="ant-select-item-option-content">autotestmodel-6716-v2-8k</div>
<span class="ant-select-item-option-state" unselectable="on" aria-hidden="true" style="user-select: none;"></span>
</div>
<div aria-selected="false" class="ant-select-item ant-select-item-option" title="Singapore Codeswitch 16k">
<div class="ant-select-item-option-content">Singapore Codeswitch 16k</div>
<span class="ant-select-item-option-state" unselectable="on" aria-hidden="true" style="user-select: none;"></span>
</div>
<div aria-selected="false" class="ant-select-item ant-select-item-option" title="manualtest8020-v1-8k">
<div class="ant-select-item-option-content">manualtest8020-v1-8k</div>
<span class="ant-select-item-option-state" unselectable="on" aria-hidden="true" style="user-select: none;"></span>
</div>
<div aria-selected="false" class="ant-select-item ant-select-item-option" title="mmlntu-v1-8k">
<div class="ant-select-item-option-content" style="">mmlntu-v1-8k</div>
<span class="ant-select-item-option-state" unselectable="on" aria-hidden="true" style="user-select: none;"></span>
</div>
<div aria-selected="false" class="ant-select-item ant-select-item-option" title="semicolon:test123-v1-8k">
<div class="ant-select-item-option-content">semicolon:test123-v1-8k</div>
<span class="ant-select-item-option-state" unselectable="on" aria-hidden="true" style="user-select: none;"></span>
</div>
<div aria-selected="false" class="ant-select-item ant-select-item-option" title="sourcemodel8k8020-v1-8k">
<div class="ant-select-item-option-content" style="">sourcemodel8k8020-v1-8k</div>
<span class="ant-select-item-option-state" unselectable="on" aria-hidden="true" style="user-select: none;"></span>
</div>
<div aria-selected="false" class="ant-select-item ant-select-item-option" title="test2-16000-7030-v13-16k" style="">
<div class="ant-select-item-option-content" style="">test2-16000-7030-v13-16k</div>
<span class="ant-select-item-option-state" unselectable="on" aria-hidden="true" style="user-select: none;"></span>
</div>
<div aria-selected="true" class="ant-select-item ant-select-item-option ant-select-item-option-active ant-select-item-option-selected" title="train-again-v1-16k">
<div class="ant-select-item-option-content" style="">train-again-v1-16k</div>
<span class="ant-select-item-option-state" unselectable="on" aria-hidden="true" style="user-select: none;"></span>
</div>
</div>
</div>
</div>
<div class="rc-virtual-list-scrollbar rc-virtual-list-scrollbar-show" style="width: 8px; top: 0px; bottom: 0px; right: 0px; position: absolute; display: none;">
<div class="rc-virtual-list-scrollbar-thumb" style="width: 100%; height: 128px; top: 128px; left: 0px; position: absolute; background: rgba(0, 0, 0, 0.5); border-radius: 99px; cursor: pointer; user-select: none;"></div>
</div>
</div>
您的 xpath 缺少“//”。 xpath 应始终以 // 开头,除非您从 html 元素开始。
如果您的 xpath 的其余部分是正确的,那么像这样添加 // 应该会起作用。
Hover //div[@class='ant-select-item-option-content'][contains(.,'mmlntu-v1-8k')]
如果你能提供你的html,我可以根据你的情况给你一个更具体的答案。
添加后更新html
试试这个:
Hover //div[@class='ant-select-item-option-content' and contains(text(),'mmlntu-v1-8k')]
对于 xpaths 的未来参考,您可以使用此备忘单:https://devhints.io/xpath