vnnogile
vnnogile

Reputation: 33

How can we read excelsheet data in selenium IDE

I am very new to selenium ide,How can we read excelsheet data in selenium IDE. I have searched in google but not found particular links which I wanted .I got one link where they are reading excelsheet using eclipse, junit,testNG etc. Is it possible to read data of excelsheet in selenium ide and use that data in selenium ide test cases and also i want to export my test suit result in excelsheet.

Please reply

Thank you

Upvotes: 1

Views: 16842

Answers (2)

ElectricRefugee
ElectricRefugee

Reputation: 21

Though I'm late to the show, I hope the following instructions will at least be of some use to anyone looking to automate part of their workflow. The method detailed below will allow automated web form entry from data in a CSV file using only Selenium IDE.

What you'll need: 1.) Selenium IDE 2.) CSV File Reader plugin // This can be acquired at seleniumhq.org/download then proceed to download at Github 3.) Selblocks // a language extension which permits use of conditonals & looping

Now that you have the necessary tools, fire up Firefox and navigate to your Selenium IDE options. You'll want to copy the path of the File Reader (.js) to Selenium Core Extensions to enable use. With that out of the way, verify that Selblocks installed without issue by typing in "while"; if this command is recognized (i.e. auto-completes/has a reference description) then all went well. Now verify that the File reader plugin commands are accessible by typing in "readCSV"; again if it auto-completes the command that means you're good to go.

Your target for the readCSV command is the path to your file (ex: file:\C:/Test.csv). To read the entire contents of the csv file, you'll need a simple while loop. Here's a sample framework:

...
<tr>
    <td>store</td>
    <td>4</td>
    <td>loop</td>
</tr>
<tr>
    <td>store</td>
    <td>1</td>
    <td>p</td>
</tr>
<tr>
    <td>while</td>
    <td>${p}&lt;${loop}</td>
    <td></td>
</tr>
<tr>
    <td>open</td>
    <td>https://automatestuff.com/go </td>
    <td></td>
</tr>
<tr>
    <td>readCSV</td>
    <td>file:\C:/Test.csv</td>
    <td></td>
</tr>
<tr>
    <td>storeCellValue</td>
    <td>SomeData</td>
    <td>${p},1</td>
</tr>
<tr>
    <td>storeCellValue</td>
    <td>MoreData</td>
    <td>${p},2</td>
</tr>
<tr>
    <td>echo</td>
    <td>${SomeData}</td>
    <td></td>
</tr>
<tr>
    <td>echo</td>
    <td>${MoreData}</td>
    <td></td>
</tr>
<tr>
    <td>storeEval</td>
    <td>${p}+1</td>
    <td>p</td>
</tr>
....
<tr>
    <td>endWhile</td>
    <td></td>
    <td></td>
</tr>

...

Your target value (in this example, 4) for the first store command will vary given the size of your dataset. The while expression will run through your data until it evaluates to false. In this example, I have data being read from column 1, row 1 (and so on) and column 2, but it's possible to configure more or less.

Anyway, I hope that's clear and gets you on your way to automating the mundane bits of your workflow.

Upvotes: 2

DMart
DMart

Reputation: 2461

You can probably hack together something for this that uses javascript to read in files, but I think you should question WHY you want to do it this way instead. Why do you need excel files or why are you limited to IDE testing?

But maybe some help on excel files & javascript: How to read an excel file contents on client side?

Upvotes: 0

Related Questions