Make Money Online AUTOMATION Creating automated UI test using Selenium/Visual Studio 2019 (c#) tutorial

Creating automated UI test using Selenium/Visual Studio 2019 (c#) tutorial

Creating automated UI test using Selenium/Visual Studio 2019 (c#) tutorial post thumbnail image



This video is a step by step guide on how to create an automated UI test using Selenium/Visual Studio 2019 (c#).

Visual Studio 2019 can be downloaded from Microsoft

NuGet packages used:
Selenium.WebDriver
Selenium.WebDriver.ChromeDriver

To save you time, the snippet below contains the code of the project:
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System.Threading;

namespace GoogleUITest
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestSearchStreetFighterVThenVerifyStreetFighterVIsDisplayed()
{
int waitingTime = 2000;
By googleSearchBar = By.Name(“q”);
By googleSearchButton = By.Name(“btnK”);
By googleResultText = By.XPath(“.//h2//span[text()=’Street Fighter V’]”);
By googleIAgreeButton = By.Id(“L2AGLb”);

IWebDriver webDriver = new ChromeDriver();

Thread.Sleep(waitingTime);

webDriver.Navigate().GoToUrl(”

Thread.Sleep(waitingTime);

webDriver.FindElement(googleIAgreeButton).Click();

webDriver.Manage().Window.Maximize();

Thread.Sleep(waitingTime);

webDriver.FindElement(googleSearchBar).SendKeys(“Street Fighter V”);

Thread.Sleep(waitingTime);

webDriver.FindElement(googleSearchButton).Click();

Thread.Sleep(waitingTime);

var actualResultText = webDriver.FindElement(googleResultText);

Assert.IsTrue(actualResultText.Text.Equals(“Street Fighter V”));

webDriver.Quit();
}
}
}

Related Post