コード例 #1
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)
                )
            )
            ;
        }