Showing posts with label VS2019. Show all posts
Showing posts with label VS2019. Show all posts

Wednesday, May 27, 2020

Cucumber Selenium test automation framework using C# - Part 8 - Attaching Screenshots to the report

Prerequisites


Please complete Part 7 of this tutorial before continuing.

Adding screenshots to test report using Extent Reports


1) In order to maintain multiple screenshots before adding them to the report, we need to add a public class in Utility package and name it as StepImageContext and add the following content to it.

public string StepInformation { get; set; }
public string ScreenshotPathWithName { get; set; }


2) We need to have a method to capture screenshot and save in given location and another method to add screenshots with step information into the instance of StepImageContext list. Add these two methods as given below.

3) After adding above methods, navigate to Hooks.cs class and create a method to add screenshots to log. We need to check if StepImageContext instance is empty. Attaching screenshot to log should be available only if at least one screenshot is added. Also create another method to add screenshot to the log when there is a failure.

4) Next step is to call the screenshot capture method (LogInfoWithScreenshot) to all the places step information is added as given below. Do not add this method to Step definition pending section.

5) At the end of the AfterStep() method, clear the current scenario context.

6) Once you complete that, define an object of StepImageContext and add screenshots as required. A sample is shown below. Make sure to add screenshots for each step.

6) Rebuild the code and execute the test. In the report you should see added screenshots.

Monday, March 16, 2020

Installing Visual Studio Community Edition on Windows 10

1) Click on the following link.

2) Select Free Download button under Community. (Latest version at the time of writing this article)


3) Once .exe file is downloaded, run the file. Complete the steps as prompted. Then in the following screen, select the required packages to install. (ASP.NET and web development and .NET desktop development are preferred)


4) In the next screen, click on "install" button to continue.


5) Once installation is complete, launch Visual Studio 2019 Community Edition by clicking Visual Studio 2019 from start menu