Reference URL: http://blog.csdn.net/Anniejunyan/article/details/39313591
Http://www.yiibai.com/selenium/selenium_drop_down.html
To operate the drop-down box, first locate the drop-down box, new a Selcet object, and then manipulate it. You need to import it when you execute the example above
* ORG.OPENQA
*. Selenium.support.ui.Select class. First, create a Select object, Ismultiple () to determine if it is a multi-select drop-down box
* The Select class provides 3 ways to select a drop-down option
* Selectbyvisibletext (), Selectbyvalue (), Selectbyindex ().
* When using the rebate method, be aware that the drop-down list is dynamically changing.
If it is a single-choice drop-down list, you can get the selected item by Getfirstselectedoption (), and then call GetText () to get this article. If it is a multi-select drop-down list, using Getallselectedoptions () to get all the selected items, this method returns a collection of elements. Use the Assertarrayequals () method to compare the expected and actual selected items correctly. Call the Getallselectedoptions (). Size () method to determine the number of drop-down list items that have been selected. If you want to check whether an option is selected, you can use the Asserttrue (Act_sel_options.contains ("Red")) method
We can select an option with "Selectbyvisibletext" or "Selectbyindex" or "Selectbyvalue".
Let's see how to use the Interactive check box-HTTP://WWW.CALCULATOR.NET/INTEREST-CALCULATOR.HTMLL. We can also check the dropdown box to select/enable/visible.
Selecting an item from Drop down list boxselect dropdown = new Select (Driver.findelement (By.id ("Ccompound")));d Ropdown. Selectbyvisibletext ("continuously");//You can also use Dropdown.selectbyindex (1) to select Second element as index s Tarts with 0.//your can also use Dropdown.selectbyvalue ("annually");
Automatic selection, check drop-down list