1. Selenium Guideline
1. Setup environment
a. InstallJDK 6 or later
b. InstallEclipse
c. InstallTestNG plugin for Eclipse from http://testng.org/doc/download.html
d. Download Selenium libraries for Java from
http://www.seleniumhq.org/download/
Selenium StandaloneServer: selenium-server-standalone-x.x.x.jar
Selenium Client and Webdriver: selenium-java-x.x.x.jar
2. How to work with Selenium-TestNG project
a. Configureproject
ImportSelenium-TestNG:
o FromEclipse, you selects: File->Import->select General/Existing Projects
into Workspace->Next->Browser to Selenium folder->Finish
Add the selenium libraries for Selenium-TestNG project
o FromEclipse, right click on Selenium-TestNG->Properties->Select Java
Build Path->Open Libraries tab->Add External JARS…-> browser to
selenium libraries (selenium-server-standalone-x.x.x.jar, selenium-java-
x.x.x.jar) -> OK
2. b. Structure of Selenium-TestNG project
selenium package
o SeleniumActionBase.java: Including the selenium action (API) which
helps you interact with UI (web element) such as click, enter, get text, …
o SeleniumBrowserBase.java: Including theselenium action (API) which
help you interact with browser (IE, Firefox, Chrome) such as close
browser, navigate, closebrowser, …
testmodule package
o Including the test module that you create such as TM_CreateIssue.java,
TM_Login.java
test-output
o Including the test results after running test module. You can get more
information of test resultfromthis folder
c. How to create a test module
Fromeclipse, right click on testmodule package->New->Class->Enter class
name (e.g: TM_Demo)->Finish. After finishing, the class look like as image
below:
3. Next, you mustadd 2 methods which are “setup”, “tearDown” and at least
a test method. Following image below for more details
4. d. Run/debug test module and get result
In order to run test module, right-click on test module (TM_Demo)->Run
As->TestNG Test
5. In order to debug test script:
o Toggle breakpoint
o Then right-click on test module (TM_Demo)->Debug As->TestNG Test
6. Get result: After running the test module, you can refer to “test-output”
folder to get test result
o The file of test result: // test-output/index.html