Ejemplo n.º 1
0
        public void ShouldNotAllowUserToDeselectByIndexWhenSelectDoesNotSupportMultipleSelections()
        {
            IWebElement   element        = driver.FindElement(By.Name("selectomatic"));
            SelectElement elementWrapper = new SelectElement(element);

            Assert.Throws <InvalidOperationException>(() => elementWrapper.DeselectByIndex(0));
        }
Ejemplo n.º 2
0
        public void ShouldThrowExceptionOnDeselectByIndexIfOptionDoesNotExist()
        {
            IWebElement   element        = driver.FindElement(By.Name("select_empty_multiple"));
            SelectElement elementWrapper = new SelectElement(element);

            Assert.Throws <NoSuchElementException>(() => elementWrapper.DeselectByIndex(10));
        }
Ejemplo n.º 3
0
        public void ShouldAllowOptionsToBeDeselectedByIndex()
        {
            IWebElement element = driver.FindElement(By.Name("multi"));
            SelectElement elementWrapper = new SelectElement(element);
            elementWrapper.DeselectByIndex(0);
            IList<IWebElement> returnedOptions = elementWrapper.AllSelectedOptions;

            Assert.AreEqual(1, returnedOptions.Count);
        }
Ejemplo n.º 4
0
        public void ShouldAllowOptionsToBeDeselectedByIndex()
        {
            IWebElement   element        = driver.FindElement(By.Name("multi"));
            SelectElement elementWrapper = new SelectElement(element);

            elementWrapper.DeselectByIndex(0);
            IList <IWebElement> returnedOptions = elementWrapper.AllSelectedOptions;

            Assert.AreEqual(1, returnedOptions.Count);
        }
Ejemplo n.º 5
0
 public void DeselectByIndex(int index)
 {
     SelectElement element = new SelectElement(aWebElement);
     element.DeselectByIndex(index);
 }
Ejemplo n.º 6
0
        public void TestMultipleSelectList()
        {
            //Get the List as a Select using it's name attribute
             		    SelectElement color = new SelectElement(driver.FindElement(By.Name("color")));

             		    //Verify List support multiple selection
            Assert.IsTrue(color.IsMultiple);

            //Verify List has five options for selection
            Assert.AreEqual(5, color.Options.Count);

            //Select multiple options in the list using visible text
            color.SelectByText("Black");
            color.SelectByText("Red");
            color.SelectByText("Silver");

            //Verify there 3 options selected in the list
            Assert.AreEqual(3,color.AllSelectedOptions.Count);

            //We will verify list has multiple options selected as listed in a array
            var exp_sel_options = new ArrayList(new String[]{"Black", "Red", "Silver"});
            var act_sel_options = new ArrayList();

            foreach(IWebElement option in color.AllSelectedOptions)
                act_sel_options.Add(option.Text);

            //Verify expected array for selected options match with actual options selected
            Assert.AreEqual(exp_sel_options.ToArray(), act_sel_options.ToArray());

            //Deselect an option using visible text
            color.DeselectByText("Silver");
            //Verify selected options count
            Assert.AreEqual(2, color.AllSelectedOptions.Count);

            //Deselect an option using value attribute of the option
            color.DeselectByValue("rd");
            //Verify selected options count
            Assert.AreEqual(1, color.AllSelectedOptions.Count);

            //Deselect an option using index of the option
            color.DeselectByIndex(0);
            //Verify selected options count
            Assert.AreEqual(0, color.AllSelectedOptions.Count);
        }
Ejemplo n.º 7
0
        public void _07_Multyselection_Box_List_Test()
        {

            //идем на сайт 
            driver.Url= "http://toolsqa.com/automation-practice-form/";

            //Находим список c выбором по имени и присваеваем его в oSelect
            SelectElement oSelect = new SelectElement(driver.FindElement(By.Name("selenium_commands")));

            //выбираем первый элемет, 2-х секундная пауза
            oSelect.SelectByIndex(0);
            System.Threading.Thread.Sleep(2000);
            
            //отменяем выбор, 2-х секундная пауза
            oSelect.DeselectByIndex(0); 
            System.Threading.Thread.Sleep(2000);

            //выбираем по содежанию, 2-х секундная пауза
            oSelect.SelectByText("Navigation Commands");
            System.Threading.Thread.Sleep(2000);

            //отменяем выбор, 2-х секундная пауза
            oSelect.DeselectByText("Navigation Commands");
            System.Threading.Thread.Sleep(2000);

            //создаем колекцию всех опций списка
            IList<IWebElement> Options = oSelect.Options;

            //для каждого вебэлемента в колеции
            foreach (IWebElement item in Options)
            {
                //выводим его текст
                Console.WriteLine(item.Text);

                //Выбираем его и 1 сек. пауза
                item.Click();
                System.Threading.Thread.Sleep(1000);

            }

            //отменяем выбор всех опций 2 сек. пауза
            oSelect.DeselectAll();
            System.Threading.Thread.Sleep(2000);
        }
Ejemplo n.º 8
0
 public void ShouldNotAllowUserToDeselectByIndexWhenSelectDoesNotSupportMultipleSelections()
 {
     IWebElement element = driver.FindElement(By.Name("selectomatic"));
     SelectElement elementWrapper = new SelectElement(element);
     Assert.Throws<InvalidOperationException>(() => elementWrapper.DeselectByIndex(0));
 }
Ejemplo n.º 9
0
 public void ShouldThrowExceptionOnDeselectByIndexIfOptionDoesNotExist()
 {
     IWebElement element = driver.FindElement(By.Name("select_empty_multiple"));
     SelectElement elementWrapper = new SelectElement(element);
     Assert.Throws<NoSuchElementException>(() => elementWrapper.DeselectByIndex(10));
 }