watir 6.5.0 → 6.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +58 -21
- data/CHANGES.md +11 -0
- data/Rakefile +3 -5
- data/lib/watir.rb +14 -2
- data/lib/watir/adjacent.rb +20 -27
- data/lib/watir/alert.rb +1 -1
- data/lib/watir/attribute_helper.rb +1 -1
- data/lib/watir/browser.rb +6 -3
- data/lib/watir/capabilities.rb +95 -0
- data/lib/watir/cookies.rb +5 -6
- data/lib/watir/element_collection.rb +17 -0
- data/lib/watir/elements/element.rb +12 -15
- data/lib/watir/elements/iframe.rb +1 -1
- data/lib/watir/elements/option.rb +5 -6
- data/lib/watir/elements/select.rb +52 -36
- data/lib/watir/legacy_wait.rb +2 -2
- data/lib/watir/locators/button/selector_builder.rb +10 -7
- data/lib/watir/locators/element/locator.rb +2 -2
- data/lib/watir/locators/element/selector_builder.rb +10 -4
- data/lib/watir/locators/element/selector_builder/xpath.rb +22 -3
- data/lib/watir/logger.rb +109 -0
- data/lib/watir/wait.rb +6 -6
- data/lib/watirspec.rb +1 -1
- data/lib/watirspec/guards.rb +4 -4
- data/lib/watirspec/implementation.rb +13 -5
- data/lib/watirspec/remote_server.rb +38 -0
- data/lib/watirspec/runner.rb +2 -2
- data/lib/watirspec/server.rb +1 -1
- data/spec/browser_spec.rb +101 -17
- data/spec/element_locator_spec.rb +1 -1
- data/spec/element_spec.rb +1 -1
- data/spec/logger_spec.rb +46 -0
- data/spec/watirspec/adjacent_spec.rb +45 -0
- data/spec/watirspec/after_hooks_spec.rb +45 -40
- data/spec/watirspec/alert_spec.rb +20 -14
- data/spec/watirspec/browser_spec.rb +71 -77
- data/spec/watirspec/cookies_spec.rb +13 -16
- data/spec/watirspec/drag_and_drop_spec.rb +6 -6
- data/spec/watirspec/elements/button_spec.rb +14 -7
- data/spec/watirspec/elements/collections_spec.rb +18 -1
- data/spec/watirspec/elements/dd_spec.rb +4 -2
- data/spec/watirspec/elements/del_spec.rb +12 -10
- data/spec/watirspec/elements/div_spec.rb +17 -13
- data/spec/watirspec/elements/dl_spec.rb +4 -2
- data/spec/watirspec/elements/form_spec.rb +8 -6
- data/spec/watirspec/elements/frame_spec.rb +27 -19
- data/spec/watirspec/elements/iframe_spec.rb +28 -17
- data/spec/watirspec/elements/ins_spec.rb +12 -10
- data/spec/watirspec/elements/option_spec.rb +17 -33
- data/spec/watirspec/elements/select_list_spec.rb +111 -97
- data/spec/watirspec/elements/span_spec.rb +12 -10
- data/spec/watirspec/elements/table_spec.rb +13 -11
- data/spec/watirspec/elements/tbody_spec.rb +13 -11
- data/spec/watirspec/elements/td_spec.rb +6 -4
- data/spec/watirspec/elements/text_field_spec.rb +19 -17
- data/spec/watirspec/elements/tr_spec.rb +12 -8
- data/spec/watirspec/html/javascript/helpers.js +2 -2
- data/spec/watirspec/html/nested_elements.html +5 -5
- data/spec/watirspec/relaxed_locate_spec.rb +13 -19
- data/spec/watirspec/wait_spec.rb +279 -301
- data/spec/watirspec/window_switching_spec.rb +190 -174
- data/spec/watirspec_helper.rb +64 -122
- data/support/doctest_helper.rb +4 -0
- data/watir.gemspec +2 -2
- metadata +15 -4
@@ -75,6 +75,19 @@ describe "Button" do
|
|
75
75
|
expect(browser.button(xpath: "//input[@type='button']")).to exist
|
76
76
|
end
|
77
77
|
|
78
|
+
it "matches the specific type when locating by type" do
|
79
|
+
expect(browser.button(type: "button").type).to eq "button"
|
80
|
+
expect(browser.button(type: "reset").type).to eq "reset"
|
81
|
+
expect(browser.button(type: "submit").type).to eq "submit"
|
82
|
+
expect(browser.button(type: "image").type).to eq "image"
|
83
|
+
end
|
84
|
+
|
85
|
+
it "matches valid input types when type is boolean" do
|
86
|
+
expect(browser.buttons(type: false).map(&:tag_name)).to all eq("button")
|
87
|
+
|
88
|
+
input_buttons = browser.buttons(type: true).select { |e| e.tag_name == "input" }
|
89
|
+
expect(input_buttons.map(&:type).uniq).to match_array(Watir::Button::VALID_TYPES)
|
90
|
+
end
|
78
91
|
|
79
92
|
it "raises TypeError when 'what' argument is invalid" do
|
80
93
|
expect { browser.button(id: 3.14).exists? }.to raise_error(TypeError)
|
@@ -132,13 +145,7 @@ describe "Button" do
|
|
132
145
|
end
|
133
146
|
|
134
147
|
describe "#style" do
|
135
|
-
not_compliant_on :internet_explorer
|
136
|
-
it "returns the style attribute if the button exists" do
|
137
|
-
expect(browser.button(id: 'delete_user_submit').style).to eq "border: 4px solid red;"
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
deviates_on :safari do
|
148
|
+
not_compliant_on :internet_explorer do
|
142
149
|
it "returns the style attribute if the button exists" do
|
143
150
|
expect(browser.button(id: 'delete_user_submit').style).to eq "border: 4px solid red;"
|
144
151
|
end
|
@@ -14,7 +14,7 @@ describe "Collections" do
|
|
14
14
|
|
15
15
|
it "returns correct subtype of elements" do
|
16
16
|
browser.goto(WatirSpec.url_for("collections.html"))
|
17
|
-
collection = browser.span(id: "a_span").spans
|
17
|
+
collection = browser.span(id: "a_span").spans
|
18
18
|
expect(collection.all? { |el| el.is_a? Watir::Span}).to eq true
|
19
19
|
end
|
20
20
|
|
@@ -32,4 +32,21 @@ describe "Collections" do
|
|
32
32
|
browser.refresh
|
33
33
|
expect(collection[3].tag_name).to eq tag
|
34
34
|
end
|
35
|
+
|
36
|
+
it "returns value for #empty?" do
|
37
|
+
browser.goto(WatirSpec.url_for("collections.html"))
|
38
|
+
expect(browser.span(id: "a_span").options.empty?).to eq true
|
39
|
+
end
|
40
|
+
|
41
|
+
it "returns value for #any?" do
|
42
|
+
browser.goto(WatirSpec.url_for("collections.html"))
|
43
|
+
expect(browser.span(id: "a_span").spans.any?).to eq true
|
44
|
+
end
|
45
|
+
|
46
|
+
it "locates elements" do
|
47
|
+
browser.goto(WatirSpec.url_for("collections.html"))
|
48
|
+
spans = browser.span(id: "a_span").spans
|
49
|
+
expect(spans).to receive(:elements).and_return([])
|
50
|
+
spans.locate
|
51
|
+
end
|
35
52
|
end
|
@@ -77,8 +77,10 @@ describe "Dd" do
|
|
77
77
|
expect(browser.dd(id: "someone").text).to eq "John Doe"
|
78
78
|
end
|
79
79
|
|
80
|
-
|
81
|
-
|
80
|
+
bug "Safari does not strip text", :safari do
|
81
|
+
it "returns an empty string if the element exists but contains no text" do
|
82
|
+
expect(browser.dd(class: 'noop').text).to eq ""
|
83
|
+
end
|
82
84
|
end
|
83
85
|
|
84
86
|
it "raises UnknownObjectException if the element does not exist" do
|
@@ -113,16 +113,18 @@ describe "Del" do
|
|
113
113
|
end
|
114
114
|
|
115
115
|
# Other
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
116
|
+
not_compliant_on :headless do
|
117
|
+
describe "#click" do
|
118
|
+
it "fires events" do
|
119
|
+
expect(browser.del(class: 'footer').text).to_not include('Javascript')
|
120
|
+
browser.del(class: 'footer').click
|
121
|
+
expect(browser.del(class: 'footer').text).to include('Javascript')
|
122
|
+
end
|
123
|
+
|
124
|
+
it "raises UnknownObjectException if the del doesn't exist" do
|
125
|
+
expect { browser.del(id: "no_such_id").click }.to raise_unknown_object_exception
|
126
|
+
expect { browser.del(title: "no_such_title").click }.to raise_unknown_object_exception
|
127
|
+
end
|
126
128
|
end
|
127
129
|
end
|
128
130
|
end
|
@@ -114,8 +114,10 @@ describe "Div" do
|
|
114
114
|
expect(browser.div(index: 0).text.strip).to eq ""
|
115
115
|
end
|
116
116
|
|
117
|
-
|
118
|
-
|
117
|
+
not_compliant_on :safari do
|
118
|
+
it "returns an empty string if the div is hidden" do
|
119
|
+
expect(browser.div(id: 'hidden').text).to eq ""
|
120
|
+
end
|
119
121
|
end
|
120
122
|
|
121
123
|
it "raises UnknownObjectException if the element does not exist" do
|
@@ -136,18 +138,20 @@ describe "Div" do
|
|
136
138
|
end
|
137
139
|
|
138
140
|
# Manipulation methods
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
141
|
+
not_compliant_on :headless do
|
142
|
+
describe "#click" do
|
143
|
+
it "fires events when clicked" do
|
144
|
+
expect(browser.div(id: 'best_language').text).to_not eq 'Ruby!'
|
145
|
+
browser.div(id: 'best_language').click
|
146
|
+
expect(browser.div(id: 'best_language').text).to eq 'Ruby!'
|
147
|
+
end
|
145
148
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
149
|
+
it "raises UnknownObjectException if the element does not exist" do
|
150
|
+
expect { browser.div(id: "no_such_id").click }.to raise_unknown_object_exception
|
151
|
+
expect { browser.div(title: "no_such_title").click }.to raise_unknown_object_exception
|
152
|
+
expect { browser.div(index: 1337).click }.to raise_unknown_object_exception
|
153
|
+
expect { browser.div(xpath: "//div[@id='no_such_id']").click }.to raise_unknown_object_exception
|
154
|
+
end
|
151
155
|
end
|
152
156
|
end
|
153
157
|
|
@@ -77,8 +77,10 @@ describe "Dl" do
|
|
77
77
|
expect(browser.dl(id: "experience-list").text).to include("11 years")
|
78
78
|
end
|
79
79
|
|
80
|
-
|
81
|
-
|
80
|
+
bug "Safari does not strip text", :safari do
|
81
|
+
it "returns an empty string if the element exists but contains no text" do
|
82
|
+
expect(browser.dl(id: 'noop').text).to eq ""
|
83
|
+
end
|
82
84
|
end
|
83
85
|
|
84
86
|
it "raises UnknownObjectException if the element does not exist" do
|
@@ -57,12 +57,14 @@ describe "Form" do
|
|
57
57
|
expect(browser.text).to include("Semantic table")
|
58
58
|
end
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
60
|
+
not_compliant_on :safari do
|
61
|
+
it "triggers onsubmit event and takes its result into account" do
|
62
|
+
form = browser.form(name: "user_new")
|
63
|
+
form.submit
|
64
|
+
expect(form).to exist
|
65
|
+
expect(messages.size).to eq 1
|
66
|
+
expect(messages[0]).to eq "submit"
|
67
|
+
end
|
66
68
|
end
|
67
69
|
end
|
68
70
|
end
|
@@ -10,13 +10,15 @@ describe "Frame" do
|
|
10
10
|
browser.goto(WatirSpec.url_for("frames.html"))
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
not_compliant_on :safari do
|
14
|
+
it "handles crossframe javascript" do
|
15
|
+
browser.goto WatirSpec.url_for("frames.html")
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
expect(browser.frame(id: "frame_1").text_field(name: 'senderElement').value).to eq 'send_this_value'
|
18
|
+
expect(browser.frame(id: "frame_2").text_field(name: 'recieverElement').value).to eq 'old_value'
|
19
|
+
browser.frame(id: "frame_1").button(id: 'send').click
|
20
|
+
expect(browser.frame(id: "frame_2").text_field(name: 'recieverElement').value).to eq 'send_this_value'
|
21
|
+
end
|
20
22
|
end
|
21
23
|
|
22
24
|
describe "#exist?" do
|
@@ -51,12 +53,14 @@ describe "Frame" do
|
|
51
53
|
end
|
52
54
|
|
53
55
|
bug "https://bugzilla.mozilla.org/show_bug.cgi?id=1255946", :firefox do
|
54
|
-
|
55
|
-
|
56
|
+
not_compliant_on :safari do
|
57
|
+
it "handles nested frames" do
|
58
|
+
browser.goto(WatirSpec.url_for("nested_frames.html"))
|
56
59
|
|
57
|
-
|
60
|
+
browser.frame(id: "two").frame(id: "three").link(id: "four").click
|
58
61
|
|
59
|
-
|
62
|
+
Watir::Wait.until { browser.title == "definition_lists" }
|
63
|
+
end
|
60
64
|
end
|
61
65
|
end
|
62
66
|
|
@@ -94,18 +98,22 @@ describe "Frame" do
|
|
94
98
|
expect(browser.frame(index: 0).text_field(name: 'senderElement').value).to eq "new value"
|
95
99
|
end
|
96
100
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
+
bug "Safari does not strip text", :safari do
|
102
|
+
it "can access the frame's parent element after use" do
|
103
|
+
el = browser.frameset
|
104
|
+
el.frame.text_field.value
|
105
|
+
expect(el.attribute_value("cols")).to be_kind_of(String)
|
106
|
+
end
|
101
107
|
end
|
102
108
|
|
103
109
|
describe "#execute_script" do
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
110
|
+
bug "Safari does not strip text", :safari do
|
111
|
+
it "executes the given javascript in the specified frame" do
|
112
|
+
frame = browser.frame(index: 0)
|
113
|
+
expect(frame.div(id: 'set_by_js').text).to eq ""
|
114
|
+
frame.execute_script(%Q{document.getElementById('set_by_js').innerHTML = 'Art consists of limitation. The most beautiful part of every picture is the frame.'})
|
115
|
+
expect(frame.div(id: 'set_by_js').text).to eq "Art consists of limitation. The most beautiful part of every picture is the frame."
|
116
|
+
end
|
109
117
|
end
|
110
118
|
end
|
111
119
|
|
@@ -11,13 +11,15 @@ describe "IFrame" do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
bug "https://bugzilla.mozilla.org/show_bug.cgi?id=1255906", :firefox do
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
14
|
+
not_compliant_on :safari do
|
15
|
+
it "handles crossframe javascript" do
|
16
|
+
browser.goto WatirSpec.url_for("iframes.html")
|
17
|
+
|
18
|
+
expect(browser.iframe(id: "iframe_1").text_field(name: 'senderElement').value).to eq 'send_this_value'
|
19
|
+
expect(browser.iframe(id: "iframe_2").text_field(name: 'recieverElement').value).to eq 'old_value'
|
20
|
+
browser.iframe(id: "iframe_1").button(id: 'send').click
|
21
|
+
expect(browser.iframe(id: "iframe_2").text_field(name: 'recieverElement').value).to eq 'send_this_value'
|
22
|
+
end
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
@@ -83,12 +85,14 @@ describe "IFrame" do
|
|
83
85
|
|
84
86
|
|
85
87
|
bug "https://bugzilla.mozilla.org/show_bug.cgi?id=1255946", :firefox do
|
86
|
-
|
87
|
-
|
88
|
+
not_compliant_on :safari do
|
89
|
+
it "handles nested iframes" do
|
90
|
+
browser.goto(WatirSpec.url_for("nested_iframes.html"))
|
88
91
|
|
89
|
-
|
92
|
+
browser.iframe(id: "two").iframe(id: "three").link(id: "four").click
|
90
93
|
|
91
|
-
|
94
|
+
Watir::Wait.until { browser.title == "definition_lists" }
|
95
|
+
end
|
92
96
|
end
|
93
97
|
end
|
94
98
|
|
@@ -112,9 +116,14 @@ describe "IFrame" do
|
|
112
116
|
end
|
113
117
|
end
|
114
118
|
|
119
|
+
it 'switches when the frame is created by subtype' do
|
120
|
+
subtype = browser.iframe.to_subtype
|
121
|
+
expect { subtype.iframe.exist? }.to_not raise_exception
|
122
|
+
end
|
123
|
+
|
115
124
|
it 'switches back to top level browsing context' do
|
116
125
|
# Point driver to browsing context of first iframe
|
117
|
-
browser.iframes.first.ps.
|
126
|
+
browser.iframes.first.ps.locate
|
118
127
|
|
119
128
|
expect(browser.h1s.first.text).to be == 'Iframes'
|
120
129
|
end
|
@@ -147,11 +156,13 @@ describe "IFrame" do
|
|
147
156
|
end
|
148
157
|
|
149
158
|
describe "#execute_script" do
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
159
|
+
bug "Safari does not strip text", :safari do
|
160
|
+
it "executes the given javascript in the specified frame" do
|
161
|
+
frame = browser.iframe(index: 0)
|
162
|
+
expect(frame.div(id: 'set_by_js').text).to eq ""
|
163
|
+
frame.execute_script(%Q{document.getElementById('set_by_js').innerHTML = 'Art consists of limitation. The most beautiful part of every picture is the frame.'})
|
164
|
+
expect(frame.div(id: 'set_by_js').text).to eq "Art consists of limitation. The most beautiful part of every picture is the frame."
|
165
|
+
end
|
155
166
|
end
|
156
167
|
end
|
157
168
|
|
@@ -113,16 +113,18 @@ describe "Ins" do
|
|
113
113
|
end
|
114
114
|
|
115
115
|
# Other
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
116
|
+
not_compliant_on :headless do
|
117
|
+
describe "#click" do
|
118
|
+
it "fires events" do
|
119
|
+
expect(browser.ins(class: 'footer').text).to_not include('Javascript')
|
120
|
+
browser.ins(class: 'footer').click
|
121
|
+
expect(browser.ins(class: 'footer').text).to include('Javascript')
|
122
|
+
end
|
123
|
+
|
124
|
+
it "raises UnknownObjectException if the ins doesn't exist" do
|
125
|
+
expect { browser.ins(id: "no_such_id").click }.to raise_unknown_object_exception
|
126
|
+
expect { browser.ins(title: "no_such_title").click }.to raise_unknown_object_exception
|
127
|
+
end
|
126
128
|
end
|
127
129
|
end
|
128
130
|
|
@@ -72,43 +72,27 @@ describe "Option" do
|
|
72
72
|
end
|
73
73
|
|
74
74
|
bug "https://bugzilla.mozilla.org/show_bug.cgi?id=1255957", :firefox do
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
it "selects the chosen option (select_list context)" do
|
82
|
-
browser.select_list(name: "new_user_country").option(text: "Denmark").select
|
83
|
-
expect(browser.select_list(name: "new_user_country").selected_options.map(&:text)).to eq ["Denmark"]
|
84
|
-
end
|
85
|
-
|
86
|
-
it "selects the option when found by text (page context)" do
|
87
|
-
browser.option(text: 'Sweden').select
|
88
|
-
expect(browser.option(text: 'Sweden')).to be_selected
|
89
|
-
end
|
75
|
+
not_compliant_on :safari do
|
76
|
+
describe "#select" do
|
77
|
+
it "selects the chosen option (page context)" do
|
78
|
+
browser.option(text: "Denmark").select
|
79
|
+
expect(browser.select_list(name: "new_user_country").selected_options.map(&:text)).to eq ["Denmark"]
|
80
|
+
end
|
90
81
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
82
|
+
it "selects the chosen option (select_list context)" do
|
83
|
+
browser.select_list(name: "new_user_country").option(text: "Denmark").select
|
84
|
+
expect(browser.select_list(name: "new_user_country").selected_options.map(&:text)).to eq ["Denmark"]
|
85
|
+
end
|
95
86
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
it "fires the onclick event (page context)" do
|
100
|
-
browser.option(text: "Username 3").select
|
101
|
-
expect(browser.textarea(id: 'delete_user_comment').value).to eq 'Don\'t do it!'
|
87
|
+
it "selects the option when found by text (page context)" do
|
88
|
+
browser.option(text: 'Sweden').select
|
89
|
+
expect(browser.option(text: 'Sweden')).to be_selected
|
102
90
|
end
|
103
|
-
end
|
104
|
-
end
|
105
91
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
browser.select_list(id: 'delete_user_username').option(text: "Username 3").select
|
111
|
-
expect(browser.textarea(id: 'delete_user_comment').value).to eq 'Don\'t do it!'
|
92
|
+
it "selects the option when found by text (select_list context)" do
|
93
|
+
browser.select_list(name: 'new_user_country').option(text: 'Sweden').select
|
94
|
+
expect(browser.select_list(name: 'new_user_country').option(text: 'Sweden')).to be_selected
|
95
|
+
end
|
112
96
|
end
|
113
97
|
end
|
114
98
|
|
@@ -91,10 +91,12 @@ describe "SelectList" do
|
|
91
91
|
|
92
92
|
describe "#value" do
|
93
93
|
bug "https://bugzilla.mozilla.org/show_bug.cgi?id=1255957", :firefox do
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
94
|
+
not_compliant_on :safari do
|
95
|
+
it "returns the value of the selected option" do
|
96
|
+
expect(browser.select_list(index: 0).value).to eq "2"
|
97
|
+
browser.select_list(index: 0).select(/Sweden/)
|
98
|
+
expect(browser.select_list(index: 0).value).to eq "3"
|
99
|
+
end
|
98
100
|
end
|
99
101
|
end
|
100
102
|
|
@@ -104,14 +106,16 @@ describe "SelectList" do
|
|
104
106
|
end
|
105
107
|
|
106
108
|
describe "#text" do
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
109
|
+
not_compliant_on :safari do
|
110
|
+
it "returns the text of the selected option" do
|
111
|
+
expect(browser.select_list(index: 0).text).to eq "Norway"
|
112
|
+
browser.select_list(index: 0).select(/Sweden/)
|
113
|
+
expect(browser.select_list(index: 0).text).to eq "Sweden"
|
114
|
+
end
|
115
|
+
|
116
|
+
it "raises UnknownObjectException if the select list doesn't exist" do
|
117
|
+
expect {browser.select_list(index: 1337).text}.to raise_unknown_object_exception
|
118
|
+
end
|
115
119
|
end
|
116
120
|
end
|
117
121
|
|
@@ -182,9 +186,11 @@ describe "SelectList" do
|
|
182
186
|
|
183
187
|
describe "#clear" do
|
184
188
|
bug "https://bugzilla.mozilla.org/show_bug.cgi?id=1255957", :firefox do
|
185
|
-
|
186
|
-
|
187
|
-
|
189
|
+
not_compliant_on :safari do
|
190
|
+
it "clears the selection when possible" do
|
191
|
+
browser.select_list(name: "new_user_languages").clear
|
192
|
+
expect(browser.select_list(name: "new_user_languages").selected_options).to be_empty
|
193
|
+
end
|
188
194
|
end
|
189
195
|
end
|
190
196
|
|
@@ -229,79 +235,83 @@ describe "SelectList" do
|
|
229
235
|
end
|
230
236
|
end
|
231
237
|
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
238
|
+
not_compliant_on :safari do
|
239
|
+
describe "#selected?" do
|
240
|
+
bug "https://bugzilla.mozilla.org/show_bug.cgi?id=1255957", :firefox do
|
241
|
+
it "returns true if the given option is selected by text" do
|
242
|
+
browser.select_list(name: 'new_user_country').select('Denmark')
|
243
|
+
expect(browser.select_list(name: 'new_user_country')).to be_selected('Denmark')
|
244
|
+
end
|
237
245
|
end
|
238
|
-
end
|
239
246
|
|
240
|
-
|
241
|
-
|
242
|
-
|
247
|
+
it "returns false if the given option is not selected by text" do
|
248
|
+
expect(browser.select_list(name: 'new_user_country')).to_not be_selected('Sweden')
|
249
|
+
end
|
243
250
|
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
251
|
+
bug "https://bugzilla.mozilla.org/show_bug.cgi?id=1255957", :firefox do
|
252
|
+
it "returns true if the given option is selected by label" do
|
253
|
+
browser.select_list(name: 'new_user_country').select('Germany')
|
254
|
+
expect(browser.select_list(name: 'new_user_country')).to be_selected('Germany')
|
255
|
+
end
|
248
256
|
end
|
249
|
-
end
|
250
257
|
|
251
|
-
|
252
|
-
|
253
|
-
|
258
|
+
it "returns false if the given option is not selected by label" do
|
259
|
+
expect(browser.select_list(name: 'new_user_country')).to_not be_selected('Germany')
|
260
|
+
end
|
254
261
|
|
255
|
-
|
256
|
-
|
262
|
+
it "raises UnknownObjectException if the option doesn't exist" do
|
263
|
+
expect { browser.select_list(name: 'new_user_country').selected?('missing_option') }.to raise_unknown_object_exception
|
264
|
+
end
|
257
265
|
end
|
258
266
|
end
|
259
267
|
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
268
|
+
not_compliant_on :safari do
|
269
|
+
describe "#select" do
|
270
|
+
bug "https://bugzilla.mozilla.org/show_bug.cgi?id=1255957", :firefox do
|
271
|
+
context "when interacting with options" do
|
272
|
+
it "selects the given item when given a String" do
|
273
|
+
browser.select_list(name: "new_user_country").select("Denmark")
|
274
|
+
expect(browser.select_list(name: "new_user_country").selected_options.map(&:text)).to eq ["Denmark"]
|
275
|
+
end
|
276
|
+
|
277
|
+
it "selects options by label" do
|
278
|
+
browser.select_list(name: "new_user_country").select("Germany")
|
279
|
+
expect(browser.select_list(name: "new_user_country").selected_options.map(&:text)).to eq ["Germany"]
|
280
|
+
end
|
281
|
+
|
282
|
+
it "selects the given item when given a Regexp" do
|
283
|
+
browser.select_list(name: "new_user_country").select(/Denmark/)
|
284
|
+
expect(browser.select_list(name: "new_user_country").selected_options.map(&:text)).to eq ["Denmark"]
|
285
|
+
end
|
286
|
+
|
287
|
+
it "selects the given item when given an Xpath" do
|
288
|
+
browser.select_list(xpath: "//select[@name='new_user_country']").select("Denmark")
|
289
|
+
expect(browser.select_list(xpath: "//select[@name='new_user_country']").selected_options.map(&:text)).to eq ["Denmark"]
|
290
|
+
end
|
291
|
+
|
292
|
+
it "selects multiple items using :name and a String" do
|
293
|
+
browser.select_list(name: "new_user_languages").clear
|
294
|
+
browser.select_list(name: "new_user_languages").select("Danish")
|
295
|
+
browser.select_list(name: "new_user_languages").select("Swedish")
|
296
|
+
expect(browser.select_list(name: "new_user_languages").selected_options.map(&:text)).to eq ["Danish", "Swedish"]
|
297
|
+
end
|
298
|
+
|
299
|
+
it "selects multiple items using :name and a Regexp" do
|
300
|
+
browser.select_list(name: "new_user_languages").clear
|
301
|
+
browser.select_list(name: "new_user_languages").select_all(/ish/)
|
302
|
+
expect(browser.select_list(name: "new_user_languages").selected_options.map(&:text)).to eq ["Danish", "English", "Swedish"]
|
303
|
+
end
|
304
|
+
|
305
|
+
it "selects multiple items using :xpath" do
|
306
|
+
browser.select_list(xpath: "//select[@name='new_user_languages']").clear
|
307
|
+
browser.select_list(xpath: "//select[@name='new_user_languages']").select_all(/ish/)
|
308
|
+
expect(browser.select_list(xpath: "//select[@name='new_user_languages']").selected_options.map(&:text)).to eq ["Danish", "English", "Swedish"]
|
309
|
+
end
|
310
|
+
|
311
|
+
it "selects empty options" do
|
312
|
+
browser.select_list(id: "delete_user_username").select("")
|
313
|
+
expect(browser.select_list(id: "delete_user_username").selected_options.map(&:text)).to eq [""]
|
314
|
+
end
|
305
315
|
end
|
306
316
|
end
|
307
317
|
end
|
@@ -311,7 +321,7 @@ describe "SelectList" do
|
|
311
321
|
end
|
312
322
|
|
313
323
|
it "returns the first matching value if there are multiple matches" do
|
314
|
-
expect(browser.select_list(name: "new_user_languages").
|
324
|
+
expect(browser.select_list(name: "new_user_languages").select_all(/ish/)).to eq "Danish"
|
315
325
|
end
|
316
326
|
|
317
327
|
not_compliant_on :safari do
|
@@ -337,8 +347,10 @@ describe "SelectList" do
|
|
337
347
|
end
|
338
348
|
|
339
349
|
bug "https://bugzilla.mozilla.org/show_bug.cgi?id=1255957", :firefox do
|
340
|
-
|
341
|
-
|
350
|
+
not_compliant_on :safari do
|
351
|
+
it "returns an empty string when selecting an option that disappears when selected" do
|
352
|
+
expect(browser.select_list(id: 'obsolete').select('sweden')).to eq ''
|
353
|
+
end
|
342
354
|
end
|
343
355
|
end
|
344
356
|
|
@@ -361,24 +373,26 @@ describe "SelectList" do
|
|
361
373
|
end
|
362
374
|
|
363
375
|
# deprecate?
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
browser.select_list(name: "new_user_languages").select_value("2")
|
368
|
-
expect(browser.select_list(name: "new_user_languages").selected_options.map(&:text)).to eq %w[English]
|
369
|
-
end
|
370
|
-
|
371
|
-
bug "https://bugzilla.mozilla.org/show_bug.cgi?id=1255957", :firefox do
|
372
|
-
it "selects the items by value regexp" do
|
376
|
+
not_compliant_on :safari do
|
377
|
+
describe "#select_value" do
|
378
|
+
it "selects the item by value string" do
|
373
379
|
browser.select_list(name: "new_user_languages").clear
|
374
|
-
browser.select_list(name: "new_user_languages").select_value(
|
375
|
-
expect(browser.select_list(name: "new_user_languages").selected_options.map(&:text)).to eq %w[
|
380
|
+
browser.select_list(name: "new_user_languages").select_value("2")
|
381
|
+
expect(browser.select_list(name: "new_user_languages").selected_options.map(&:text)).to eq %w[English]
|
376
382
|
end
|
377
|
-
end
|
378
383
|
|
379
|
-
|
380
|
-
|
381
|
-
|
384
|
+
bug "https://bugzilla.mozilla.org/show_bug.cgi?id=1255957", :firefox do
|
385
|
+
it "selects the items by value regexp" do
|
386
|
+
browser.select_list(name: "new_user_languages").clear
|
387
|
+
browser.select_list(name: "new_user_languages").select_value(/1|3/)
|
388
|
+
expect(browser.select_list(name: "new_user_languages").selected_options.map(&:text)).to eq %w[Danish Norwegian]
|
389
|
+
end
|
390
|
+
end
|
391
|
+
|
392
|
+
it "raises NoValueFoundException if the option doesn't exist" do
|
393
|
+
expect { browser.select_list(name: "new_user_languages").select_value("no_such_option") }.to raise_no_value_found_exception
|
394
|
+
expect { browser.select_list(name: "new_user_languages").select_value(/no_such_option/) }.to raise_no_value_found_exception
|
395
|
+
end
|
382
396
|
end
|
383
397
|
end
|
384
398
|
|