Select each option in a drop down using Selenium WebDriver C#

后端 未结 5 1828
深忆病人
深忆病人 2021-02-19 00:06

I\'m not able to select options in a drop down list. I think I need to have .Select or SelectElement, but there is no such option.

Sample code:

5条回答
  •  失恋的感觉
    2021-02-19 00:40

    Depending what version of Selenium WebDriver you are using you can use the SelectElement class, which will be included in OpenQA.Selenium.Support.UI.
    For example:

    SelectElement selector = new SelectElement(element);
    selector.SelectByIndex(1);
    

    Where the element is your drop down box.

提交回复
热议问题