public void BeSubmittedWhenValidationErrorsCorrected() { using (IWebDriver driver = new ChromeDriver()) { const string firstName = "Rashiid"; const string lastName = "Jama"; const string invalidAge = "17"; const string validAge = "23"; const string number = "123456-A"; const string income = "50000"; var applicationPage = new ApplicationPage(driver); applicationPage.NavigateTo(); applicationPage.EnterFirstName(firstName); // Not entering last name applicationPage.EnterFrequentFlyerNumber(number); applicationPage.EnterAge(invalidAge); applicationPage.EnterGrossAnnualIncome(income); applicationPage.ChooseMaritalStatusSingle(); applicationPage.ChooseBusinessSourceIntenet(); applicationPage.ClickAcceptTerms(); applicationPage.SumbitApplication(); // Asserting 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(lastName); applicationPage.ClearAge(); applicationPage.EnterAge(validAge); // Resubmit form ApplicationCompletePage applicationCompletePage = applicationPage.SumbitApplication(); //applicationCompletePage.EnsurePageLoaded(); } }
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 ThenIRemoveTheEnteredAge() { var applicationPage = new ApplicationPage(driver); applicationPage.ClearAge(); }