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() { 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 ThenIShouldBeTakenToTheCompleteApplicationForm() { var applicationPage = new ApplicationPage(driver); ApplicationCompletePage applicationCompletePage = new ApplicationCompletePage(driver); 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("Internet", applicationCompletePage.BusinessSource); }
public void FixErrorsOnForm() { using (IWebDriver driver = new ChromeDriver(".")) { const string fname = "Divesh"; const string lname = "David"; const string flyerNumber = "1234-T"; const string age = "30"; const string invalidage = "17"; const string income = "100000"; const string status = "Single"; const string option = "Word of Mouth"; const string decision = "AutoAccepted"; var applicationPage = new ApplicationPage(driver); applicationPage.NavigateTo(); applicationPage.EnterFirstName(fname); //applicationPage.EnterLastName(lname); applicationPage.EnterFlyerNumber(flyerNumber); applicationPage.EnterAge(invalidage); applicationPage.EnterGrossAnnualIncome(income); applicationPage.EnterStatus(status); applicationPage.SelectOption(option); applicationPage.AcceptTerms(); applicationPage.SubmitForm(); 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); //find out validation errors /*var vaidationErrors = driver.FindElements(By.CssSelector(".validation-summary-errors > ul > li")); * Assert.Equal(2, vaidationErrors.Count); * Assert.Equal("Please provide a last name", vaidationErrors[0].Text); * Assert.Equal("You must be at least 18 years old", vaidationErrors[1].Text);*/ //fix validation errors applicationPage.EnterLastName(lname); applicationPage.clearAge(); applicationPage.EnterAge(age); ApplicationCompletePage applicationCompletePage = applicationPage.SubmitForm(); //Asserts applicationCompletePage.EnsurePageLoads(); } }
public void ShouldDeclineLowIncomes() { _applicationPage.EnterName("Sarah", "Smith"); DelayForDemoVideo(); _applicationPage.EnterFrequentFlyerNumber("012345-A"); DelayForDemoVideo(); _applicationPage.EnterAge("35"); DelayForDemoVideo(); _applicationPage.EnterGrossAnnualIncome("10000"); DelayForDemoVideo(); ApplicationCompletePage applicationCompletePage = _applicationPage.SubmitApplication(); Assert.Equal("Application Complete - CreditCards", applicationCompletePage.Driver.Title); Assert.Equal("AutoDeclined", applicationCompletePage.ApplicationDecision); }
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 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); } }
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 EnterValuesForForm() { using (IWebDriver driver = new ChromeDriver(".")) { const string fname = "Divesh"; const string lname = "David"; const string flyerNumber = "1234-T"; const string age = "30"; const string income = "100000"; const string status = "Single"; const string option = "Word of Mouth"; const string decision = "AutoAccepted"; var applicationPage = new ApplicationPage(driver); applicationPage.NavigateTo(); applicationPage.EnterFirstName(fname); applicationPage.EnterLastName(lname); applicationPage.EnterFlyerNumber(flyerNumber); applicationPage.EnterAge(age); applicationPage.EnterGrossAnnualIncome(income); applicationPage.EnterStatus(status); applicationPage.SelectOption(option); applicationPage.AcceptTerms(); applicationPage.SubmitForm(); var applicationCompletePage = new ApplicationCompletePage(driver); applicationCompletePage.EnsurePageLoads(); Assert.Equal(decision, applicationCompletePage.decision); Assert.NotEmpty(applicationCompletePage.referenceNumber); Assert.Equal($"{fname} {lname}", applicationCompletePage.fullName); Assert.Equal(age, applicationCompletePage.age); Assert.Equal(income, applicationCompletePage.income); Assert.Equal(status, applicationCompletePage.status); Assert.Equal(option, applicationCompletePage.source); //To View All Options in select /*foreach (IWebElement options in eachValue.Options ) * { * output.WriteLine($"Value:{options.GetAttribute("value")} Text:{options.Text}"); * * } * Assert.Equal("I'd Rather Not Say",eachValue.SelectedOption.Text); * Assert.Equal(5,eachValue.Options.Count); * //Selecting the option by value * eachValue.SelectByValue("Internet"); * DemoHelper.Pause(); * //Selecting the option by Text * eachValue.SelectByText("Word of Mouth"); * DemoHelper.Pause(); * //Selecting the option by Index * eachValue.SelectByIndex(4); * DemoHelper.Pause(); * driver.FindElement(By.Id("TermsAccepted")).Click(); * DemoHelper.Pause(); * //Submit by click * //driver.FindElement(By.Id("SubmitApplication")).Click(); * //Submit by function * //driver.FindElement(By.Id("Single")).Submit();*/ /* Assert.Equal("Application Complete - Credit Cards", driver.Title); * Assert.Equal("ReferredToHuman", driver.FindElement(By.Id("Decision")).Text); * Assert.NotEmpty(driver.FindElement(By.Id("ReferenceNumber")).Text); * Assert.Equal("Divesh David", driver.FindElement(By.Id("FullName")).Text); * Assert.Equal("30", driver.FindElement(By.Id("Age")).Text); * Assert.Equal("85000", driver.FindElement(By.Id("Income")).Text); * Assert.Equal("Single", driver.FindElement(By.Id("RelationshipStatus")).Text); * Assert.Equal("TV", driver.FindElement(By.Id("BusinessSource")).Text);*/ } }
public void WhenISubmitTheApplicationForm() { var applicationPage = new ApplicationPage(driver); ApplicationCompletePage applicationCompletePage = applicationPage.SumbitApplication(); }