Selenium Guideline

7
Selenium Guideline 1. Setup environment a. Install JDK 6 or later b. Install Eclipse c. Install TestNG plugin for Eclipse from http://testng.org/doc/download.html d. Download Selenium libraries for Java from http://www.seleniumhq.org/download/ Selenium Standalone Server: 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. Configure project Import Selenium-TestNG: o From Eclipse, 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 From Eclipse, 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

Transcript of Selenium Guideline

Page 1: Selenium Guideline

Selenium Guideline

1. Setup environmenta. Install JDK 6 or later b. Install Eclipse c. Install TestNG plugin for Eclipse from http://testng.org/doc/download.htmld. Download Selenium libraries for Java from

http://www.seleniumhq.org/download/ Selenium Standalone Server: selenium-server-standalone-x.x.x.jar Selenium Client and Webdriver: selenium-java-x.x.x.jar

2. How to work with Selenium-TestNG projecta. Configure project

Import Selenium-TestNG: o From Eclipse, 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 From Eclipse, 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

Page 2: Selenium Guideline

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 the selenium action (API) which

help you interact with browser (IE, Firefox, Chrome) such as close browser, navigate, close browser, …

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 result from this folder

c. How to create a test module From eclipse, right click on testmodule package->New->Class->Enter class

name (e.g: TM_Demo)->Finish. After finishing, the class look like as image below:

Page 3: Selenium Guideline

Next, you must add 2 methods which are “setup”, “tearDown” and at least a test method. Following image below for more details

Page 4: Selenium Guideline

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

Page 5: Selenium Guideline

In order to debug test script:o Toggle breakpoint

o Then right-click on test module (TM_Demo)->Debug As->TestNG Test

Page 6: Selenium Guideline

Get result: After running the test module, you can refer to “test-output” folder to get test resulto The file of test result: // test-output/ index.html