Monday, 3 February 2014

Generating HTML result file using Selenium Webdriver


1.       Generate HTML Result file:

Reports are really worth to show the client, what we are doing, what we executed, Steps fail, Steps passed…etc.
   Selenium does not have any capability to do generate HTML result file, we can generate up to some extent HTML results file using the ANT Framework, but still those results are not descriptive ,To generate user friendly and clear cut results we should have some mechanism to generate the html results.

Below post can give you a good basic information about your test execution results:

STEPS TO FOLLOW:


1.      Add the ‘testUtils.pro jar’ (I will provide the .Jar file ) file to your project class path,Download the jar file from https://drive.google.com/file/d/0B9ZTXXKTZAYVUjhRYnNpRFV0aDA/view?usp=sharing



2.      Import the following class in your Test.java file
  Import com.webdriver.framework.*;

3.      Create an  object for GenerateResult Class
       
4.      Add a step to generate result file
       
Note: Here is will create a result file with the parameter you passed, appended with timestamp.

Example Result file screen shot:

5.     Now write your step like this                   
                           

                     
6.        Put all your test case steps into try-catch block as below :






7.      Now  Run your scripts, and look into you workspace folder, there will be new folder created with the name ‘Results’ to store the html results file, and another file named as ‘Screenshots’ will be create at the same location, to take the screenshots of the application for the failed test cases.



Sample Result file:
If Passed:
   


If Failed:
                        


5 comments:

  1. Hi
    I have tried the above steps to generate result, its working properly and results with screenshot for failed tests are generating properly.

    i am facing only only one problem , that is when on the test result html when i am clicking on the "Click here for error screenshot" link its redirecting to a blank page though proper screenshot has been generated under screenshot folder.

    can u tell me how to fix this problem .

    i am using java testng framework and eclipse as editor.

    ReplyDelete
  2. even i am facing same issue as per neil

    ReplyDelete
  3. Hi Neil and Raghavendara,Please try open with Fire Fox,There are some known issues with IE

    ReplyDelete
  4. Hi Neil,Do you able to open the result file with firefox?

    ReplyDelete