Robot Framework - 从鼠标悬停后出现的下拉列表中选择值
Robot Framework - Selecting value from a dropdown list which appears after mouse over
场景是:
- 用户将鼠标移动到 link : ID_CHECK: R17AA003
- 下拉列表会自动出现
- 用户将 select 通过单击
从列表中选择一个测试类型
我正在尝试使用此代码来实现此目的:
Mouse over ${xpathToIdCheck}
Page Should Contain Element xpath=//*[@id="list_of_test_types"] 5s
Click Element ${User_Menu Link}
Select From List xpath=//*[@id="list_of_test_types"] STR
当我运行测试时,Robot framework将鼠标移到id_Checklink上,我们可以看到文本框出现了:
但紧接着测试就失败了。明明可以找到网页上的元素,但是找不到可以点击的下拉框。
在此之后,我尝试通过删除单击 link 命令并直接从列表命令中获取 Select:
Mouse over ${xpathToIdCheck}
Page Should Contain Element xpath=//*[@id="list_of_test_types"] 5s
Select From List xpath=//*[@id="list_of_test_types"] STR
但是又失败了。反馈如下:
html代码如下:
<form action="/change_test_type_id_check?page=1&study_id=ID&test_uuid=UUID" method="post" style="display:inline">
<select class="list_of_test_types" id="list_of_test_types" name="`" onchange="this.form.submit()">
<option value="">Select a test type</option>
<option value="STR">STR</option></select>
</form>
此外,如果我将代码更改为
Select From List by Value xpath=//*[@id="list_of_test_types"] STR
这也失败并显示消息 "NoSuchElementException: Message: Cannot locate option with value: STR"
期待您的支持。谢谢
您可以尝试以下方法。
Mouse over ${xpathToIdCheck}
Page Should Contain Element xpath=//*[@id="list_of_test_types"] 5s
Click Element ${User_Menu Link}
Mouse Down xpath=//li[contains(.,'${STR}')]
Click Element xpath=//li[contains(.,'${STR}')]
尝试使用这个
Select From List By Index name:Trail.NationalParkId 1
场景是:
- 用户将鼠标移动到 link : ID_CHECK: R17AA003
- 下拉列表会自动出现
- 用户将 select 通过单击 从列表中选择一个测试类型
我正在尝试使用此代码来实现此目的:
Mouse over ${xpathToIdCheck}
Page Should Contain Element xpath=//*[@id="list_of_test_types"] 5s
Click Element ${User_Menu Link}
Select From List xpath=//*[@id="list_of_test_types"] STR
当我运行测试时,Robot framework将鼠标移到id_Checklink上,我们可以看到文本框出现了:
但紧接着测试就失败了。明明可以找到网页上的元素,但是找不到可以点击的下拉框。
在此之后,我尝试通过删除单击 link 命令并直接从列表命令中获取 Select:
Mouse over ${xpathToIdCheck}
Page Should Contain Element xpath=//*[@id="list_of_test_types"] 5s
Select From List xpath=//*[@id="list_of_test_types"] STR
但是又失败了。反馈如下:
html代码如下:
<form action="/change_test_type_id_check?page=1&study_id=ID&test_uuid=UUID" method="post" style="display:inline">
<select class="list_of_test_types" id="list_of_test_types" name="`" onchange="this.form.submit()">
<option value="">Select a test type</option>
<option value="STR">STR</option></select>
</form>
此外,如果我将代码更改为
Select From List by Value xpath=//*[@id="list_of_test_types"] STR
这也失败并显示消息 "NoSuchElementException: Message: Cannot locate option with value: STR"
期待您的支持。谢谢
您可以尝试以下方法。
Mouse over ${xpathToIdCheck}
Page Should Contain Element xpath=//*[@id="list_of_test_types"] 5s
Click Element ${User_Menu Link}
Mouse Down xpath=//li[contains(.,'${STR}')]
Click Element xpath=//li[contains(.,'${STR}')]
尝试使用这个
Select From List By Index name:Trail.NationalParkId 1