private static Boolean pollingBusinessCardReceived(ChromeDriver driver, Random random, String connString, SettingsInfo setting)
        {
            String  status      = Utilities.Utilities.GetCurrentMethodName();
            Boolean success     = false;
            Int32   totalPage   = 0;
            Int32   currentPage = 0;
            Boolean terminated  = false;

            try
            {
                WebDriverWait wait = new WebDriverWait(driver, _TimeSpanWaiting);
                driver.GoToUrl(setting.UrlReceivied);
                totalPage = getTotalPages(driver);
                display(String.Format("[{0}] Received Cards .", totalPage), false, true);
                do
                {
                    display(".", false, false);
                    currentPage = getCurrentPage(driver, wait);
                    if (currentPage > 0)
                    {
                        List <BusinessCardInfo> cards = getBusinessCardsReceived(driver, setting.Account, setting.Email);
                        success = DataOperation.UpdateBusinessCards(connString, cards);
                        if (!setting.CheckAllPages && cards.Where(card => card.Result.Code == "INSERT").FirstOrDefault <BusinessCardInfo>() == null)
                        {
                            terminated = true;
                            break;
                        }
                        if (currentPage < totalPage)
                        {
                            success = driver.ClickElement(wait, "//div[@class='ui2-pagination-pages']/a[@class='next']");
                            System.Threading.Thread.Sleep(random.Next(2000, 3000));
                        }
                    }
                    else
                    {
                        break;
                    }
                } while (currentPage < totalPage);
                //System.Threading.Thread.Sleep(random.Next(20000, 30000));
            }
            catch (System.Exception ex)
            {
                display($"[{status}] ERROR: {ex.Message}", true, true);
            }
            display(String.Format("Done [{0}].", terminated ? "Terminated" : "Completed"), true, false);
            return(success);
        }
Exemple #2
0
        void RegistrationPremium(MainWindow mainWindow, Models.Account account)
        {
            Random random = new Random();

            Thread.Sleep(random.Next(10000, 15000));

            _driver.Navigate().GoToUrl(mainWindow.RegisterPremium.Url);
            var cardInfo = StringHelper.GetCardInfo(account.CardContact);

            Thread.Sleep(random.Next(10000, 15000));

            _driver.SwitchTo().Frame(_driver.FindElementWait(mainWindow.RegisterPremium.IFrame, 10));
            Thread.Sleep(random.Next(1000, 2000));

            var cardNumberElement = _driver.FindElementWait(mainWindow.RegisterPremium.CardNumber);

            _driver.FillTextToTextBox(cardNumberElement, cardInfo.CardNumber);
            Thread.Sleep(random.Next(1000, 2000));

            var expiryMonthElement = _driver.FindElementWait(mainWindow.RegisterPremium.ExpiryMonth);
            var selectMonthElement = new SelectElement(expiryMonthElement);

            selectMonthElement.SelectByText(cardInfo.ExpiryMonth);
            Thread.Sleep(random.Next(1000, 2000));

            var expiryYearElement = _driver.FindElementWait(mainWindow.RegisterPremium.ExpiryYear);
            var selectYearElement = new SelectElement(expiryYearElement);

            selectYearElement.SelectByText(cardInfo.ExpiryYear);
            Thread.Sleep(random.Next(1000, 2000));

            var secureCodeElement = _driver.FindElementWait(mainWindow.RegisterPremium.SecurityCode);

            _driver.FillTextToTextBox(secureCodeElement, cardInfo.SecurityCode);
            Thread.Sleep(random.Next(1000, 2000));

            var zipCodeElement = _driver.FindElementWait(mainWindow.RegisterPremium.ZipCode);

            _driver.FillTextToTextBox(zipCodeElement, cardInfo.ZipCode);
            Thread.Sleep(random.Next(1000, 2000));

            var submitElement = _driver.FindElementWait(mainWindow.RegisterPremium.ZipCode);

            _driver.ClickElement(submitElement);

            Thread.Sleep(random.Next(10000, 15000));
        }
Exemple #3
0
        /// <summary>
        ///     The entry point of this application.
        /// </summary>
        public static void Main()
        {
            Stopwatch timer = new Stopwatch();

            timer.Start();

            string userName = "******";
            string password = @"admin";

            string themeName = "checkinpark";
            int    kioskId   = 2;

            using (IWebDriver driver = new ChromeDriver())
            {
                // Start up the web browser
                driver.Navigate().GoToUrl(new Uri("https://rock.rocksolidchurchdemo.com/checkin"));

                #region Log in

                // Log in
                driver.SendKeysToElement(By.XPath("//input[contains(@id, 'tbUserName') and @type='text']"), userName);
                driver.SendKeysToElement(By.XPath("//input[contains(@id, 'tbPassword') and @type='password']"), password);
                driver.ClickElement(By.XPath("//a[contains(@id, 'btnLogin')]"));
                driver.WaitForPostBack(TimeSpan.FromSeconds(5));

                #endregion

                #region Configure kiosk

                // Configure kiosk
                driver.ClickElement(By.XPath($@"//select[contains(@id, 'ddlTheme')]/option[@value='{ themeName }']"));
                driver.WaitForPostBack(TimeSpan.FromSeconds(5));

                driver.ClickElement(By.XPath($@"//select[contains(@id, 'ddlKiosk')]/option[@value='{ kioskId }']"));
                driver.WaitForAjax(TimeSpan.FromSeconds(5));

                // Check-in Configuration is automatically set to the default

                driver.WaitForElement(By.XPath("//div[contains(@id, 'pnlManualConfig')]//div[contains(@class, 'rock-check-box-list')]"), TimeSpan.FromSeconds(5));

                ISet <int> checkInAreaIds = new HashSet <int>()
                {
                    18, // Check-in Test Area
                    19, // Nursery/Preschool Area
                    20, // Elementary Area
                    21, // Jr High Area
                    22, // High School Area
                };
                foreach (int checkInAreaId in checkInAreaIds)
                {
                    driver.ClickElement(By.XPath($"//input[contains(@id, 'cblPrimaryGroupTypes') and @type='checkbox' and @value='{ checkInAreaId }']"));
                }

                ISet <int> additionalAreaIds = new HashSet <int>()
                {
                    23, // Serving Team
                };
                foreach (int additionalAreaId in additionalAreaIds)
                {
                    driver.ClickElement(By.XPath($"//input[contains(@id, 'cblAlternateGroupTypes') and @type='checkbox' and @value='{ additionalAreaId }']"));
                }

                driver.ClickElement(By.XPath($"//a[contains(@id, 'lbOk')]"));
                driver.WaitForPostBack(TimeSpan.FromSeconds(5));

                #endregion

                #region Check in people

                // Check in people
                driver.CheckInPerson("3322", 68, 6, 6, null, null, null, "Bears Room");
                driver.CheckInPerson("3322", 68, 7, 6, null, null, null, "Bunnies Room");

                #endregion

                // Shut down the web browser
                driver.Quit();
            }

            timer.Stop();

            Console.WriteLine
            (
                String.Format
                (
                    "Finished in {0:00}:{1:00}:{2:00}.{3:00}",
                    timer.Elapsed.Hours,
                    timer.Elapsed.Minutes,
                    timer.Elapsed.Seconds,
                    (timer.Elapsed.Milliseconds / 10)
                )
            )
            ;
        }