Esempio n. 1
0
        public void TestUpdateCustomer()
        {
            HomePage      homePage      = new HomePage();
            CustomersPage customersPage = null;
            string        id            = null;

            // Locate Administration Menu and Click
            // Locate Time & Materials Menu item and Click
            try
            {
                customersPage = homePage.GoToCustomersPage(Driver);
                Contact contactObject = new Contact(
                    ExcelLibHelpers.ReadData(GenerateRandomNumber(2, 7), "ContactFirstName"),
                    ExcelLibHelpers.ReadData(GenerateRandomNumber(2, 7), "ContactLastName"),
                    ExcelLibHelpers.ReadData(GenerateRandomNumber(2, 7), "ContactPhoneNumber"));
                Customer customerObject = new Customer(ExcelLibHelpers.ReadData(GenerateRandomNumber(2, 7), "CustomerName"), contactObject, contactObject);

                customersPage.CreateNewCustomer(Driver, customerObject);
                // go back to the summary page
                Driver.Navigate().GoToUrl(customersUrl);

                // verify
                IWebElement customerElementRow = PerformValidation(Driver, customersPage, customerObject);
                Assert.That(customerElementRow, Is.Not.Null, "Unable to create new customer - TestUpdateCustomer failed");
                id = customerElementRow.FindElement(By.XPath("td[1]")).Text;

                Contact updatedContactObject = new Contact(
                    ExcelLibHelpers.ReadData(GenerateRandomNumber(2, 7), "ContactFirstName"),
                    ExcelLibHelpers.ReadData(GenerateRandomNumber(2, 7), "ContactLastName"),
                    ExcelLibHelpers.ReadData(GenerateRandomNumber(2, 7), "ContactPhoneNumber"));

                Customer updatedCustomerObject = new Customer(ExcelLibHelpers.ReadData(GenerateRandomNumber(2, 7), "CustomerName"), updatedContactObject, updatedContactObject);
                customersPage.UpdateCustomer(Driver, id, updatedCustomerObject);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
                Assert.Fail("Unexpected error has occurred - TestUpdateCustomer failed " + e.Message);
            }

            Assert.That(PerformValidation(Driver, customersPage, id), Is.Not.Null, "Unable to update customer - TestUpdateCustomer failed");
        }