Automatic selection, check drop-down list

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.