You tin non exhibit TestNG default reports to your director or customer because they are non much to a greater extent than readable together with Interactive. ReportNG Is real practiced plus to generate Interactive together with readable reports for selenium webdriver tests. It Is uncomplicated HTML reporting plug-In. Also It Is real very slow to configure ReportNG alongside your selenium project. If y'all remember, XSLT reports are Interactive also together with nosotros convey generated XSLT reports In webdriver datadriven framework. If y'all postulate XSLT reports together with then y'all tin READ THIS POST.
Follow bellow given v steps to generate ReportNG HTML report.
STEP 1 : Download required Jar Files
You postulate to download bellow given jolt files.
- guice-3.0.jar
- reportng-1.1.4.jar
- velocity-dep-1.4.jar
You tin download all to a higher house iii files from THIS PAGE.
Alternate download locations
- Go to THIS PAGE and click on Download link equally shown In bellow Image to download reportng-1.1.4.jar and velocity-dep-1.4.jar files.
- Go to THIS PAGE together with click on guice-3.0.zip download push clit equally shown In bellow Image to download reportng-1.1.4.jar together with velocity-dep-1.4.jar file.
STEP 2 : Add Jar Files In Project's Build path
Now y'all postulate to add together to a higher house all iii files In project's cook path. If y'all don't know how to add together jolt files In project's cook path together with then refer "Adding jolt Files In Project's Build Path" department on THIS PAGE.
So instantly your Referenced Libraries folder convey iii to a greater extent than files equally shown In bellow Image.
STEP 3 : Disable default listeners of testng
You postulate to disable default listeners of testng.
To disable default listeners
- Right click on projection folder In eclipse.
- Go to Properties. - It volition opened upward Properties dialog.
- Go to TestNG together with banking concern agree Disable default listeners checkbox equally shown In bellow Image together with click on OK button.
STEP iv : Create examination cases nether your projection together with configure testng.xml file
My projection refer Is Test_NG. Now do packet nether your projection alongside refer = Testing_Pack together with add together bellow given ii examination cases nether that package.
Reportngtest1.java
package Testing_Pack; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.Assert; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; world aeroplane Reportngtest1 { WebDriver driver; @BeforeTest world void setup() throws Exception { driver =new FirefoxDriver(); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.get(" "); } @Test(priority=1) world void Sum_Test() { driver.findElement(By.xpath("//input[@id='Resultbox']")).clear(); driver.findElement(By.xpath("//input[@id='2']")).click(); driver.findElement(By.xpath("//input[@id='plus']")).click(); driver.findElement(By.xpath("//input[@id='6']")).click(); driver.findElement(By.xpath("//input[@id='equals']")).click(); String Result = driver.findElement(By.xpath("//input[@id='Resultbox']")).getAttribute("value"); int ResultInt = Integer.parseInt(Result); Assert.assertEquals(8, ResultInt); } @Test(priority=2) world void Sub_Test() { driver.findElement(By.xpath("//input[@id='Resultbox']")).clear(); driver.findElement(By.xpath("//input[@id='4']")).click(); driver.findElement(By.xpath("//input[@id='minus']")).click(); driver.findElement(By.xpath("//input[@id='2']")).click(); driver.findElement(By.xpath("//input[@id='equals']")).click(); String Result = driver.findElement(By.xpath("//input[@id='Resultbox']")).getAttribute("value"); int ResultInt = Integer.parseInt(Result); Assert.assertEquals(2, ResultInt); } @AfterTest world void Close() throws Exception { driver.quit(); } }
Reportngtest2.java
package Testing_Pack; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.Assert; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; world aeroplane Reportngtest2 { WebDriver driver; @BeforeTest world void setup() throws Exception { driver =new FirefoxDriver(); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.get(" "); } @Test(priority=1) world void mul_Test() { driver.findElement(By.xpath("//input[@id='Resultbox']")).clear(); driver.findElement(By.xpath("//input[@id='5']")).click(); driver.findElement(By.xpath("//input[@id='multiply']")).click(); driver.findElement(By.xpath("//input[@id='4']")).click(); driver.findElement(By.xpath("//input[@id='equals']")).click(); String Result = driver.findElement(By.xpath("//input[@id='Resultbox']")).getAttribute("value"); int ResultInt = Integer.parseInt(Result); Assert.assertEquals(20, ResultInt); } @Test(priority=2) world void div_Test() { driver.findElement(By.xpath("//input[@id='Resultbox']")).clear(); driver.findElement(By.xpath("//input[@id='9']")).click(); driver.findElement(By.xpath("//input[@id='divide']")).click(); driver.findElement(By.xpath("//input[@id='3']")).click(); driver.findElement(By.xpath("//input[@id='equals']")).click(); String Result = driver.findElement(By.xpath("//input[@id='Resultbox']")).getAttribute("value"); int ResultInt = Integer.parseInt(Result); Assert.assertEquals(3, ResultInt); } @AfterTest world void Close() throws Exception { driver.quit(); } }
Now do testng.xml file nether your projection folder together with add together bellow laissez passer on configuration In It.
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > <suite name="ReportNG Suite" verbose="1"> <listeners> <listener class-name="org.uncommons.reportng.HTMLReporter"/> <listener class-name="org.uncommons.reportng.JUnitXMLReporter"/> </listeners> <test name="ReportNG1 Test" > <classes> <class name="Testing_Pack.Reportngtest1" /> </classes> </test> <test name="ReportNG2 Test" > <classes> <class name="Testing_Pack.Reportngtest2" /> </classes> </test> </suite>
Pink color Highlighted lines are responsible to generate ReportNG reports thence do non forget to Include them In your testng.xml file.
STEP v : Execute examination together with sentiment ReportNG reports
Now run your examination cases from testng.xml file. On completion of examination execution, refresh your projection folder. It volition create/update test-output folder. Explore that folder together with then explore html folder. You volition find index.html file Inside It. To open index.html file.
- Right click on index.html file -> Open With -> Web Browser.
It volition opened upward ReportNG HTML Interactive study equally shown In bellow Image.