コード例 #1
0
        public void SelectValueByIndex(int index)
        {
            WaitForElementPresent();
            var select = new UISelectElement(GetElement());

            select.SelectByIndex(index);
        }
コード例 #2
0
        /// <summary>
        /// Select from a dropdown by index
        /// </summary>
        /// <param name="element">Select element</param>
        /// <param name="text">Option index</param>
        public static void SelectByIndex(this IBrowser browser, SelectElement element, int value)
        {
            // Create selenium select element object
            var select = new OpenQA.Selenium.Support.UI.SelectElement(browser.Find(element));

            // Select by value
            select.SelectByIndex(value);
        }
コード例 #3
0
        private void Search(int row)
        {
            string valueToSearch = handle.GetNext(row, col);

            if (valueToSearch != null)
            {
                string textboxName       = "ctl00$ctl00$ctl00$BodyContent$ContentPlaceHolder1$MainContentPlaceHolder$ResourceHostControl1$resContainer$rptContainers$ctl00$rptColumn1$ctl00$ctl01$Wrapper$txtSearchString";
                string attributeDropdown = "ctl00$ctl00$ctl00$BodyContent$ContentPlaceHolder1$MainContentPlaceHolder$ResourceHostControl1$resContainer$rptContainers$ctl00$rptColumn1$ctl00$ctl01$Wrapper$lbxNodeProperty";
                string searchBtnId       = "ctl00_ctl00_ctl00_BodyContent_ContentPlaceHolder1_MainContentPlaceHolder_ResourceHostControl1_resContainer_rptContainers_ctl00_rptColumn1_ctl00_ctl01_Wrapper_btnSearch";

                chrome.Navigate().GoToUrl("https://solarwindscs.dell.com/Orion/SummaryView.aspx?ViewID=1");

                while (IsElementPresent(textboxName, false, true) == false)
                {
                    Thread.Sleep(25);
                }
                try
                {
                    OpenQA.Selenium.IWebElement searchBox           = chrome.FindElementByName(textboxName);
                    OpenQA.Selenium.IWebElement dropBox             = chrome.FindElementByName(attributeDropdown);
                    OpenQA.Selenium.IWebElement searchBtn           = chrome.FindElementById(searchBtnId);
                    OpenQA.Selenium.Support.UI.SelectElement select = new OpenQA.Selenium.Support.UI.SelectElement(dropBox);
                    //Console.WriteLine("HHHHHHH");
                    searchBox.SendKeys(valueToSearch);
                    //Console.WriteLine("HHHHHHH");
                    select.SelectByIndex(attributeIndex);
                    // Console.WriteLine("uyguygufuov");
                    searchBtn.Click();
                    // Console.WriteLine("HHHHHHH");

                    while (IsElementPresent("StatusMessage", true, false) == false)
                    {
                        Thread.Sleep(25);
                    }

                    string result = chrome.FindElementByClassName("StatusMessage").Text;
                    if (result.Contains("Nodes with ") && result.Contains(" similar to "))
                    {
                        ReadOnlyCollection <OpenQA.Selenium.IWebElement> amount = chrome.FindElementsByClassName("StatusIcon");
                        //Console.WriteLine(amount.Count);
                        handle.AddResult(row, valueToSearch, "Y", (amount.Count - 1).ToString());
                    }
                    else
                    {
                        handle.AddResult(row, valueToSearch, "N", "0");
                    }
                }
                catch (Exception e)
                {
                    throw new WebSearchException(Thread.CurrentThread.ManagedThreadId.ToString());
                }
            }
        }
コード例 #4
0
        public bool selectByIndex(By locator, int index, string locatorName)
        {
            bool flag = false;

            try
            {
                Select s = new Select(driver.FindElement(locator));
                s.SelectByIndex(index);
                flag = true;
                return(flag);
            }
            catch (Exception)
            {
                return(flag);
            }
        }
コード例 #5
0
        public void SetValue(string value, SelectMode selectMode)
        {
            if (selectMode == SelectMode.Value)
            {
                try
                {
                    _element.SelectByValue(value);
                }
                catch (NoSuchElementException)
                {
                    try
                    {
                        _element.SelectByText(value);
                    }
                    catch (NoSuchElementException)
                    {
                    }
                }
            }
            else if (selectMode == SelectMode.Text)
            {
                try
                {
                    _element.SelectByText(value);
                }
                catch (NoSuchElementException)
                {
                    throw new NoSuchElementException("Cannot locate option with text: " + value);
                }
            }
            else if (selectMode == SelectMode.Index)
            {
                try
                {
                    _element.SelectByIndex(Int32.Parse(value));
                }
                catch (NoSuchElementException)
                {
                    throw new NoSuchElementException("Cannot location option at index: " + value);
                }
            }

            this.OnChange();
        }
コード例 #6
0
ファイル: PageBase.cs プロジェクト: diegotegs/Projeto_Mantis2
 protected void ComboBoxSelectByVisibleIndex(By locator, int location)
 {
     OpenQA.Selenium.Support.UI.SelectElement comboBox = new OpenQA.Selenium.Support.UI.SelectElement(WaitForElement(locator));
     comboBox.SelectByIndex(location);
     ExtentReportHelpers.AddTestInfo(3, "PARAMETER: " + location);
 }