:::: MENU ::::

Read a CSV file in Selenium IDE

Finally, here is simple yet efficient code to read a CSV file in Selenium IDE for data driven testing.

Two commands needed to do this, first you need to read file so use “Readcsv” file and this will read you file, you can use this data in multiple test cases, test suite by specifying cell position of data you want to read so use the second command “StoreCellValue” specify variable name and use this across your test case/ test suite.

You can also specify dynamic values instead of static values for cell positions.

 

 

Add below JavaScript file to your Selenium IDE plug-in. Using options menu.

CSVRead_Selenium IDE (code file)

I have also added example code.

readcsv(example file)


18 Comments

  • Reply Arijit |

    Hi,
    Yea it would be great to have the option to write ‘storeText’ values into files as well. Any solution?

    regards,
    Arijit

  • Reply Doug |

    I have this same issue. Basically reading data from a .js file that is sometimes English data or sometimes spanish data. When I use that in my test cases, any characters with special codes (for instance: México when is es-MS culture code) result in Unicode characters (ie. M�xico). So the error I get in the Selenium IDE log when trying to select this value is…[error] Option with label ‘M�xico’ not found

    • Reply Abhishek Jain |

      You can user SelBlocks or Flow Control, For loop will help you with the option to loop through CSV file, pass parameters in the StoreCellValue command.

  • Reply Salman |

    It works only for a single row of CSV file , I need to read all rows of csv file? please let me know how to do it.

  • Reply Sourav Jain |

    Nice work!
    you can add up more feature of Mozilla plug-in and also one thing it works only with fetching values to variables not to other commands, try to add that too.

  • Reply Automation Tester |

    I cannot download this addon from selenium website, download link doesnt work. Please help

  • Reply Laura |

    Hi.

    I’m trying to add this to Selenium IDE on ubuntu. I saved the code for file extension, loaded it on Selenium IDE, and I saved a csv file in the same folder as the extension file.

    Now, when I call readCSV function, I add as target only the csv file name, as they are in the same folder. But I always get the “file not found” error.

    Can you please let me know what am I doing wrong?

    • Reply Laura |

      Never mind, My path was wrong. If anyone is searching for an anser, the path should be “file:/home///.csv”

  • Reply C.Harris |

    This sounds like what I’m looking for.
    How do I add your “CSVRead_Selenium IDE.js” file to my Selenium IDE plugins list?
    I don’t see any ‘browse’ button on the Options page. Any help would be greatly appreciated.

  • Reply Derek |

    Would you mind providing step by step instructions on how to execute this? I am new to Selenium and it seems like this will do exactly what i need (load a bunch of values from a csv into a web form)

    Thank You in advance,
    Derek

  • Reply sachin |

    Thanks for sharing.
    Its working fine but if we want to perform the cross browsing testing on “IE” using selenium RC then its not working at all.
    Please help…..

  • Reply Stefan |

    Great work!
    Would you be able to add a function to actually return values to the CSV?

    Use case:
    – ReadCSV
    – Test stuff
    – Write results back to CSV

    Would be amazing!

    Thx!

  • Reply Scott |

    I like the script. It would be useful if the columns could be selected by the first row name rather the position in the list. I’ll play around and see how else I can use this. Thanks for sharing 😉

So, what do you think ?

Fork me on GitHub