{"id":4005,"date":"2020-07-10T15:44:47","date_gmt":"2020-07-10T10:14:47","guid":{"rendered":"https:\/\/www.h2kinfosys.com\/blog\/?p=4005"},"modified":"2025-04-02T04:32:02","modified_gmt":"2025-04-02T08:32:02","slug":"testng-report-generation-in-selenium-webdriver","status":"publish","type":"post","link":"https:\/\/www.h2kinfosys.com\/blog\/testng-report-generation-in-selenium-webdriver\/","title":{"rendered":"TestNG Report Generation in Selenium WebDriver"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><strong>TestNG Reports:<\/strong><\/h2>\n\n\n\n<p>TestNG Reports come into picture when we execute the test cases using TestNG Report generation is very important when you perform Manual Testing and Automation Testing. By going through the result, you can easily identify how many test cases are passed, how many are failed and how many test cases are skipped.By looking at the result report, you will know the status of the project. <\/p>\n\n\n\n<p>Selenium WebDriver is used only for automation, but it won\u2019t generate any reports. In this situation, TestNG plays a crucial role right after executing test cases, automatically generating detailed default HTML reports. Enroll in an <a href=\"https:\/\/www.h2kinfosys.com\/courses\/selenium-automation-testing-certification-course\/\" data-type=\"link\" data-id=\"https:\/\/www.h2kinfosys.com\/courses\/selenium-automation-testing-certification-course\/\">Selenium certification<\/a> course to learn how to efficiently utilize Selenium and TestNG for comprehensive test automation setups.<\/p>\n\n\n\n<p>These reports provide an organized view of the test results, including information on passed, failed, and skipped test cases, making it easy for testers to quickly assess the status of their test suite. With TestNG\u2019s built-in reporting, you gain an at-a-glance overview of your test outcomes, allowing for efficient debugging and better overall test management without needing any additional configuration.<\/p>\n\n\n\n<p>Using 3 Methods we can generate the TestNG Reports:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>emailable-report.html<\/li>\n\n\n\n<li>index.html<\/li>\n\n\n\n<li>Reporter Class<\/li>\n<\/ol>\n\n\n\n<p><strong>Method 1:<\/strong> emailable-report.html<\/p>\n\n\n\n<p>Generally TestNG will generate default reports. You will get test-output folder when you execute testng.xml file and refresh the project. Right-click on emailable-report.html in test-output folder and select the option open with the web browser.<\/p>\n\n\n\n<p>Let us consider the below scenario which has three methods passTest, failTest and skipTest with @Test annotation.<\/p>\n\n\n\n<p><strong>Step 1:<\/strong> Launch the Eclipse<\/p>\n\n\n\n<p><strong>Step 2:<\/strong> Create a New Package<\/p>\n\n\n\n<p><strong>Step 3:<\/strong> Create a New Java Class \u201cEmailReport\u201d<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>package<\/strong> testngpackage;\n\n<strong>import<\/strong> org.testng.Assert;\n<strong>import<\/strong> org.testng.SkipException;\n<strong>import<\/strong> org.testng.annotations.Test;\n\n<strong>public<\/strong> <strong>class<\/strong> EmailReport {\n\/\/To make it pass\n@Test\n<strong>public<\/strong> <strong>void<\/strong> passTest(){\nAssert.<em>assertTrue<\/em>(<strong>true<\/strong>);\n}\n\/\/To make it fail\n@Test\n<strong>public<\/strong> <strong>void<\/strong> failTest(){\nAssert.<em>assertTrue<\/em>(<strong>false<\/strong>);\n}\n\/\/To make it skip\n@Test\n<strong>public<\/strong> <strong>void<\/strong> skipTest(){\n<strong>throw<\/strong> <strong>new<\/strong> SkipException(\"Skipping - This method is skipped testing \");\n}\n}<\/code><\/pre>\n\n\n\n<p><strong>Step 4:<\/strong> Create a TestNG.xml file<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?xml version=<em>\"1.0\"<\/em> encoding=<em>\"UTF-8\"<\/em>?&gt;\n&lt;!DOCTYPE suite SYSTEM \"http:\/\/testng.org\/testng-1.0.dtd\"&gt;\n&lt;suite name=<em>\"testngpackage\"<\/em> parallel=<em>\"methods\"<\/em>&gt;\n&lt;test name=<em>\"testngTest\"<\/em>&gt;\n&lt;classes&gt;\n&lt;class name=<em>\"testngpackage.EmailReport\"<\/em> \/&gt;\n&lt;\/classes&gt;\n&lt;\/test&gt;\n&lt;\/suite&gt;<\/code><\/pre>\n\n\n\n<p><strong>Step 5:<\/strong> Execute the testng.xml file and refresh the project. You can see your project as the below image.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/vA1GsjesAxRmGckuUgu_z_CKhGwpFXHSEC3igWGwim_yVdk6ccFYOX8yACXRTB6FK5n_HTpv6LWECzsdy-TFa_mBSHAxZt8EIDUzI7C3cgPMuia5ZZwLiQv2Z1aEgpHqNP-8zI5Y7ApfoI1bpg\" alt=\"testng.PNG\" title=\"\"><\/figure>\n\n\n\n<p>Expand \u2018test-output\u2019 folder and you should find a&nbsp;report \u201d<strong><em>emailable-report.html<\/em><\/strong>\u2018 which is the default report generated by TestNG.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/tn2dyI2PDHPYCkgICb7Ok9su4_VemswpsTjci4B-vHZcl0YlOGcUvQGpHfj0ZOI23aW794arlijV3FB2JF5_8rVs4dDC4172ZkLuwFtcEAPSiIBLOscTTdngXnkU4F5gzZPjzGhMrVAWKMSR4w\" alt=\"report.PNG\" title=\"\"><\/figure>\n\n\n\n<p>Step 6: Right-click on <strong><em>emailable -report.html<\/em><\/strong>&nbsp;and select <strong>open with<\/strong> and click on <strong>web browser<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/A8_4dCYjrjRigbLRoD7a2URC70B4jEGiYsgXNPndHQP2OaEmzwzmq__Fj9L715JcPTUIACFCsik69a8GvOAS_hm2hMN2w3DEyaexkmopqr8kyvgiEM6ecWNwQ2gu2xTypRP1Zi1Jk0yCWE1zlw\" alt=\"web.PNG\" title=\"\"><\/figure>\n\n\n\n<p>Report will be like as shown below:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/k-0RzXvhAlsAFTX2e0CCFsfjwtm2pzFJuUB4ANSJcuqXknreYUgnA-9XN2fGBeLE7LaeULetLhy7qhdSFeQ1BwG5vaQo_M-YrC5uu7u2VqxWzYOKxszFzdXl0jeSk0hl8DdnFN8KLBdXnptozQ\" alt=\"pic1.PNG\" title=\"\"><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/DroXDd3hAF00Y6Ovr-_Ceplakcf1p17tDvaQMyvpNYkB3ghUSXmvLtvx9maQYMVu0Bj7wzJaBKptK7kuwj6Pa5_WsyCL8FZmS8XTCIyw1Jbg1_nr864u8Ps2dU_q-cAWvY3FDLBtXCnHxLHF0Q\" alt=\"pic2.PNG\" title=\"\"><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Method 2: <\/strong>index.html<\/h3>\n\n\n\n<p>Expand \u2018test-output\u2019 folder and you find an option \u201d<strong><em><a href=\"https:\/\/en.wikipedia.org\/wiki\/Web_server_directory_index\" data-type=\"link\" data-id=\"https:\/\/en.wikipedia.org\/wiki\/Web_server_directory_index\" rel=\"nofollow noopener\" target=\"_blank\">index.html<\/a><\/em><\/strong>\u2018 which is the default report generated by TestNG.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/bxb6uN_0cFVzjqwE2VM_WEcQd4-TBNPOwq5Xxr6BPr2-7R28J_KBffdQjpyUD-qMrGnd9HgguQKON-WoBTW0dZ4dy-5YdBakwndExgVQqypyAIdne80T6wlZ0OMz9s_2SUWYO_T3zMKYeUz83Q\" alt=\"index.PNG\" title=\"\"><\/figure>\n\n\n\n<p>Right-click on <strong><em>index.html<\/em><\/strong>&nbsp;and select <strong>open with<\/strong> and click on <strong>web browser<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/566A6mnHfZJUslCEnWA9aAvVm4LpvXfFxuGpiLFovBwYo3STJDmy4Qtx8_WEg0bhxWD0oIazoGWofnt5UcS4oVAiMW4fL_VG349G0PrQegGdmnvhaq9-wiK-ufduLk672jICpAkdACzqCKTJiw\" alt=\"web1.PNG\" title=\"\"><\/figure>\n\n\n\n<p>Report will be like as shown below:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/X4qF2y2R843r2BhHn5ghv-1dqySbxWVgFNrFcOOjXIImE9LxLcGNMPVyOrsmJB51L8Ed--j4jydR4kKITupouTC34pJtttwLRf4_Ff_8_TPtMLMX6gJYopwUqZ11AUiB5KT-kiyEiPy42JvdDA\" alt=\"index1.PNG\" title=\"\"><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Method 3: <\/strong>Reporter Class<\/h3>\n\n\n\n<p>Along with the above two methods to generate reports, you can use the object.properties file to store the system-generated logs as well as user-generated logs. Using Reporter Class is one of the simplest ways to store log information in testing. <\/p>\n\n\n\n<p>Reporter class is an inbuilt class in TestNG. It helps in storing the logs inside the reports which are user-generated or system-generated so that in the future when we look at the report, we can directly view the logs from there instead of rerunning the test cases.<\/p>\n\n\n\n<p>Reporter is a class present in TestNG. It has four different methods to store log information:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Reporter.log(String s);<\/li>\n\n\n\n<li>Reporter.log(String s, Boolean logToStandardOut);<\/li>\n\n\n\n<li>Reporter.log(String s, int level);<\/li>\n\n\n\n<li>Reporter.log(String s, int level, Boolean logToStandardOut);<\/li>\n<\/ol>\n\n\n\n<p>Following syntax is used to use the reporter class<\/p>\n\n\n\n<p><strong><em>Reporter.log(string);<\/em><\/strong><\/p>\n\n\n\n<p>Simply we need to call the \u201c<strong><em>log<\/em><\/strong>\u201d function of the Reporter class of TestNG.<\/p>\n\n\n\n<p><strong>Example<\/strong><\/p>\n\n\n\n<p>Create a class as GoogleTest and write the following code inside the classes.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>package<\/strong> com.sampletestpackage;\n\n<strong>import<\/strong> org.openqa.selenium.WebDriver;\n<strong>import<\/strong> org.openqa.selenium.chrome.ChromeDriver;\n<strong>import<\/strong> org.testng.Reporter;\n\/\/import org.openqa.selenium.firefox.FirefoxDriver;\n\/\/import org.openqa.selenium.ie.InternetExplorerDriver;\n<strong>import<\/strong> org.testng.annotations.Test;\n\n<strong>public<\/strong> <strong>class<\/strong> GoogleTest {\n\nWebDriver driver;\n@Test(priority = 1)&nbsp;\n<strong>public<\/strong> <strong>void<\/strong> driverSetup()\n{&nbsp;\n\/\/ System.setProperty(\"webdriver.gecko.driver\", \"src\\\\main\\\\java\\\\com\\\\browserdrivers\\\\geckodriver.exe\");\nSystem.<em>setProperty<\/em>(\"webdriver.chrome.driver\", \"src\\\\main\\\\java\\\\com\\\\browserdrivers\\\\chromedriver.exe\");\n\/\/System.setProperty(\"webdriver.ie.driver\", \"src\\\\main\\\\java\\\\com\\\\browserdrivers\\\\IEDriverServer.exe\");\n\ndriver=<strong>new<\/strong> ChromeDriver();&nbsp;\nReporter.<em>log<\/em>(\"The browser is opened\");\n\n}&nbsp;\n@Test(priority = 2)&nbsp;\n<strong>public<\/strong> <strong>void<\/strong> getURL()\n{&nbsp;\n&nbsp; driver.get(\"https:\/\/www.google.com\");\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ System.out.println(\"Launching Google site\");&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Reporter.<em>log<\/em>(\"The Google Site is Launched\");\n\n}&nbsp;\n@Test(priority = 3)&nbsp;\n<strong>public<\/strong> <strong>void<\/strong> getTitle()\n{&nbsp;\n&nbsp; String title = driver.getTitle();&nbsp;\n&nbsp; System.<strong><em>out<\/em><\/strong>.println(title);&nbsp;\n&nbsp; &nbsp; &nbsp; Reporter.<em>log<\/em>(\"Prints the web page title\");\n\n&nbsp; }&nbsp;\n@Test(priority = 4)&nbsp;\n<strong>public<\/strong> <strong>void<\/strong> closeBrowser()\n{&nbsp;\n&nbsp; driver.close();&nbsp;\n&nbsp; \/\/System.out.println(\"Test successfully passed\");&nbsp;\n&nbsp; &nbsp; &nbsp; Reporter.<em>log<\/em>(\"Close the driver\");\n\n&nbsp; }&nbsp;\n\n}<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Now, Create testng.xml file by selecting the class and<\/li>\n\n\n\n<li>Select run as and<\/li>\n\n\n\n<li>Click on convert to Testng.<\/li>\n\n\n\n<li>Then run this testng.xml file by selecting run as and select Testng suite.<\/li>\n\n\n\n<li>Then refresh the project and open the test-output folder.<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>In the test-output folder and Right-click on open the emailable-report.html. It will look like:<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/05WQeOvvAnIkmVJWvDXJvsQAICMEcaJSjK_mIV4E-3V6_vkIf08QKKlvra1t6G8trW380kB6V1iGrHW4pMfzkta1XNSxP4eUKO4O7YInLQExy0zNgtU5JWjjiA57S6dUbv7p20jx7UvclSlYiw\" alt=\"email.PNG\" title=\"\"><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/tsEoUWw9F0pzIgehO9VxIfq5NFvHRksmSJUJpLePzbZ0724TDN26kifWENljN7B0KRgw94y1RaLfrqp66oLCkd9T_6mBlxWcOopzzcqjHKo1O61CSpFKFgq-I2KIM7FG33Y6ToppBwS4bFUOZA\" alt=\"email1.PNG\" title=\"\"><\/figure>\n\n\n\n<p>2. In test-output folder, Right-click on <strong><em>index.html<\/em><\/strong>&nbsp;and select <strong>open with<\/strong> and click on <strong>web browser<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/2HMS_3uvbxYV8Mrcn3GE7dLQl60JtJCZw_S_EAV1ymfzK4csq2FCD8fJfTf71mHkUQNk5eGjiEZ8rYAQlgS4ur8YclI21EIpkFiYeI6eAR7OTf0deC6IONp4yqT5tqTJha2nkzb-fpsFFLoFSA\" alt=\"index2.PNG\" title=\"\"><\/figure>\n\n\n\n<p>Click on<strong> Reporter output<\/strong>. It will open logging information that is written in the test methods.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/MNH0U7chy3N82ALMlXnxRg8Vd8m3c8IJGQ6JH-DKlSpIMJNBy5pF09nxPZT9Ed9xJ1tGFqSwAdA8PitkmQSA4VAUy3l6w8isG0MaEIXQ4iDUW8nzuc6uNFbHUr5XYeIFj4OmluaiRSmy4ZAeNQ\" alt=\"index3.PNG\" title=\"\"><\/figure>\n\n\n\n<p>Click on <strong>\u201cTimes\u201d. <\/strong>It will show how much time it took to run the test method present in class.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/q_KdRzyZkVCjb5udNinG18C726HfFS8Uk35muRWfHq9ChcrkPi2paGqqpaTgalatQ2NeoR2F4w2_5bRNhum4HTxhjEMTcDnH_0VUb3yJCejg6-nIhU-RptCfUJZD-YIlpcpRbwCyr-nNt0fWNA\" alt=\"index4.PNG\" title=\"\"><\/figure>\n\n\n\n<p><strong>Generating Allure Reports using TestNG in Selenium Automation<\/strong><\/p>\n\n\n\n<p>Following are the steps to generate Allure Reports using TestNG<\/p>\n\n\n\n<p><strong>Step1:<\/strong> Create a New Maven project and Update pom.xml with required dependencies from <a href=\"https:\/\/mvnrepository.com\/\" rel=\"nofollow noopener\" target=\"_blank\">https:\/\/mvnrepository.com\/<\/a><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>TestNG<\/li>\n\n\n\n<li>Selenium Java<\/li>\n\n\n\n<li>Webdrivermanager<\/li>\n\n\n\n<li>Allure-TestNG<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>TestNG Dependencies<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!-- https:\/\/mvnrepository.com\/artifact\/org.testng\/testng --&gt;\n&lt;dependency&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;groupId&gt;org.testng&lt;\/groupId&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;artifactId&gt;testng&lt;\/artifactId&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;version&gt;7.1.0&lt;\/version&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;scope&gt;test&lt;\/scope&gt;\n&lt;\/dependency&gt;\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Selenium Java<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!-- https:\/\/mvnrepository.com\/artifact\/org.seleniumhq.selenium\/selenium-java --&gt;\n&lt;dependency&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;groupId&gt;org.seleniumhq.selenium&lt;\/groupId&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;artifactId&gt;selenium-java&lt;\/artifactId&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;version&gt;4.0.0-alpha-6&lt;\/version&gt;\n&lt;\/dependency&gt;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Webdrivermanager<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!-- https:\/\/mvnrepository.com\/artifact\/io.github.bonigarcia\/webdrivermanager --&gt;\n&lt;dependency&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;groupId&gt;io.github.bonigarcia&lt;\/groupId&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;artifactId&gt;webdrivermanager&lt;\/artifactId&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;version&gt;4.0.0&lt;\/version&gt;\n&lt;\/dependency&gt;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Allure-TestNG<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!-- https:\/\/mvnrepository.com\/artifact\/io.qameta.allure\/allure-testng --&gt;\n&lt;dependency&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;groupId&gt;io.qameta.allure&lt;\/groupId&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;artifactId&gt;allure-testng&lt;\/artifactId&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;version&gt;2.13.3&lt;\/version&gt;\n&lt;\/dependency&gt;<\/code><\/pre>\n\n\n\n<p><strong>Step2:<\/strong> Download Maven and Allure Binaries then set the path<\/p>\n\n\n\n<p>Go to <a href=\"https:\/\/maven.apache.org\/download.cgi\" rel=\"nofollow noopener\" target=\"_blank\">https:\/\/maven.apache.org\/download.cgi<\/a>&nbsp; and download and extract the zip folder (apache-maven-3.6.3-bin.zip)<\/p>\n\n\n\n<p>Click on Extracted folder and go to bin folder and copy the path and set the maven path in environment variables<\/p>\n\n\n\n<p>Right-click on My PC-&gt;Properties -&gt; Click Advance System Settings -&gt; Click Environment Variables &#8211; &gt; Click Path under System Variables and click Edit -&gt; Click New and paste the path <strong>C:\\apache-maven-3.6.3\\bin<\/strong><\/p>\n\n\n\n<p>To check whether maven is configured or not, go to the command prompt and type the command <strong>mvn &#8211;version<\/strong>.<\/p>\n\n\n\n<p>To download Allure Binaries go to <a href=\"https:\/\/docs.qameta.io\/allure\/#_installing_a_commandline\" rel=\"nofollow noopener\" target=\"_blank\">https:\/\/docs.qameta.io\/allure\/#_installing_a_commandline<\/a> and click Maven Central under Manual Installation and download the latest version <strong>2.13.0<\/strong> and click on the ZIP folder <strong>allure.commandline-2.13.0.zip<\/strong><\/p>\n\n\n\n<p>Click on Extracted folder and go to bin folder and copy the path and set the path in environment variables.<\/p>\n\n\n\n<p>Right-click on My PC-&gt;Properties -&gt; Click Advance System Settings -&gt; Click Environment Variables &#8211; &gt; Click Path under System Variables and click Edit -&gt; Click New and paste the path <strong>C:\\allure-2.13.0\\bin<\/strong><\/p>\n\n\n\n<p>To check whether Allure is configured or not, go to the command prompt and type the command <strong>&nbsp;allure &#8211;version.<\/strong><\/p>\n\n\n\n<p><strong>Step3:<\/strong> Create TestNG Test Cases and run through TestNG.XML<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create a New Package <strong>(allureReports)<\/strong><\/li>\n\n\n\n<li><strong>C<\/strong>reate a New Class <strong>(Tests)<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>Package allureReports;\n\n<strong>import<\/strong> java.util.concurrent.TimeUnit;\n<strong>import<\/strong> org.openqa.selenium.By;\n<strong>import<\/strong> org.openqa.selenium.WebDriver;\n<strong>import<\/strong> org.openqa.selenium.chrome.ChromeDriver;\n<strong>import<\/strong> org.testng.Assert;\n<strong>import<\/strong> org.testng.SkipException;\n<strong>import<\/strong> org.testng.annotations.AfterClass;\n<strong>import<\/strong> org.testng.annotations.BeforeClass;\n<strong>import<\/strong> org.testng.annotations.Test;\n<strong>import<\/strong> io.github.bonigarcia.wdm.WebDriverManager;\n\nPublic <strong>class<\/strong> Tests {\nWebDriver driver;\n@BeforeClass\nPublic <strong>void<\/strong> setup()\n{\nWebDriverManager.chromedriver().setup();\ndriver = <strong>new<\/strong>&nbsp; ChromeDriver();\ndriver.manage().timeouts.implicitywait(10,TimeUnit.SECONDS);\n\ndriver.get(\u201chttps:\/\/demo.nopcommerce.com\/\u201d);\ndriver.manage().window().maximize();\n}\n@Test(priority=1)\nPublic <strong>void<\/strong> logoPresence()\n{\nBoolean disstatus = driver.findElement(By.xpath(\u201c\/\/div&#91;@class=\u2019header-logo\u2019]\/\/a\/\/img\u201d)).isDisplayed();\nAssert.assertEquals(disstatus, <strong>true<\/strong>);\n}\n@Test(priority=2)\nPublic <strong>void<\/strong> loginTest()\n{\ndriver.findElement(By.linkText(\u201cLog in\u201d)).click();\ndriver.findElement(By.id(\u201cEmail\u201d)).sendKeys(\u201cxxxabc@gmail.com\u201d);\ndriver.findElement(By.id(\u201cPassword\u201d)).sendKeys(\u201cxxxabc\u201d);\ndriver.findElement(By.xpath(\u201c\/\/input&#91;@class=\u2019button-1 login-button\u2019]\u201d)).click();\nAssert.assertEquals(driver.getTitle(), \u201cnopCommerce demo store\u201d);\n\n\n}\n@AfterClass\nPublic <strong>void<\/strong> teardown()\n{\ndriver.quit();\n}\n}<\/code><\/pre>\n\n\n\n<p><strong>Step4:<\/strong> Create a TestNG.xml&nbsp; file<\/p>\n\n\n\n<p>Right-click on your Testcase(Tests)- &gt;Go to TestNG-&gt; Click Convert to TestNG and click Finish<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?xml&nbsp; version \u201c1.0\u201d encoding-\u201cUTF-8\u201d?&gt;\n&lt;!DOCTYPE suite SYSTEM <a href=\"http:\/\/testng.org\/testng-1.0.dtd\" rel=\"nofollow noopener\" target=\"_blank\">http:\/\/testng.org\/testng-1.0.dtd<\/a>&gt;\n&lt;suite name = \u201cSuite\u201d&gt;\n&lt;test thread-count=\u201d2\u201d name=\u201dTest\u201d\/&gt;\n&lt;classes&gt;\n&lt;class name = \u201callureReports.Tests\u201d\/&gt;\n&lt;\/classes&gt;\n&lt;\/test&gt; &lt;!- - Test- - &gt;\n&lt;\/suite&gt; &lt;!- - Suite - - &gt;<\/code><\/pre>\n\n\n\n<p>Right-click on TestNG.xml file -&gt;Run As-&gt;TestNg Suite<\/p>\n\n\n\n<p>Refresh your project and you can see a new folder allure results. Expand the allure results and you can see json files. To see the allure reports which are generated for test case through TestNG.xml we need to run a command <strong>allure serve<\/strong><\/p>\n\n\n\n<p><strong>Right-click on allure results folder &#8211; &gt; Go to Properties &#8211; &gt; Copy the Location<\/strong><\/p>\n\n\n\n<p>Open Command prompt and type the command<\/p>\n\n\n\n<p><strong>Allure serve C:\\Users\\admin\\eclipse-workspace\\AllureReporting\\allure-results.<\/strong><\/p>\n\n\n\n<p>It will automatically generate the Allure Reports.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>In conclusion, TestNG report generation in Selenium WebDriver is a valuable tool for enhancing the testing process. By providing detailed insights into test execution, including passed, failed, and skipped tests, TestNG reports make it easier to analyze results and identify areas that need improvement. The ability to customize reports, add screenshots, and generate logs ensures that testers have a comprehensive view of test outcomes, which is essential for maintaining high-quality applications. <\/p>\n\n\n\n<p>Implementing <a href=\"https:\/\/www.h2kinfosys.com\/blog\/testng-tutorial\/\" data-type=\"link\" data-id=\"https:\/\/www.h2kinfosys.com\/blog\/testng-tutorial\/\">TestNG<\/a> with Selenium WebDriver greatly enhances the efficiency of your testing process by allowing you to manage, group, and execute test cases with ease. TestNG\u2019s powerful features, such as parallel execution, parameterization, and detailed reporting, enable a more organized and systematic approach to testing. <\/p>\n\n\n\n<p>This structured setup not only saves time but also helps teams maintain a clear view of testing progress and results, making it easier to share insights and collaborate effectively. By integrating TestNG, you create a more reliable and scalable automation framework, turning it into an essential tool for quality-focused testing teams.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Call to Action<\/h2>\n\n\n\n<p>Ready to take your Selenium testing to the next level? Learn how to generate and customize detailed TestNG reports with H2K Infosys! Our expert-led courses will guide you through the essentials of TestNG report generation, helping you gain insights into test outcomes, improve debugging, and streamline your automation process. Enhance your skills and boost your career with hands-on experience in Selenium WebDriver and TestNG. Join H2K Infosys today and become a proficient automation tester!<\/p>\n\n\n\n<p>With TestNG report generation, you\u2019ll gain a clear view of your test results, making it easy to track performance and identify issues quickly. By mastering TestNG with Selenium WebDriver, you can enhance the quality and reliability of your tests, ensuring that every test run is accurately documented and actionable.<br><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>TestNG Reports: TestNG Reports come into picture when we execute the test cases using TestNG Report generation is very important when you perform Manual Testing and Automation Testing. By going through the result, you can easily identify how many test cases are passed, how many are failed and how many test cases are skipped.By looking [&hellip;]<\/p>\n","protected":false},"author":16,"featured_media":4027,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[156,1099,448,974,1098],"class_list":["post-4005","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-selenium-tutorials","tag-automation-testing","tag-report-generation","tag-selenium-webdriver","tag-testng","tag-testng-reports"],"_links":{"self":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/4005","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/comments?post=4005"}],"version-history":[{"count":0,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/4005\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/media\/4027"}],"wp:attachment":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/media?parent=4005"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/categories?post=4005"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/tags?post=4005"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}