2

Right now I'm running selenium test script in which I have get data from a CSV file and paste in a site.So can I copy data from a CSV file and paste in a test script in Selenium IDE.

It would be of great help if you could provide method to make changes in a CSV file using a Selenium IDE.

2

Yes, you can do it using Selenium IDE. You can read data from CSV files and use it to fill forms/fields in your application using Selenium IDE. For this you will need to add extension to Selenium IDE which can be downloaded from here.

Download this 'CSVRead_Selenium-IDE.js' file from the specified location and add it to your IDE.

enter image description here

After that you first need to add the command 'readCSV' file to your IDE script and in Target paste the full path of your saved CSV file like 'file://C:/Users/dhi/Desktop/login.csv'. Then, store your defined parameters with the help of 'storeCellValue' command, variable name in Target field and cell location as Value.

Once, this is done, use the defined variable name in the Value field of the command where you need to paste/fill it. In all your script will look like this. I too have used this and it works fine for reading data from CSV files and filling up forms/fields in application.

enter image description here

enter image description here

enter image description here

Use this link for more detail information.

1

It is not exactly what you are asking, but it can suit your needs. You can use SelBlocks Plugin to enable data-driven testing for Selenium IDE.

  1. Convert your CSV to XML file as is required by ForXML command
  2. make use of data in your test.

SelBlocks implements other functions as conditions if-else-endIf, for cycle and others. You can find SelBlocks here: http://refactoror.wikia.com/wiki/Selblocks_Reference

Also the StoredVariables plugin will be usefull to get info what is going on in Stored variables during the script creation.

For example following XML will fill stored variables for each cycle of your test:

<testdata>
<vars testcycle="1" Param1="10" Param2="5"  Result="50" />
<vars testcycle="2" ...
...
</testdata>

Test can look like this:

forXml | data.xml
storeEval | storedVars['Param1'] * storedVars['Param2'] == storedVars['Result'] | ResultOfTheCycle
if | storedVars['ResultOfTheCycle']
   echo | cycle ${testcycle} Passed 
else
   echo | cycle ${testcycle} Failed
endIf
endForXml
1

It is not good idea to use Selenium IDE to modify cvs files. Actually IDE is very simple and was not intended to execute extra functionality. It is better to export code to Java and then implement code for file operations: read, write, etc.

  • If you want to do it using Java - try OpenCSV library. I have recently used it: very simple to use with good fucntionality – Ostap Elyashevskyy Sep 9 '16 at 8:33

protected by Niels van Reijmersdal Sep 6 '16 at 15:01

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.