Gain increased confidence in a thing we are delivering to an end user. Automated tests give us breadth, faster to execute, and can be ran any time we want.
Errors in Views, Models, DTOs Errors in client side/server side validation mismatch
If we split them, Selenium IDE records scripts Selenium webdriver code-first apprached
Test Code Test Framework WebDriver Library Browser Specific Driver Browser Web Server
"Follow the money" Focus on risk and legal implications
- Run application in debug mode
- Add a new class library and delete the default class file
- Right click on the Dependencies in the Solution explorer and select manage nuget packages
- Add following packages:
- xunit
- xunit.runner.visualstudio
- selenium.webdriver
- selenium.webdriver.chromedriver (when running locally ensure your browser version matches your chromedriver version)
- Add a new class to the project CreditCardApplicationShould.cs
- Import Xunit library
- Add first script:
[Fact]
[Trait("Category", "Smoke")]
public void LoadApplicationPage()
{
using (IWebDriver driver = new ChromeDriver())
{
driver.Navigate().GoToUrl(HomeUrl);
DemoHelper.Pause();
Assert.Equal(HomeTitle, driver.Title);
Assert.Equal(HomeUrl, driver.Url);
}
}
- Add following constants on the class level
private const string HomeUrl = "http://localhost:44108/";
private const string AboutUrl = "http://localhost:44108/Home/About";
private const string HomeTitle = "Home Page - Credit Cards";
- Add the DemoHelper class to the project
internal static class DemoHelper { ///// <summary> ///// Brief delay to slow down browser interactions for ///// demo video recording purposes ///// </summary> public static void Pause(int secondsToPause = 3000) { Thread.Sleep(secondsToPause); } }