Venkatesh
Venkatesh

Reputation: 52

How to select items of a drop down list in an iteration

I have a drop down list which consists of 'n' number of items. I have to verify that all the drop down items are clickable. To execute this I have used for loop as shown below:

*** Settings ***
Resource  ../resources/settings.robot

*** Test Cases ***
TC title
  Make sure that the user should be able to select an item from the drop down list

*** Keywords ***
Make sure that the user should be able to select an item from the drop down list
Click Element  ${combo_box}           //Clicking on the combo box displays the drop down list
@{get_role_list}=   Get WebElements  css=td.row-highted > div:nth-child(1) > combo-box:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div
:FOR    ${each}     IN      @{get_role_list}
\  Click Element  @{get_role_list}    //selects an item from the list in an iteration
\  Click Element  ${combo_box}        //once an item from the list is selected the drop down list disappears, to iterate this loop drop down list should be displayed hence clicking on combo box after selecting an item

Any help would be appreciated.

Upvotes: 0

Views: 261

Answers (1)

A. Kootstra
A. Kootstra

Reputation: 6971

It seems to me that you should click on ${each} instead of @{get_role_list}

:FOR    ${each}     IN      @{get_role_list}
\    
\    # selects an item from the list in an iteration
\    Click Element  ${each}
\  
\    # once an item from the list is selected the drop down list disappears, 
\    # to iterate this loop drop down list should be displayed hence clicking 
\    # on combo box after selecting an item
\    Click Element  ${combo_box}  

Upvotes: 1

Related Questions