{"id":6493,"date":"2020-11-04T15:30:16","date_gmt":"2020-11-04T10:00:16","guid":{"rendered":"https:\/\/www.h2kinfosys.com\/blog\/?p=6493"},"modified":"2020-12-15T17:43:13","modified_gmt":"2020-12-15T12:13:13","slug":"xslt-report-in-selenium-webdriver","status":"publish","type":"post","link":"https:\/\/www.h2kinfosys.com\/blog\/xslt-report-in-selenium-webdriver\/","title":{"rendered":"XSLT Report in Selenium Webdriver"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><strong>What is XSLT Report?<\/strong><\/h2>\n\n\n\n<p>The XSLT (XML Stylesheet Language for transformation) Report is a language that transforms one XML document into an XHTML document which is suitable for any browser for test reporting display. It is a very important feature in Selenium Framework which is used to develop the reporting system provided by TestNG. It generates the TestNG reports in a user-friendly way and the UI has more user-friendly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What is XSLT in Selenium?<\/strong><\/h2>\n\n\n\n<p>In Selenium XSLT is a language which transforms one<a href=\"https:\/\/en.wikipedia.org\/wiki\/XML\" rel=\"nofollow noopener\" target=\"_blank\"> XML document<\/a> into XHTML document. Using XSLT in XML files we can customize output files by adding and removing attributes that help in interpreting the results fast and is suitable for any browser for test reporting display.<\/p>\n\n\n\n<p>The most commonly used XSL element in the programming:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>&lt;xsl:if&gt;<\/strong>: This element will place a conditional test against the content of the XML file.<\/li><li><strong>&lt;xsl:template&gt;: <\/strong>This element&nbsp;is used to form templates.<\/li><li><strong>&lt;xsl:stylesheet&gt;&nbsp;<\/strong>It is an outermost element of a stylesheet. It defines the root element of the style sheet.<strong> <\/strong>It tells you that this document is an XSLT style sheet document.<\/li><li><strong>&lt;xsl:choose&gt;<\/strong>: It tests against the content of nodes used in conjunction with &lt;xsl: otherwise &gt; and &lt;xsl:when &gt; to specify multiple conditions<\/li><li><strong>&lt;xsl:apply-templates&gt;<\/strong>&nbsp;is used to apply template rule to the elements or the current element\u2019s child nodes.<\/li><\/ul>\n\n\n\n<ul class=\"wp-block-list\"><li>&nbsp;<strong>&lt;xsl:value-of&gt;: <\/strong>This element is used to extract the selected node value.<\/li><li><strong>&lt;xsl:for-each&gt;&nbsp;<\/strong>This element is used to select every XML element of a specified node-set.<\/li><li><strong>&lt;xsl:sort&gt;&nbsp;<\/strong>is used to sort the output.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Required Pre-requisite to generate XSLT reports<\/strong><\/h2>\n\n\n\n<ol class=\"wp-block-list\"><li>ANT build tool is needed to be installed to configure your project with the ANT build tool<\/li><li>XSLT Package downloaded inside the project folder<\/li><li>The <a href=\"https:\/\/www.h2kinfosys.com\/courses\/selenium-webdriver-junit-training-course\" class=\"rank-math-link\">Selenium <\/a>project must be executed with TestNG<\/li><\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>ANT set up in the Selenium project<\/strong><\/h2>\n\n\n\n<p>Below are the steps to set up ANT in your Selenium project. ANT is a Java build tool that is written in XML which is mainly used to compile the code.<\/p>\n\n\n\n<p><strong>STEP 1: DOWNLOAD THE ANT ZIP FILE<\/strong><\/p>\n\n\n\n<p>Go to the URL <a href=\"http:\/\/ant.apache.org\/bindownload.cgi\" rel=\"nofollow noopener\" target=\"_blank\">http:\/\/ant.apache.org\/bindownload.cgi<\/a> and download it from the current release version.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/4XTuDhyJn2dK9n4GVbyJnKqIyJAZGEvi4UKchNN5oYNOT3cs8hLjx4uUr9nvSQ4f9fF-g_w8LjbdMgWvdqxd5MiLKlwvuBxHC7paOBrJKJ0MZcKWYV26PeXmi12Qw_U3PR4ZcYQeVmDZYxANeg\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<p><strong>STEP 2: EXTRACT AND THE ANT FILE SET UP<\/strong><\/p>\n\n\n\n<p>Extract the zip file and set up its path.<\/p>\n\n\n\n<p>Right-click on My Computer&gt;Click Properties&gt;click on&nbsp;<strong>Advanced system settings&gt; <\/strong>Click<strong> on Environment Variables<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/w20QRtKD0Uxq2R02U3wzX8s2ttXoae0BZbqTZQV87hJamIUx8b00H20ACYvxJWn_hC6hEZbD2bC7MKQpQjjKbOh5gZeQ1fCks-u8MC2-LDqW7rKHArjjFVGpgqiJeyV0ZIFptdDVx9BZpzkghQ\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<p><strong>STEP 3: ENVIRONMENT VARIABLE SET UP<\/strong><\/p>\n\n\n\n<p>Click on&nbsp;<strong>Environment Variables <\/strong>to set up the environment variable<strong>.<\/strong>&nbsp;Click on the New button and enter the Variable name and Variable value as the path of Ant folder till bin.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/QZHzvwnoqrBq7nctYg9NLiYqpF6gWBAb_w5xuJ5nNksAiTsR9OWxIaIAlJYKPjrHGnunbpWJW2cASlEE8DgANLalGsyEjYMl9hCCBLC_ea5NQwI4yE8mLWkUjJ-BkL6rvLdFCMcI-SBhKGSl1g\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/1Fntf0MzYDxuV0bxia4EG3r64IE2zzwR7eyvHOYsN1qVERUYIJyRvHzVeYQFB3btq6UyqUYnxQIcRZGWcCLvyoD2i8KSom54-4d-QKzaendmA_ha5RFDZ2sOR0F6B81lgKwJkIajsYqY-V2QVw\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<p><strong>STEP 4: SYSTEM VARIABLE SET UP<\/strong><\/p>\n\n\n\n<p>Now set up the System variable. Click on New and add the bin path.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/A71MsddB-Ed1lNritTLqgdBlwFYLsO6Lqkkwc1M6SVKTQ6cbEV8fGoXFEtmQhOmlSUhJlCfGtiL_IAg-X4XtWRxNrcqtihl7MwGIKFzlKgZfnGEVGnbgNP7ySWfYZVOnC1KmWPwHIA3gvwgoZA\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<p><strong>STEP 5: VALIDATE BUILD ON CMD<\/strong><\/p>\n\n\n\n<p>Open CMD prompt and type command-&nbsp;<strong>ant<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Generate XSLT Report in Selenium<\/strong><\/h2>\n\n\n\n<p>In this scenario, we will use the Facebook site to generate the XSLT report<strong> <\/strong>in Selenium.<\/p>\n\n\n\n<p><strong>Scenario<\/strong>: In the following scenario you will automate and generate XSLT report&nbsp;<\/p>\n\n\n\n<p>Launch the web browser<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Open the Firefox browser and navigate to the &#8220;<a href=\"http:\/\/www.facebook.com\" rel=\"nofollow noopener\" target=\"_blank\">http:\/\/www.facebook.com\u201d<\/a><\/li><li>Login to the application<\/li><\/ul>\n\n\n\n<p>By using the below steps we will generate an XSLT report in <a href=\"https:\/\/www.h2kinfosys.com\/blog\/selenium-webdriver\/\">selenium Webdriver<\/a>&nbsp;<\/p>\n\n\n\n<p><strong>Step 1:<\/strong>&nbsp;Create and execute the Selenium script for the Facebook site.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import org.openqa.selenium.By;<br>import org.openqa.selenium.WebElement;<br>import org.openqa.selenium.chrome.ChromeDriver;<br>public class SeleniumTest {<br><br>&nbsp; &nbsp; &nbsp; &nbsp; public static void main(String[] args) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.setProperty(\"webdriver.chrome.driver\", \"F:\\\\drivers\\\\chromedriver.exe\");<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/create chrome instance<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; driver = new ChromeDriver();<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; driver.get(\"http:\/\/www.facebook.com\/\");<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WebElement element = driver.findElement(By.<em>xpath<\/em>(\"\/\/input[@name='email']\"));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; element.sendKeys(\"xxxx@gmail.com\");<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WebElement element = driver.findElement(By.<em>xpath<\/em>(\"\/\/input[@name='pass']\"));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; element.sendKeys(\"xxxx\");<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WebElement button = driver.findElement(By.<em>xpath<\/em>(\"\/\/input[@name='login']\"));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; button.click();<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; }<\/pre>\n\n\n\n<p><strong>Step 2:<\/strong>&nbsp;To download the XSLT report package go to the <a href=\"https:\/\/drive.google.com\/drive\/folders\/1nic2hXP6JYSEMJ-JXS4JBk4MU3VfUiX1\" rel=\"nofollow noopener\" target=\"_blank\">https:\/\/drive.google.com\/drive\/folders\/1nic2hXP6JYSEMJ-JXS4JBk4MU3VfUiX1<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/ZMJmJLHis6viqlUqwevzubQi-CPRRJkSEH1rmRiG8EsFxoUjCYDvbO0FEt3Mgob_qt6mA5CO8YluwsEnpKlTnnw6oIUOIbds0f3Cjvdz5SZ_2tqIzLS72fhedK58hFBCt_bsy2usHu5iPTtARA\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<p>Unzip the above-extracted XSLT Report folder you will find the below items:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>build.xml<\/li><li>testng-results.xsl<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/dSd-nJxcjjUaQ9GHXKsl6V7TVuj0947gOZs_Ij3cbxAP0QGoUPuDB-kt29YZz69ocSi5Sr9f1C2_zwnN7z0HJ6enCvSyMAroaOrME12DYSq2kGXQiMGFJvD37WW4YHHyKc8MeuGrVHU79ObC-Q\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>STEP 3: STORE THE FILE IN YOUR PROJECT<\/strong><\/h4>\n\n\n\n<p>Go to the directory of your project then inside your project folder store the extracted XSLT file.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/B2HGr0CFYaE-FAe35Y5CclXyhi1tGnnMf9aWNJ1rrXCMIfOac8kMi8WmXckxva5lm_Bm6OHcn_SkR-3yWtuYoWvBJhIqNZNT6_tFpqa-wbY5T4Nt7O333Gf-fN62pkeSyahjQ1HCbNjj7aUibQ\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<p>In Eclipse when you refresh your project folder you will see the XSLT files are added in the project.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/42isH0whBPtIoJ1MUzX5bt5VhNmZGEkEMRjTKFdnMwuEXQScwrifVd9CL7T_oGFlYUd6dd2pajKZfMvvKBpjuHJ3g77UDLZ9Ojwn1Iill421BUl93J9S5yd2-Xha267u1EyiTZRVnTOsfkzmBQ\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>GENERATION OF \u2018TESTNG-XSLT\u2019&nbsp;FOLDER IN THE PROJECT DIRECTORY<\/strong><\/h3>\n\n\n\n<p>In eclipse go to your project and right-click on build.xml and Run as Ant Build.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/ESZN-PV9nJSbrhfP9flg-ZXTpYZMUF3mIZiT1qNfm6C2U3ReJ_-z6Uitch_UC4_PdnkxdoXrmZFSI16xxfLQBsqmQb1knyaR-ka5hZwaHcuv9MJIjdINkPZzx-3w66Blwhtyuoh_khceCSyhUw\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<p>Then a new window opens. Now select option &#8216;generateReport&#8217;.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/7HixD9FpReEbuNHJQEOhBxmP1iAJqGq5l-XFKQ_AeYVJd7BOc55AVCfsjwvOrzT5qgAD_rdd9EcQA_u1jWRbNAaWB6swYj_3M5StkxYZwOmmb14V2Rgm0yGIGY6tR8NAxd4K1xJnWnA8bXIAeQ\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<p>Click on the Run button and it will generate the report.<\/p>\n\n\n\n<p>You will see the&nbsp;<strong>testng-xslt<\/strong>&nbsp;folder added to your project directory.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/GHLzMNor0vZDpY4R9W0yuKaDxjguLi5aXyBQPJjrxZxTLOG3G8WO8tmAt3fL_0CdonkLHT4vmvU9BANwiTA0tfv6DTGoGqnjljQwvk3by-EnMm3G7Rvb2NRM4BazVTvC5h0DRtQLmdPIguw4ow\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<p>Open this folder and click on the index.html file to see the report in your browser.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/fx-jE9tckuGFV5CmgFLR1Q49j5EhCxlhDkISP1vrrAQ91bFouffNqluv69HdZ1WivQgAFgTt6TCNXXuVoPjaBA2s2-A655d1Tv_Wv4tx2AW0EwXrMbydLNmx9Z-mJ_839taGU8e5mW7x2e6UOA\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<p>Run the index file and you will find the report which represents the test status more clearly.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/x-02JHWIDzsoqLqfYINwf-LHFM7DQd1iA_5kvqf_6_GppgMmDSYsLhHOk22yectWUkoELUZXhZWsdlx0tWM9ilgoGTAa0Gg7tiHS7eNry1wzLo5t2JqajHw3QkGAi6NwVkxszSQHU3CL-RrGDA\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusion:<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>It generates the TestNG reports in a user-friendly way and the UI has more user-friendly.<\/li><li>It stands for Extensible Stylesheet Language Transformations.<\/li><li>The XSLT (XML Stylesheet Language for transformation) Report is a language that transforms one XML document into an XHTML document which is suitable for any browser for test reporting display.<\/li><li>It is a very important feature in Selenium Framework which is used to develop the reporting system provided by TestNG.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.h2kinfosys.com\/courses\/selenium-webdriver-junit-training-course\"><img fetchpriority=\"high\" decoding=\"async\" width=\"728\" height=\"90\" src=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/11\/Selenium-Real-time-project-training-1.jpeg\" alt=\"Selenium Training with Live Project\" class=\"wp-image-6606\" title=\"\" srcset=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/11\/Selenium-Real-time-project-training-1.jpeg 728w, https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/11\/Selenium-Real-time-project-training-1-300x37.jpeg 300w\" sizes=\"(max-width: 728px) 100vw, 728px\" \/><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>What is XSLT Report? The XSLT (XML Stylesheet Language for transformation) Report is a language that transforms one XML document into an XHTML document which is suitable for any browser for test reporting display. It is a very important feature in Selenium Framework which is used to develop the reporting system provided by TestNG. It [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":6565,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[],"class_list":["post-6493","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-selenium-tutorials"],"_links":{"self":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/6493","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\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/comments?post=6493"}],"version-history":[{"count":0,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/6493\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/media\/6565"}],"wp:attachment":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/media?parent=6493"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/categories?post=6493"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/tags?post=6493"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}