I am writing a Keyword using Robot Framework with FOR Loop just to iterate all the values present in the 1ST dropdown and get selected one by one. Loop is working but not able to iterate for selecting the indexes.
WebSite:
https://blazedemo.com/ (Choose your departure city:)
Test Case is:
1st will select the zero index with value "Paris", then will select the First index with value "Philadelphia" so on till the 6th indexes.
XPATH:
${Xpath_Departure_DropDown}= "xpath://*[starts-with(@class,'container')]//select[@name='fromPort']"
${Xpath_Departure_DropDown_Options}= "xpath://select[@name='fromPort']/option"
Robot Framework Keyword:
KW_14: Choose your departure city Drop Down:
@{All_Items_In_Drop_Down}= Get List Items ${Xpath_Departure_DropDown} values=True
${All_Items_In_Drop_Down_Label}= Get Selected List Label ${Xpath_Departure_DropDown}
${All_Items_In_Drop_Down_Value}= Get Selected List Value ${Xpath_Departure_DropDown}
List Selection Should Be ${Xpath_Departure_DropDown} ${All_Items_In_Drop_Down_Value}
${Length_Of_Lists_Items}= get length ${All_Items_In_Drop_Down}
FOR ${Index} IN RANGE ${Length_Of_Lists_Items}
LOG ${Index} html=true
Click Element ${Xpath_Departure_DropDown}
sleep 2 seconds
run keyword and continue on failure Select From List By Index ${Xpath_Departure_DropDown_Options}[${Index}]
sleep 2 seconds
${All_Items_In_Drop_Down_Label}= Get Selected List Label ${Xpath_Departure_DropDown}
${All_Items_In_Drop_Down_Value}= Get Selected List Value ${Xpath_Departure_DropDown}
List Selection Should Be ${Xpath_Departure_DropDown} ${All_Items_In_Drop_Down_Value}
END