コード例 #1
0
        public void CheckValidationForCompany()
        {
            productsPage     = new ProductsPage(CmdDriver.Driver);
            yourOrderPage    = new YourOrderPage(CmdDriver.Driver);
            contactInfoPage  = new ContactInfoPage(CmdDriver.Driver);
            orderSummaryPage = new OrderSummaryPage(CmdDriver.Driver);

            extentReportUtils.createATestCase("Check validation for company");
            extentReportUtils.addTestLog(Status.Info, "CheckValidationForCompany");

            productsPage.ClickAcceptAllCookies();

            // Click on Buy Now button per Product name
            productsPage.ClickBuyNowButtonByProductName(ProductsEnum.DEVCRAFT_UI);

            //yourOrderPage.ClickAcceptAllCookies();

            // Assert there is at least one product at the page
            Assert.AreEqual(1, yourOrderPage.GetProductsCountFromPage());

            // Navigate user to the next page - Contact Info Page
            yourOrderPage.ClickContinueButton();

            contactInfoPage.ClickAcceptAllCookies();

            ContactInfo contactInfo = new ContactInfo();

            // Fill Billing Information
            contactInfoPage.SetFirstName(contactInfo.FirstName);
            contactInfoPage.SetLastName(contactInfo.LastName);
            contactInfoPage.SetEmail(contactInfo.Email);
            contactInfoPage.SetPhone(contactInfo.PhoneNumber);
            contactInfoPage.SetAddress(contactInfo.Address.Street);
            contactInfoPage.SetCountry(contactInfo.Address.Country);
            contactInfoPage.SetCity(contactInfo.Address.City);
            contactInfoPage.SetZipCode(contactInfo.Address.ZipCode);
            contactInfoPage.SetState("New Jersey");

            // Click 'Continue' button
            contactInfoPage.ClickContinueButton();

            // Assert email error message about required field
            Assert.AreEqual("Company is required", contactInfoPage.GetErrorMessageForCompany());

            // Set email with more than max lenght (60)
            string tooLongCompany = StringUtils.CreateString(61);

            contactInfoPage.SetCompany(tooLongCompany);

            // Click 'Continue' button
            contactInfoPage.ClickContinueButton();

            // Assert email error message about required field
            Assert.AreEqual("Invalid company", contactInfoPage.GetErrorMessageForCompany());
        }