Quantcast
Channel: Technical Blogs » Testing Tools
Viewing all articles
Browse latest Browse all 2

Web Application Testing with Selenium Part -2

$
0
0


I have written getting started post on Selenium RC  Testing previously and now I am trying to write this post related to eclipse setup with Selenium RC. I am trying to explain this with helping pictures.

Selenium RC with Eclipse
Eclipse is a multi-language software development platform comprising an IDE and a plug-in system to extend it. It is written primarily in Java and is used to develop applications in this language.

Following lines describes configuration of Selenium-RC with eclipse-jee-indigo-win32 (Indigo Release).

Configuring Selenium-RC with Eclipse

It should not be too different for higher versions of Eclipse
• Launch Eclipse.

• Select File > New > Other.

Selenium Eclipse Integration -1

Step -1

• Java > Java Project > Next

Selenium Eclipse Integration -2

Step -2

  • Provide Name to this project [Test Automation], Select JDK in ‘Use a project Specific JRE’ option (JDK 1.6 selected

in this example) > click Next

Selenium - Eclipse Integration 3

Step-3

Keep ‘JAVA Settings’ intact in next window. Project specific libraries can be added here.

Eclipse Selenium Integration -4

Step -4

Click Finish > Click on Yes in Open Associated Perspective pop up window

 

Eclipse Selenium Integration 5

Step -5

This would create Project ‘Test Automation’ in Package Explorer/Navigator pane.

Eclipse Selenium Integration 6

Step-6

Right click on src folder and click on New > Folder

Eclipse Selenium Integration 7

Step-7

Name this folder as com and click on Finish button.

This should get com package insider src folder.

Following the same steps create core folder inside com

Eclipse Selenium Integration 8

Step-8

 

NewTest class can be kept inside core package.

Create one more package inside src folder named testscripts. This is a place holder for test scripts.

Please notice this is about the organization of project and it entirely depends on individual’s choice /organization’s standards. Test scripts package can further be segregated depending upon the project requirements.

Create a folder called lib inside project Test Automation. Right click on Project name > New > Folder. This is a place holder for jar files to project (i.e. Selenium client driver, selenium server etc)

Eclipse Selenium Integration 9

Step-9

This would create lib folder in Project directory.
Right click on lib folder > Build Path > Configure build Path

Eclipse Selenium Intehration 10

Step-10

Eclipse Selenium Integration 11

Step-11

Under Library tab click on Add External Jars to navigate to directory where jar files are saved. Select the jar files which are to be added and click on Open button.

Eclipse Selenium Integration 12

Step-12

After having added jar files click on OK button. Added libraries would appear in Package Explorer.

 Test Suit Creation 

A Junit Report can be generated by Selenium RC test execution using Ant script. I have used a “build.xml” for Ant for executing Selenium cases and generating a Junit report for the said selenium execution. Following are the steps to generate a Junit report for Selenium Execution.

Setting up a Java Project for test execution using Ant


Preconditions:

1. Install Ant from apache.

2. Install Java JDK (not JRE) and add its bin folder to “PATH” environment variable of user’s system. For checking JDK is mapped check whether “javac” is recognized in the system by typing “javac” in your command prompt.

3. Download the Selenium RC.

4. Test cases are already written in Selenium Junit cases.

Steps:

1. Create a Java project in Java IDE. I am using Eclipse. [Already mentioned how to create it]

2. Now write Selenium Junit classes to this new “com.testscripts” package.

3. Create a new folder called “lib” under the said Java Project. [Already mentioned how to create it]

4. Copy ant-junit.jar, selenium-server-standalone-2.21.0.jar, selenium-java-2.21.0.jar , selenium-java-2.21.0-srcs.jar and junit-4.8.2.jar to your “lib” folder of Java Project.

5. Now create a folder called “build” under Java Project and copy the “build.xml” file attached with this example to the build folder you created.

6. Now open the build.xml file for edit.

7. Search for “run-single-test” in build.xml. Go to the “<test” under the “run-single-test” target .Replace the values for “name=” variable with the Selenium Junit class name. For ex if class name is TestSelenium.java and it is under package “test” under “src” then replace the value with “test.TestSelenium” then save the build.xml file.

8. Now start the Selenium RC server.

9. Now go to the build folder of the Java Project using command prompt and run the command “ant run-single-test”.

10.It should execute Selenium cases on selenium server and generate an html report onto the “report/html” folder of the Java project.

 

Ok.

That is it for now. More testing schenarios will be explained in next Posts.

References/External Links  :

http://seleniumhq.org/

http://jroller.com/selenium/

Thanks :

To my wife Ketaki Nandi (J2ee Professional also…) for helping me in preparing contents.

 


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images