Selenium 2 and Junit example

  • 12 years ago
We run software Testing workshops.

see www.time2test.co.uk

Selenium 2 and jUnit example
1. use the already created script
2. open up eclipse IDE
3. creat a java project on Eclipse IDE
4. give it a name: Selenium2JavaScript
5. click on Next and Finish
6. create a package for the project
Source folder: Selenium2javaSciprt/src
Name:com.example.tests
7. click on Finish
8. create a java file
New->Class
Name: TestJava
9. Now convert a .html file to .java file
10. open up Selenium IDE and export test case as jUNit4 (webdriver) as .java
11. open up the java file in notepad++
12. copy the saved java file directly into Eclipse
13. Ensure that class name and .java file file name is the same
14. now add the selenium 2 jar and jUnit jar
15 Right click on project->Properties - select java Build Path-> External Jars
16. select jUnit 4.7
17. we have already added the selenium 2 jars to the library so first add selenium 2 jars using "add external jars" button
18. Now Run the Project
19. right click on project->Run As->jUnit Test
20. tick "use configuration specific settings"
21. select jUnit Specific settings
22 . notice the test will execute
23. Green indicates the script run successfully
24. end

Recommended