我正在使用robot framework 浏览器库来自动化UI。
UI有这样一个下拉列表,一个相当长的列表。
示例HTML:
<div class="rc-virtual-list-holder-inner" style="outline: green dotted 2px !important;">
<div aria-selected="false" class="ant-select-item ant-select-item-option" title="Singapore Codeswitch 16k" style="">
<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">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 ant-select-item-option-active" title="train-again-v1-16k" style="">
<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>测试用例
*** Settings ***
Library Browser
*** Test Cases ***
Upload New Dual Channel Audio
Fill Text ${TextField-Job-Name} ${RandomNumber}
click //input[contains(@type,'search')]
Select Options By //div[contains(@class,'ant-select-item ant-select-item-option ant-select-item-option-active')] text Model-1-wav-stm-only-v1-8k然而,出现了以下错误:
Error: locator.selectOption: Error: Element is not a <select> element
=========================== logs ===========================
waiting for selector "//div[contains(@class,'ant-select-item ant-select-item-option ant-select-item-option-active')]"
selector resolved to visible <div aria-selected="false" title="16000samplerate-60t…>…</div>
selecting specified option(s)
Element is not a <select> element
============================================================发布于 2022-05-25 08:48:09
通过对元素使用Hover,然后对元素上的Click进行计算。
*** 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(.,'${value}')]
Click //div[@class='ant-select-item-option-content'][contains(.,'${value}')]https://stackoverflow.com/questions/72343573
复制相似问题