There are so many languages and frameworks for selenium, such as JAVA, jUnit framework, and C# .Net. These are excellent if you are comfortable with one of the languages and tools. It will help you to create dynamic, advanced test framework according to your test need. Moreover, it opens door to use powerful development language in your test. For example if and else logic.
However, this HTML framework is easy and requires low maintenance. It is powerful enough for most of the automation need and you can use javascript to make your test more meaningful if necessary. You as an automation tester do not need development language either.
However, this HTML framework is easy and requires low maintenance. It is powerful enough for most of the automation need and you can use javascript to make your test more meaningful if necessary. You as an automation tester do not need development language either.
Please follow these steps if you want to adopt this for your test automation purpose. I have used website facebook login page for this tutorial. I am assuming you know about selenium IDE and recording the recording. If answer is ‘no’ then going to this page and come back here.
Download Selenium Server
- Go to http://seleniumhq.org/download/. It is also known as Selenium Server.
- If you cannot find stable build find from this page: http://code.google.com/p/selenium/downloads/list.
- It is a .ZIP file. Once download is completed unzip it in C:\selenium
- Test it. To test it runs properly follow the following step:
1. Open command line.
2. Go to the folder that contains the selenium server. (You can go using DOS cd command to navigate from one folder to another.). Type following commands: java -jar selenium-server-standalone-2.0rc2.jar. If it runs successfully, you will see the following screen:
If it doesn't run check the error message. Usually, problem is with the port. Selenium server’s default port is 4444. If it is taken already, problem occurs. Easy solution is to restart your machine.
Next step is to run your script from the command line. Before I explain more about it, let me share my file and folder structure with you. Please look at the files/folders inside 'selenium' folder carefully before you try to run script from the command line.
fb_1
I have stored my Scripts in this fb_1 folder. Second picture is about where I have put my Selenium Server 2.0
login:
In this folder I have my script file 'login'. I hope you have saved or renamed all your script with .html extension. If not please do that.
testsuite:
I have created one more .html file named 'testsuite'. (Or you have directly save your test script as "save test suite as"). Here I am going to explain about HTML file I have saved as testsuite.
This .html file is a part of selenium HTML-testrunner framework and should be kept inside same folder. My script is associated with this file. Let me copy and paste what I have inside my testsuite file:
1:
It is a batch file to run test with one click.
result1:
It is the result. It should get updated after each test run.
selenium-2.0rc2
This is simply unzipped selenium server.
Now we are ready to run our test. You can name your folder and file name anything. But make sure your command is pointing to right path.
Running Test:
I am able to run my test successfully with the help of following command:
java -jar selenium-server-standalone-2.0rc2.jar -htmlSuite "*firefox" "http://www.facebook.com" "c:\\selenium\fb_1\testsuite.html" "c:\\selenium\fb_1\result1.html"
This command invokes test runner. This looks like:
:To run test in different browser replace *firefox with :-
*chrome
*iexplore
*safari
Once you can run your script successfully, save your command in a notepad with .bat extension. Next time when you want to run your test, just double-click this batch file. You can schedule your batch file to run automatically at a specific time as well. For this use windows scheduled Task utility. You can add as many test script as you want in your batch file. Another will run automatically once previous stops running.
Always remember, Selenium is an open source tool, you might get so many errors before a successful test run. Try to make fewer errors from your side.
*chrome
*iexplore
*safari
Once you can run your script successfully, save your command in a notepad with .bat extension. Next time when you want to run your test, just double-click this batch file. You can schedule your batch file to run automatically at a specific time as well. For this use windows scheduled Task utility. You can add as many test script as you want in your batch file. Another will run automatically once previous stops running.
Always remember, Selenium is an open source tool, you might get so many errors before a successful test run. Try to make fewer errors from your side.
No comments:
Post a Comment