You just need to make a JavaScript file which contains all the parameters with their values. And then you can easily access this parameter through selenium IDE.let's see this thing by an example.
let's first make the JavaScript file .
searchKey = "selenium IDE Parameterization"
copy the above line into a file and save it as data.js
Now as we have created the data file. We need some way for selenium to identify this data.js file and access the variables inside it. So for that you need to import it as Selenium IDE Extenstion. let's see how to do it.
First open the selenium IDE.
navigate to options->options
Under the selenium IDE extension browse the data.js file.
Restart the selenium IDE.
Now selenium IDE is able to access the data.js file. So let's see how to do it.
Following is the code that will open the google browser and will search the for the keyword we have sepecied in the data.js file.
<!--
Purpose: To show Prameterization using Selenium IDE
Created by: Gaurang Shah
Email: gaurangnshah@gmail.com
-->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://www.google.co.in/" />
<title>Parameterization_Example</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Parameterization_Example</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>/</td>
<td></td>
</tr>
<tr>
<td>storeEval</td>
<td>searchKey</td>
<td>searchKey</td>
</tr>
<tr>
<td>type</td>
<td>q</td>
<td>${searchKey}</td>
</tr>
<tr>
<td>click</td>
<td>btnG</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
22 comments:
gaurang it would be much easier or helpful if you could explain that code you have attached
hi Shankar,
there is nothing much to explain in the code. It simple says you can access the variable inside data.js file using ${var_name}.
Hi Gaurang,
Can you please provide sample java script file.
Thanks in advance..
//Vijay
hey vijay,
The data.js file contains only one line as follows.
searchKey = "selenium IDE Parameterization"
Thanks for the quick reply.
i have added data.js file to selenium IDE extension. but facing issues.
please help me on this.
//Vijay
Hi Vijay,
What errors ???
I don't think you should get any error. Just copy and past the above code save it as test.html and open it in the IDE. If you have already imported Data.js as user extension as explain above it will run the test case successfully.
Hi Gaurang,
thanks a lot.. Now i am able to do this.
But can u please explain that how can we put our input values in loop here.
//Vijay
Hi Gaurang
Thanks for your excellent simple script and process how to create java file and Html file for Parameterization. But that java file contains only one data to be parameterized, I added more data over there in the JS file, didn't work. What is the correct way to insert data in that file? Searchkey= "ABCD", "DEFG" or some other way. Could you please help ?
Hi Gaurang
Thanks for your excellent simple script and process how to create java file and Html file for Parameterization. But that java file contains only one data to be parameterized, I added more data over there in the JS file, didn't work. What is the correct way to insert data in that file? Searchkey= "ABCD", "DEFG" or some other way. Could you please help ?
Hi Gaurang,
As explained above, can you please give me some tips on how to verify the email address if I am testing a website, when a user registers to my site.
Scenario:
1. I am testing a web site where user registers.
2. Once the user has registered to the site, I need to verify the email address provided by the user.
3. How can I parameterize the test and verify multiple users email id.
Please let me know if the above scenario can be performed in scelenium IDE.
Many Thanks,
Sanjay
Yes gourav,
pLease help me to pass multiple TestDatas..
searchKey = "selenium IDE Parameterization", "ABCD", "dfgd" --- Is this right way?
or every line we have to give searchKey= format?
i tried this but when i run the script instead of value its just show the variable name i dnt know y.. can anyone help on that
Facing error such as searchKey not found.Can you pls help me on this?
Hey,
It worked for one value. storeeval will take only last value from the snippet. What about other values? Seems like some R&D is required . Guys if anyone has succeeded in it then please let us know about it.
Hi Gaurang,
Whether this parametrization works only when we run the test suite from Selenium IDE or it works even if we run using Selenium server in command line. For example if we record the suite using IDE and save it as HTML file and play back using selenium server as mentioned below in command line,
java -jar selenium-server.jar -firefoxProfileTemplate "C:\Automation Scripts\Profile" -trustAllSSLCertificates -htmlSuite "*chrome"
Would the parametrization still work ? If not how to achieve parametrization here ?
Hi gaurang i am currently started working with selenium IDE and facing problem of saving a file .
when I am going to run test case it was hanged after the dialog box and time out and my case failed!
Please see if any thing add into this case.
Thanks in advance!
hi gaurang,
is it possible to parameterize the urls that are being hit from selenium testcases using js file?
@Milind -check-out this URL > http://stackoverflow.com/questions/9210578/how-do-i-parameterise-the-urls-in-selenium
Hi Gaurang,
How do you run the XML file that shown above?
I have made Selenium ide to link with data.js file. Where do run the XML file ( In which ur calling the search key)? Explain Pls
Thanks
Rekha
Thanks
Hi Gaurang
Thanks for your excellent simple script,is it possible to do with Excel file in Selenium IDE.
thanks
mamatha
Username=new Array("today81","today82");
password=new Array("indianic","indianic");
try this way...Its useful...
Post a Comment