No votes yet.
Please wait...

UI processes can be slow, contain bugs, and decelerate your work.

If a DB is constantly changed, it should be maintained.

Test configuration, bug fixing, and adjusting to software updates can become serious issues.

This article gives a useful overview of ways to execute UI automation with SpecFlow and C#.

SpecFlow

SpecFlow

Preliminary configuration of SpecFlow and Visual Studio

When you create a project, you should install a few NuGet packages manually.

This can be done by selecting Tools > NuGet Package Manager > Manager NuGet Package Manager for Solution.

A typical build should contain the following packages:

  1. Selenium. Support
  2. Specflow
  3. Specflow.Tools.MsBuild.Generation
  4. Xunit
  5. Xunit.core
  6. Xunit.runner.visualstudio

After this, you should launch the application by using automated processes.

You can launch code with the help of Chrome that goes to a required page and maximizes a screen to make a user see everything happening in the browser’s window so that tests can start on a proper web browser’s size.

An Example of a Test

An Example of a Test

The next stage is basic work with test scripts.

SpecFlow uses scripts instead of tests.

These test scripts are based on the Gherkin syntax where any test step starts with “if” or “else”.

Before taking the next steps, you need to learn how so-called locators work.

They are used to find certain elements that are shown on a web page.

Users won’t be able to interact properly with selected elements on pages without them.

The next groups can become the most popular locators used during your work:

public IWebElement ContactSection => Driver.FindElement(By.XPath(“.//div[@class=’row contact’]//div[@class=’col-sm-5′]”));
public IWebElement FormSection => ContactSection.FindElement(By.XPath(“//form”));
public IWebElement NameTextBox => FormSection.FindElement(By.Id(“name”));
public IWebElement EmailTextBox => FormSection.FindElement(By.Id(“email”));
public IWebElement PhoneTextBox => FormSection.FindElement(By.Id(“phone”));
public IWebElement SubjectTextBox => FormSection.FindElement(By.Id(“subject”));
public IWebElement MessageTextBox => FormSection.FindElement(By.Id(“description”));
public IWebElement SubmitButton => FormSection.FindElement(By.Id(“submitContact”));

Conclusion

These are only a few examples of the main steps that can be used for test automation.

But still, you should start with small actions before developing more complex steps.

You should operate some working tests and then increase work complexity until tests contain all required steps and tests.

Leave A Comment