Selenium WebDriver to select combo-box item?

后端 未结 4 1895
情深已故
情深已故 2020-12-31 05:41

We are using Selenium WebDriver and JBehave to run \"integration\" tests on our web-app. I have a method that will enter a value into a form input.

@When(\         


        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-31 06:16

    The Support package in Selenium contains all you need:

    using OpenQA.Selenium.Support.UI;
    
    SelectElement select = new SelectElement(driver.findElement( By.id( elementId ) ));
    select.SelectByText("Option3");
    select.Submit();
    

    You can import it through NuGet as a separate package: http://nuget.org/packages/Selenium.Support

提交回复
热议问题