Selenium Selector Utility

Since selector(s) are some of the more complicated elements in a web-page they need to be tested regularly. Because they are complicated you need a tool to test them. The Select library from Selenium does just that. It has nine methods to set and view the various optional values within a select structure.

The “list of options” is made up of options, matching indexes and values like a typical dictionary.

select is the web tag with some options, Multiple is a boolean option to allow for more than one value to be chosen. size is an integer to show the number of values present at any one time. autocomplete is another option available.

With the Selenium Select library you can test the indexes and the values. The assumption is that the developer would provide these values to Test. They would be applied to the website target. Your goal is that all the required values/indexes are present without any extra values possibly left over from the last release. Perhaps you have performance requirements as well. 

Here are the major functions. Visible text is what you actually see on the web-page, The index is the order in the list, If the index is a string, that is the value of the option in string form. If multiple is set you can select more than one option. 

select.select_by_index
select.select_by_value
select.deselect_all
select.select_by_value
select.all_selected_option
select_by_visible_text
select.options

if a bad selection is make a exception is thrown.
try:
    select.select_by_value(‘no_such_value’)
    assert False
except NoSuchElementException:
    pass