Selenium2library Series Keywords _selectelementkeywords select_from_list (self, locator, *items)

Source: Internet
Author: User

1     defSelect_from_list (self, locator, *items):2         """selects ' *items ' from list identified by ' locator '3 4 If more than one value was given for a single-selection list, the last5 value would be selected. If The target list is a multi-selection list,6 and ' *items ' is a empty list, all values of the list would be selected.7 8 *items try to select by value then by label.9 Ten It's faster to the use of ' by Index/value/label ' functions. One  A An exception are raised for a single-selection list if the last - value does not exist in the list and a warning for all other non- - existing items. For a multi-selection list, the exception is raised the For any and all non-existing values. -  - Select list keywords work on both lists and combo boxes. Key attributes for - Select lists is ' id ' and ' name '. See ' Introduction ' For details about + locating elements. -         """ +Non_existing_items = [] A  atITEMS_STR = Items and "option (s) '%s '"%", ". Join (items)or "All options" -Self._info ("Selecting%s from list '%s '."%(ITEMS_STR, locator)) -  -select =self._get_select_list (Locator) -  -         if  notItems: in              forIinchRange (len (select.options)): - Select.select_by_index (i) to             return +  -          forIteminchItems: the             Try: * select.select_by_value (item) $             except:Panax Notoginseng                 Try: - Select.select_by_visible_text (item) the                 except: +Non_existing_items = Non_existing_items +[item] A                     Continue the  +         ifAny (non_existing_items): -             ifselect.is_multiple: $                 RaiseValueError ("Options '%s ' not in list '%s '."% (", ". Join (Non_existing_items), locator)) $             Else: -                 ifAny (non_existing_items[:-1]): -ITEMS_STR = Non_existing_items[:-1] and "Option (s) '%s '"%", ". Join (Non_existing_items[:-1]) theSelf._warn ("%s not found within list '%s '."%(ITEMS_STR, locator)) -                 ifItems andITEMS[-1]inchNon_existing_items:Wuyi                     RaiseValueError ("Option '%s ' isn't in list '%s '."% (Items[-1], locator))

Method Name: Select_from_list (self, locator, *items)

Similar methods:

The public method selects the items that are passed in, and if multiple values are given and is Single-selection list, the last value is selected, and if the list is multi-selection and items is empty, all options will be selected

Receive parameters: Locator,*items (labels/values)

26 Rows: Use the _get_select_list (self, locator) method to return the Select Object

Selenium2library Series Keywords _selectelementkeywords select_from_list (self, locator, *items)

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.