Wednesday, May 20, 2020

How to install Jmeter in Window 10 ?

JMeter is a pure Java application and should run correctly on any system that has a compatible Java implementation.

Before installing Jmeter, we need to do some work.

1. First check your java version in command prompt by typing below command 

       java -version

2. If you don't have java in your system, you have to download java JDK

Because JMeter is pure Java desktop application, it requires a fully compliant JVM 6 or higher. You can download and install the latest version of Java SE Development Kit.

As of 20th May 2020, Java SE 14.0.1 is the latest release for the Java SE Platform


Do's

  • Install Java by right click and Run as administrator

  • Open CMD (command prompt)
  • Run the command javac to check java is installed properly

  • Run the command java -version to check the version


  • Unzip the file
  • Go to folder ..\apache-jmeter-5.3\bin
  • Click on Jmeter.bat


  • Jmeter is ready

Dont's

  • Do not install jdk without RIght Click Run as Administrator
  • Java will not properly installed
  • Jmeter will not work


Screenshot in Selenium

How to capture Screenshot in Selenium Web-driver (C#)

OVERVIEW

Selenium Web-Driver provides the capability to capture screenshots during a test execution. This ability is really important when you need to investigate different failures that occurred during the execution or in some cases to track the different stages of the run.

The capability to take a screenshot with selenium is extracted from the "ITakesScreenshot" interface that allowing us to take a screenshot of the current page displayed in the driver instance.

Taking screenshot of the entire screen (All Elements)

In the following test, we will log into a web-page and take screenshot of the entire page in .JPEG format. We can create screenshot class in common driver and can use in entire project. 

#region screenshots
        // Create a class of screenshot in common driver
        public class SaveScreenShotClass
        {
            public static string SaveScreenshot(IWebDriver driver, string ScreenShotFileName) // Definition
            {
               // Determines where do you going to save the screenshot

                var folderLocation = YourfolderLocation.ScreenshotPath;

                if (!System.IO.Directory.Exists(folderLocation))
                {
                    System.IO.Directory.CreateDirectory(folderLocation);
                }
                // This method will take the screenshot

                var screenShot = ((ITakesScreenshot)driver).GetScreenshot();

                var fileName = new StringBuilder(folderLocation);

                fileName.Append(ScreenShotFileName); // Determine the picture name

                //fileName.Append(DateTime.Now.ToString("_dd-MM-yyyy_mss"));  // Determine the                              picture name with date formate

                fileName.Append(DateTime.Now.ToString("dd-mm-yyyy_mss"));

                fileName.Append(".jpeg");  // Determine the format of the picture

                screenShot.SaveAsFile(fileName.ToString(), ScreenshotImageFormat.Jpeg); //

                return fileName.ToString();
            }
        }

        #endregion

     // Now we can use screenshot method in all project with the help of below code

    SaveScreenShotClass.SaveScreenshot(driver, "PictureName");

Friday, May 1, 2020

Extent Report

Extent Report:


Extent Reports are the most popular reporting used with Selenium. As we all know, TestNG generates html reports by default but they are not more readable and interactive, we have to put lots of efforts to make it attractive. TestNG has provided an ability to implement 'IReporter' an interface to customize TestNg report by users.

ExtentReport API makes our life easy to generate interactive report with simple configuartions. It supports almost all Java and .NET test frameworks such as TestNG, JUnit, NUnit etc.

Although the built-in reports provide information on the steps that are executed as part of the test case, they need more customization to be shared with all the major project stakeholders.

Extent Reports is a customizable HTML report developed by Anshoo Arora which can be integrated into Selenium WebDriver using JUnit and TestNG frameworks.

Extent Reports offer several advantages when compared to the built-in reports that are generated through JUnit and TestNG such as pie chart representation, test stepwise report generation, adding screenshots etc., at every test step and a presentable user interface that can be shared with all stakeholders of the project.



Advantages of using Extent Reports
There are several advantages of Extent Reports and few of them are discussed below.
  • Customisable HTML report with step-wise and pie chart representation.
  • Displays the time taken for test case execution within the report.
  • Each test step can be associated with a screenshot.
  • Multiple test case runs within a single suite can be tracked easily.
  • Can be easily integrated with TestNG and JUnit frameworks.


Using Extent Reports in Selenium Web-driver
Extent Reports contain two major classes that are used frequently.
  • Extent-Reports class
  • Extent-Test class
Syntax:

ExtentReports reports = new ExtentReports(“Path of directory to store the resultant HTML file”, true/false);


ExtentTest test = reports.startTest(“TestName”);

Extent Reports class is used to generate an HTML report on the user-specified path. The Boolean flag indicates if the existing report needs to be overwritten or a new report needs to be created. Value ‘true’ is the default value, which means all the existing data will be overwritten.



Extent Test class is used to log test steps onto the generated HTML report.

The above classes can be used with the frequently used built-in methods that are stated below.
  • Start-Test
  • End-Test
  • Log
  • flush


Start-Test and end-Test methods are used to execute preconditions and post-conditions of a test case, while log method is used to log the status of each test step onto the resultant HTML report. Flush method is used to erase any previous data on the report and create a new report.

Test Status can be any of the following values:
  • PASS
  • FAIL
  • SKIP
  • INFO


Syntax:

reports.endTest();
test.log(LogStatus.PASS,”Test Passed”);
test.log(LogStatus.FAIL,”Test Failed”);
test.log(LogStatus.SKIP,”Test Skipped”);
test.log(LogStatus.INFO,”Test Info”);

Log method takes in two parameters, the first parameter is the test status and the second parameter is the message to be printed onto the resultant report.




Featured Posts