The type or namespace SelectElement could not be found in selenium c#

后端 未结 5 569
没有蜡笔的小新
没有蜡笔的小新 2020-12-07 01:19
driver.FindElement(By.Id(\"inputUsername\")).SendKeys(\"aca\");
driver.FindElement(By.Id(\"inputPassword\")).SendKeys(\"123\");
driver.FindElement(By.TagName(\"butto         


        
5条回答
  •  抹茶落季
    2020-12-07 01:55

    Selenium WebDriver C# code for selecting item from Drop Down:

    IWebElement selectElement = driver.FindElement(By.Id("selectFilterbyUser"));
    SelectElement oSelect = new SelectElement(selectElement);
    

    There are 3 ways to select drop down item: byText, byIndex, byValue

    1.byText()

    oSelect.SelectByText("Alex");
    

    2.byIndex()

    SelectAnEducation.SelectByIndex(0);
    

    3.byValue()

    SelectAnEducation.SelectByValue("Alex");
    

    Hope this helps,

提交回复
热议问题