コード例 #1
0
        /// <summary>
        /// Mark the checkbox associated to a Job ID.
        /// </summary>
        /// <param name="jobId">The Job ID to be found and marked.</param>
        public void MarkListingCheckbox(string jobId)
        {
            try
            {
                BaseWaitForPageToLoad(Driver, 100);

                int ndx = -1; // the index of the checkbox containing the ID

                while (ndx == -1)
                {
                    for (int i = 0; i < ListingCheckBox.Count(); i++)
                    {
                        if (ListingCheckBox[i].GetAttribute("value") == jobId)
                        {
                            ndx = i;
                            break;
                        }
                    }

                    // Mark the checkbox if the Job ID is found
                    if (ndx > -1)
                    {
                        //((IJavaScriptExecutor)Driver).ExecuteScript("arguments[0].scrollIntoView(true);", ListingCheckBox[ndx]);
                        ScrollToElement(ListingCheckBox[ndx]);
                        ListingCheckBox[ndx].Click();
                    }
                    // If its not found, go to the next page
                    else
                    {
                        ((IJavaScriptExecutor)Driver).ExecuteScript("page('Down');");
                    }
                }
            }
            catch (Exception e) { throw e; }
        }
        /// <summary>
        /// Mark the checkbox associated to a Job ID.
        /// </summary>
        /// <param name="jobId">The Job ID to be found and marked.</param>
        public void MarkListingCheckbox(int jobId)
        {
            try
            {
                int ndx = -1; // the index of the checkbox containing the ID

                while (ndx == -1)
                {
                    for (int i = 0; i < ListingCheckBox.Count(); i++)
                    {
                        if (ListingCheckBox[i].GetAttribute("value") == jobId.ToString())
                        {
                            ndx = i;
                            break;
                        }
                    }

                    // Mark the checkbox if the Job ID is found
                    if (ndx > -1)
                    {
                        ListingCheckBox[ndx].ScrollIntoView(_driver);
                        ListingCheckBox[ndx].WaitAndClick(_driver);
                    }
                    // If its not found, go to the next page
                    else
                    {
                        ((IJavaScriptExecutor)_driver).ExecuteScript("page('Down');");
                    }
                }
            }
            catch (Exception e) { throw e; }
        }