3

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.

3

3 Answers 3

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 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.

1
  • If you want to do it using Java - try OpenCSV library. I have recently used it: very simple to use with good fucntionality Sep 9, 2016 at 8:33
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: SelBlocks 2.1

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

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