Search code examples
robotframeworkrobotframework-ide

Robot Framework - Selecting value from a dropdown list which appears after mouse over


The scenario is :

  1. The user will move the mouse over the link : ID_CHECK: R17AA003
  2. The dropdown list will appear automatically
  3. User will select a test type from the list by Clicking

enter image description here

I am trying this code to achieve this :

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

When I run the test, Robot framework moves the mouse over the id_Check link and we can see that the text box is appearing:

enter image description here

But right after that the test fails. Apparently it can find the element on the webpage , but can not locate the dropdown box to click on.

enter image description here

After this I tried by removing the click link command and directly went for Select from list command:

Mouse over    ${xpathToIdCheck}
Page Should Contain Element    xpath=//*[@id="list_of_test_types"]    5s
Select From List    xpath=//*[@id="list_of_test_types"]    STR

But it failed again. The feedback is as follows:

enter image description here

The html code is as follows:

    <form action="/change_test_type_id_check?page=1&amp;study_id=ID&amp;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>

Also if I change the code to

Select From List by Value   xpath=//*[@id="list_of_test_types"]    STR

This also fails with the message "NoSuchElementException: Message: Cannot locate option with value: STR"

Looking forward for your kind support. Thanks


Solution

  • You can try as below.

    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}')]