I’m currently implemenating Robot Framework for a web application testing. I need to interact with few dropdown elements. I want to save dropdowndown elements options in a CSV/Excel file. and then use one of the option in the testcase using that CSV/Excel file. I’m using selenium library and pycharm IDE.
for example, in below code i want to click an dropdown element and select a particular option. but i want to save that option inside a CSV file and call it in my testcase instead of hard coding.
Click Element //select[@id=‘plantSelector’]
Click Element //option[@value=‘52’]
I have already installed datadriver library and csv library. I tried the below block of code and multiple other options. but so far no success.
Any help would be appreciated. Need a starting point.
Hi Dave,
Thanks for the reply.
However, I do not want to declare the value that is ‘52’ inside my test case. I want to only pick the value from the Excel/CSV without declaring it in my test case. and if i want to change that value ‘52’ to something else then i would change that in the excel/CSV file instead of declaring it in my test case.
another example scenario.
in above testing website, there’s a dropdown element ‘Continents’ which has different continenents in drop down.
Asia
Europe
Australia
Africa
South America
North America
Antartica.
So my goal is to save only 1 option which is ‘Asia’ from the list of continents in an excel/CSV and then call that option during my test case. eg. Click Element and then Click the option which is ‘Asia’.
And if i want to pick a different continent then i would only change the value in my testdata file instead changing it directly inside my testcase.
As I mentioned you can replace the 52 with any variable you like, e.g.:
Select Option By Value ${your_plantSelector_variable) ${your_52_variable}
You didn’t say which Library/keywords you are using for reading the excel/CSV files, have you worked that out yet? You define the variable when you use the keyword that reads the file, then you pass that value to the next keyword that interacts with the web site.
In that above testing website, the dropdown element ‘Continents’ is an option list, so you can use the “List” keywords with it.
I’ll leave you to play and learn how to drive that “AUTOMATION PRACTICE FORM” as it looks like a good practice form