Our side past times side pace to create is - TestNG software examination example creation inwards eclipse later installation of TestNG inwards eclipse. You tin VIEW TESTNG INSTALLATION STEPS inwards my before post service if y'all accept non configured TestNG in your eclipse. Now allow me depict y'all steps of writing your outset selenium webdriver software automation examination example amongst TestNG.
Step 1 : Create New Project And Package
First of all, Create novel coffee projection inwards your eclipse amongst cite = "TestNGOne" in addition to create packet "TestNGOnePack" nether your project. VISIT THIS POST If y'all don't know how to create novel coffee software evolution projection in addition to packet inwards eclipse.
Step ii : Add TestNG Library
For adding TestNG library,
- Go to your project's Properties -> Java Build Path -> Libraries Tab.
- Click on Add Library button -> Select TestNG from Add Library popup in addition to thence click on Next and Finish buttons.
It volition add together TestNg library inwards your projection every bit shown inwards bellow image. Now click on OK button to closed that window.
Step iii : Create TestNG Class
To add together TestNg class
- Right click on packet "TestNGOnePack" -> New -> Other. It volition opened upwards New sorcerer window every bit bellow.
- Select TestNg from New sorcerer window in addition to click on Next button.
- On side past times side screen, add together degree cite = ClassOne
- It volition add together novel degree (ClassOne) nether packet every bit shown inwards bellow given image.
Step four : Add webdriver's external appall file inwards your project.
To Run webdriver software automation test, y'all require to add together webdriver software automation tool's appall files every bit external appall file inwards your project. VIEW THIS POST to know how to download webdriver appall files in addition to add together external appall file to coffee create path.
(Note : Do non add together junit appall file every bit external appall file. Now its non required inwards TestNG framework).
This is it. Now y'all are ready to write your webdriver software automation examination script within your class.
Step five : Add/write sample webdriver examination script.
Write your ain examination script or add together bellow given script inwards your degree file.
Step half dozen : Run Webdriver examination script amongst TestNG
Go to Run -> Run As -> And Click on TestNg Test every bit shown inwards bellow given image.
It volition run your webdriver examination amongst TestNG. When execution completed, You volition meet effect every bit shown inwards bellow given image.
Step seven : View examination execution HTML written report generated past times TestNG
To thought examination execution report,
Write your ain examination script or add together bellow given script inwards your degree file.
package TestNGOnePack; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; populace degree ClassOne { WebDriver driver = novel FirefoxDriver(); //@BeforeMethod defines this method has to run before every @Test methods @BeforeMethod populace void openbrowser() { driver.manage().window().maximize(); driver.get(" "); } //@AfterMethod defines this method has to run later every @Test methods @AfterMethod populace void closebrowser() { System.out.print("\nBrowser close"); driver.quit(); } @Test populace void testmethodone() { String championship = driver.getTitle(); System.out.print("Current page championship is : "+title); System.out.print("\n'TestNGOne -> TestNGOnePack -> ClassOne -> testmethodone' has been executed successfully"); } }
Step half dozen : Run Webdriver examination script amongst TestNG
Go to Run -> Run As -> And Click on TestNg Test every bit shown inwards bellow given image.
It volition run your webdriver examination amongst TestNG. When execution completed, You volition meet effect every bit shown inwards bellow given image.
Step seven : View examination execution HTML written report generated past times TestNG
To thought examination execution report,
- Right click on "TestNGOne" projection folder inwards eclipse in addition to lead Refresh.
- Folder amongst cite = "test-output" volition last created nether your projection folder every bit shown inwards bellow given Image.
- Explore that folder in addition to opened upwards it amongst spider web Browser every bit shown inwards in a higher house image. It volition opened upwards written report inwards eclipse every bit shown inwards bellow given image.