MCPcopy Create free account
hub / github.com/seleniumbase/SeleniumBase / test_base

Method test_base

examples/test_select_options.py:6–41  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

4
5class SelectTestClass(BaseCase):
6 def test_base(self):
7 self.goto("https://seleniumbase.io/demo_page")
8
9 expected_option_texts = [
10 "Set to 25%", "Set to 50%", "Set to 75%", "Set to 100%"
11 ]
12 option_texts = self.get_select_options("select#mySelect")
13 self.assert_equal(option_texts, expected_option_texts)
14
15 expected_option_indexes = ["0", "1", "2", "3"]
16 option_indexes = self.get_select_options(
17 "select#mySelect", attribute="index"
18 )
19 self.assert_equal(option_indexes, expected_option_indexes)
20
21 expected_option_values = ["25%", "50%", "75%", "100%"]
22 option_values = self.get_select_options(
23 "select#mySelect", attribute="value"
24 )
25 self.assert_equal(option_values, expected_option_values)
26
27 for index, option_text in enumerate(option_texts):
28 self.select_option_by_text("#mySelect", option_text)
29 selected_value = self.get_attribute("#mySelect", "value")
30 self.assert_equal(selected_value, option_values[index])
31
32 for index, option_value in enumerate(option_values):
33 self.select_option_by_value("#mySelect", option_value)
34 selected_value = self.get_attribute("#mySelect", "value")
35 self.assert_equal(selected_value, option_values[index])
36
37 for index, option_index in enumerate(option_indexes):
38 self.select_option_by_index("#mySelect", option_index)
39 # assert_attribute() combines get_attribute() and assert_equal()
40 # It also highlights the element when Demo Mode is enabled.
41 self.assert_attribute("#mySelect", "value", option_values[index])

Callers

nothing calls this directly

Calls 8

get_select_optionsMethod · 0.80
assert_attributeMethod · 0.80
gotoMethod · 0.45
assert_equalMethod · 0.45
select_option_by_textMethod · 0.45
get_attributeMethod · 0.45

Tested by

no test coverage detected