public void ShouldValidateApplicationDetails() { _applicationPage.EnterName("", "Smith"); _applicationPage.EnterFrequentFlyerNumber("012345-A"); _applicationPage.EnterAge("20"); _applicationPage.EnterGrossAnnualIncome("100000"); _applicationPage.SubmitApplication(); Assert.Equal("Credit Card Application - CreditCards", _applicationPage.Driver.Title); Assert.Equal("Please provide a first name", _applicationPage.FirstErrorMessage); }
public void BeSubmittedWhenValid() { const string FirstName = "Sarah"; const string LastName = "Smith"; const string Number = "123456-A"; const string Age = "18"; const string Income = "50000"; using (IWebDriver driver = new ChromeDriver()) { var applicationPage = new ApplicationPage(driver); applicationPage.NavigateTo(); applicationPage.EnterFirstName(FirstName); applicationPage.EnterLastName(LastName); applicationPage.EnterFrequentFlyerNumber(Number); applicationPage.EnterAge(Age); applicationPage.EnterGrossAnnualIncome(Income); applicationPage.ChooseMaritalStatusSingle(); applicationPage.ChooseBusinessSourceTV(); applicationPage.AcceptTerms(); ApplicationCompletePage applicationCompletePage = applicationPage.SubmitApplication(); applicationCompletePage.EnsurePageLoaded(); Assert.Equal("ReferredToHuman", applicationCompletePage.Decision); Assert.NotEmpty(applicationCompletePage.ReferenceNumber); Assert.Equal($"{FirstName} {LastName}", applicationCompletePage.FullName); Assert.Equal(Age, applicationCompletePage.Age); Assert.Equal(Income, applicationCompletePage.Income); Assert.Equal("Single", applicationCompletePage.RelationshipStatus); Assert.Equal("TV", applicationCompletePage.BusinessSource); } }
public void BeSubmittedWhenValidationErrorsCorrected() { const string firstName = "Sarah"; const string invalidAge = "17"; const string validAge = "18"; using (IWebDriver driver = new FirefoxDriver()) { ApplicationPage applicationPage = new ApplicationPage(driver); applicationPage.NavigateTo(driver); applicationPage.EnterFirstName(firstName); // Don't enter lastname applicationPage.EnterFrequentFlyerNumber("45556"); applicationPage.EnterAge(invalidAge); applicationPage.EnterGrossIncome("10000"); applicationPage.ChooseMaritalStatus("Single"); applicationPage.ChooseBusinessSource("Internet Search"); applicationPage.AcceptTermsAndConditions(); applicationPage.SubmitApplication(); // Assert that validation failed Assert.Equal(2, applicationPage.ValidationMessages.Count); Assert.Equal("Please provide a last name", applicationPage.ValidationMessages[0].ToString()); Assert.Equal("You must be at least 18 years old", applicationPage.ValidationMessages[1].ToString()); // Fix errors applicationPage.EnterLastName("Parker"); applicationPage.ClearAge(); applicationPage.EnterAge(validAge); driver.FindElement(By.Id("Age")).SendKeys(validAge); // Resubmit form ApplicationCompletePage applicationCompletePage = applicationPage.SubmitApplication(); // Check form submitted applicationCompletePage.EnsurePageLoaded(); Assert.Equal("Sarah Parker", applicationCompletePage.fullName); } }
public void BeSubmittedWhenValidationErrorsCorrected() { const string firstName = "Sarah"; const string invalidAge = "17"; const string validAge = "18"; using (IWebDriver driver = new ChromeDriver()) { var applicationPage = new ApplicationPage(driver); applicationPage.NavigateTo(); applicationPage.EnterFirstName(firstName); // Don't enter lastname applicationPage.EnterFrequentFlyerNumber("123456-A"); applicationPage.EnterAge(invalidAge); applicationPage.EnterGrossAnnualIncome("50000"); applicationPage.ChooseMaritalStatusSingle(); applicationPage.ChooseBusinessSourceTV(); applicationPage.AcceptTerms(); applicationPage.SubmitApplication(); // Assert that validation failed Assert.Equal(2, applicationPage.ValidationErrorMessages.Count); Assert.Contains("Please provide a last name", applicationPage.ValidationErrorMessages); Assert.Contains("You must be at least 18 years old", applicationPage.ValidationErrorMessages); // Fix errors applicationPage.EnterLastName("Smith"); applicationPage.ClearAge(); applicationPage.EnterAge(validAge); // Resubmit form ApplicationCompletePage applicationCompletePage = applicationPage.SubmitApplication(); // Check form submitted applicationCompletePage.EnsurePageLoaded(); } }
public void BeSubmittedWhenValid() { using (IWebDriver driver = new FirefoxDriver()) { ApplicationPage applicationPage = new ApplicationPage(driver); applicationPage.NavigateTo(driver); applicationPage.EnterFirstName("Sarah"); applicationPage.EnterLastName("Parker"); applicationPage.EnterFrequentFlyerNumber("45556"); applicationPage.EnterAge("20"); applicationPage.EnterGrossIncome("10000"); applicationPage.ChooseMaritalStatus("Single"); applicationPage.ChooseBusinessSource("Internet Search"); applicationPage.AcceptTermsAndConditions(); ApplicationCompletePage applicationCompletePage = applicationPage.SubmitApplication(); //check we are on the Complete application page applicationCompletePage.EnsurePageLoaded(); //verify the data we entered Assert.Equal("Sarah Parker", applicationCompletePage.fullName); } }