Esempio n. 1
0
        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();
            }
        }
Esempio n. 3
0
        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();
            }
        }
Esempio n. 4
0
        public void GivenIEnterMyMaritalStatusAsSingle()
        {
            var applicationPage = new ApplicationPage(driver);

            applicationPage.ChooseMaritalStatusSingle();
        }