Last active
September 20, 2021 06:56
-
-
Save bbrt3/e4fe08775f84f343933f7d21932d68c6 to your computer and use it in GitHub Desktop.
Selenium WebDriver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Xunit; | |
using OpenQA.Selenium; | |
using OpenQA.Selenium.Firefox; | |
namespace DemoWebApp.Tests | |
{ | |
public class LoanApplicationTests | |
{ | |
[Fact] | |
public void StartApplication() | |
{ | |
using (IWebDriver driver = new FirefoxDriver()) | |
{ | |
driver.Manage().Window.Maximize(); | |
driver.Navigate().GoToUrl("http://localhost:40077/"); | |
IWebElement applicationButton = driver.FindElement(By.Id("startApplication")); | |
applicationButton.Click(); | |
Assert.Equal("Start Loan Application - Loan Application", driver.Title); | |
} | |
} | |
[Fact] | |
public void SubmitApplication() | |
{ | |
using (IWebDriver driver = new FirefoxDriver()) | |
{ | |
driver.Manage().Window.Maximize(); | |
driver.Navigate().GoToUrl("http://localhost:40077/Home/StartLoanApplication"); | |
IWebElement firstNameInput = driver.FindElement(By.Id("FirstName")); | |
firstNameInput.SendKeys("Sarah"); | |
driver.FindElement(By.Id("LastName")).SendKeys("Smith"); | |
driver.FindElement(By.Id("Loan")).Click(); | |
driver.FindElement(By.Name("TermsAcceptance")).Click(); | |
driver.FindElement(By.CssSelector(".btn.btn-primary")).Click(); | |
IWebElement confirmationNameSpan = driver.FindElement(By.Id("firstName")); | |
string confirmationName = confirmationNameSpan.Text; | |
Assert.Equal("Sarah", confirmationName); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment