当前位置: 首页>>代码示例>>C#>>正文


C# SelectElement.DeselectByValue方法代码示例

本文整理汇总了C#中OpenQA.Selenium.Support.UI.SelectElement.DeselectByValue方法的典型用法代码示例。如果您正苦于以下问题:C# SelectElement.DeselectByValue方法的具体用法?C# SelectElement.DeselectByValue怎么用?C# SelectElement.DeselectByValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenQA.Selenium.Support.UI.SelectElement的用法示例。


在下文中一共展示了SelectElement.DeselectByValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShouldAllowOptionsToBeDeselectedByReturnedValue

        public void ShouldAllowOptionsToBeDeselectedByReturnedValue()
        {
            IWebElement element = driver.FindElement(By.Name("multi"));
            SelectElement elementWrapper = new SelectElement(element);
            elementWrapper.DeselectByValue("eggs");
            IList<IWebElement> returnedOptions = elementWrapper.AllSelectedOptions;

            Assert.AreEqual(1, returnedOptions.Count);
        }
开发者ID:lesmana,项目名称:selenium,代码行数:9,代码来源:SelectBrowserTests.cs

示例2: DeselectByValue

 public void DeselectByValue(string value)
 {
     SelectElement element = new SelectElement(aWebElement);
     element.DeselectByValue(value);
 }
开发者ID:geeksree,项目名称:cSharpGeeks,代码行数:5,代码来源:SeleniumWebCombobox.cs

示例3: TestMultipleSelectList

        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);
        }
开发者ID:vikramuk,项目名称:Selenium,代码行数:44,代码来源:SelectTests.cs

示例4: EditMultiSelectField

        /// <summary>
        /// select-multipleの選択と解除
        /// </summary>
        /// <param name="driver"></param>
        private static void EditMultiSelectField(IWebDriver driver)
        {
            // <select multiple="multiple">の選択
            var element = driver.FindElement(By.Id("id_selected_multiple"));
            var selectElement = new SelectElement(element);

            // 全部を選択
            selectElement.SelectByValue("1");
            selectElement.SelectByValue("2");
            selectElement.SelectByValue("3");

            // 一部を解除
            // 選択と同様、Index, Value, Textの3種類あり
            selectElement.DeselectByValue("2");

            // もしくは、一括で解除
            selectElement.DeselectAll();

            // 再度選択しておく
            selectElement.SelectByValue("2");
        }
开发者ID:thinkAmi-sandbox,项目名称:SeleniumSampleUsingCsharp,代码行数:25,代码来源:Program.cs

示例5: ShouldNotAllowUserToDeselectByValueWhenSelectDoesNotSupportMultipleSelections

 public void ShouldNotAllowUserToDeselectByValueWhenSelectDoesNotSupportMultipleSelections()
 {
     IWebElement element = driver.FindElement(By.Name("selectomatic"));
     SelectElement elementWrapper = new SelectElement(element);
     Assert.Throws<InvalidOperationException>(() => elementWrapper.DeselectByValue("two"));
 }
开发者ID:RanchoLi,项目名称:selenium,代码行数:6,代码来源:SelectBrowserTests.cs

示例6: ShouldThrowExceptionOnDeselectByReturnedValueIfOptionDoesNotExist

 public void ShouldThrowExceptionOnDeselectByReturnedValueIfOptionDoesNotExist()
 {
     IWebElement element = driver.FindElement(By.Name("select_empty_multiple"));
     SelectElement elementWrapper = new SelectElement(element);
     Assert.Throws<NoSuchElementException>(() => elementWrapper.DeselectByValue("not there"));
 }
开发者ID:RanchoLi,项目名称:selenium,代码行数:6,代码来源:SelectBrowserTests.cs


注:本文中的OpenQA.Selenium.Support.UI.SelectElement.DeselectByValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。