Esempio n. 1
0
        public void UpdateCustomer(IWebDriver driver, string id, Customer updatedCustomer)
        {
            IWebElement customerToUpdate = SearchById(driver, id); // row

            // fill out name
            customerToUpdate.FindElement(editButtonLocator).Click();
            // new client edit iframe
            IWebElement editCustomerIframe = driver.FindElement(editCustomerFrame);

            driver.SwitchTo().Frame(editCustomerIframe);
            ClearAndEnter(driver.FindElement(customerNameLocator), updatedCustomer.Name);
            // click editContactButtonLocator
            driver.FindElement(editContactButtonLocator).Click();
            // fill out contact first name and last name and phone number
            SynchronizationHelper.WaitForVisibility(driver, contactDetailFrame, 10);
            IWebElement editContactForm = driver.FindElement(contactDetailFrame);

            // switching to Edit Contact Form iframe
            driver.SwitchTo().Frame(editContactForm);
            ClearAndEnter(driver.FindElement(contactFirstNameLocator), updatedCustomer.CustomerContact.FirstName);
            ClearAndEnter(driver.FindElement(contactLastNameLocator), updatedCustomer.CustomerContact.LastName);
            ClearAndEnter(driver.FindElement(contactPhoneNumberLocator), updatedCustomer.CustomerContact.PhoneNumber);
            // click save contact button
            driver.FindElement(saveContactButtonLocator).Click();
            // switching iframe back
            driver.SwitchTo().ParentFrame();
            // have to wait for the contact detail iframe to be hidden before proceeding to clicking save button
            SynchronizationHelper.WaitForElementToBeHidden(driver, By.Id("contactDetailWindow"), 10);
            // cick save button
            SynchronizationHelper.WaitForClickability(driver, driver.FindElement(saveButtonLocator), 10);
            driver.FindElement(saveButtonLocator).Click();
        }
Esempio n. 2
0
        public void PageLast(IWebDriver driver)
        {
            // need to wait until a row is displayed in the table before clicking page last button
            //SynchronizationHelper.WaitForVisibility(driver, pageLastLocator, 10);
            //SynchronizationHelper.WaitForClickability(driver, pageLastLocator, 10);
            SynchronizationHelper.WaitForElementToBeHidden(driver, By.Id("loader"), 10);
            IWebElement pageLast = driver.FindElement(pageLastLocator);

            // rare situation where page last button is disabled because there are no table rows
            // this can happen when the user deletes a row from the table and the page only had a single record
            // proceeding to click page down instead
            pageLast.Click();
        }
Esempio n. 3
0
        public IWebElement SearchById(IWebDriver driver, string id)
        {
            SynchronizationHelper.WaitForElementToBeHidden(driver, By.Id("loader"), 10);
            PageLast(driver);
            // current page number
            int totalPageNumbers = int.Parse(driver.FindElement(By.ClassName("k-state-selected")).Text);
            int intId            = int.Parse(id);

            for (var i = 0; i < totalPageNumbers; i++)
            {
                SynchronizationHelper.WaitForVisibility(driver, By.XPath("//*[@id=\"clientsGrid\"]/div[2]/table/tbody/tr[@role='row']"), 10);
                var initialRows = driver.FindElements(By.XPath("//*[@id=\"clientsGrid\"]/div[2]/table/tbody/tr[@role='row']"));
                Console.WriteLine("rows : " + initialRows.Count);
                if (initialRows.Count == 0)
                {
                    PageDown(driver);
                    continue;
                }
                int firstRowId = int.Parse(initialRows[0].FindElement(By.XPath("td[1]")).Text);
                int lastRowId  = int.Parse(initialRows[initialRows.Count - 1].FindElement(By.XPath("td[1]")).Text);
                if (firstRowId > intId && lastRowId > intId)
                {
                    // hasn't reached the right page
                    // page down and iterate rows
                    PageDown(driver);
                    continue;
                }
                if (firstRowId < intId && lastRowId < intId)
                {
                    // already have gone past
                    // fail and return
                    return(null);
                }
                foreach (var possibleRow in initialRows)
                {
                    if (int.Parse(possibleRow.FindElement(By.XPath("td[1]")).Text) == intId)
                    {
                        return(possibleRow);
                    }
                }
                //var rows = driver.FindElements(By.XPath("//*[@id=\"clientsGrid\"]/div[2]/table/tbody/tr[@role='row']/td[1][text()='" + id + "']/parent::tr"));
                //if (rows.Count > 1)
                //{
                //    return rows[0];
                //}
                //PageDown(driver);
            }
            return(null);
        }