watir 6.13.0 → 6.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +141 -0
- data/.travis.yml +6 -0
- data/CHANGES.md +12 -0
- data/Gemfile +4 -10
- data/README.md +64 -49
- data/Rakefile +28 -16
- data/lib/watir.rb +13 -15
- data/lib/watir/adjacent.rb +15 -13
- data/lib/watir/after_hooks.rb +8 -10
- data/lib/watir/alert.rb +7 -8
- data/lib/watir/aliases.rb +2 -2
- data/lib/watir/attribute_helper.rb +18 -20
- data/lib/watir/browser.rb +42 -75
- data/lib/watir/capabilities.rb +19 -10
- data/lib/watir/cell_container.rb +0 -2
- data/lib/watir/container.rb +4 -4
- data/lib/watir/cookies.rb +7 -8
- data/lib/watir/element_collection.rb +37 -22
- data/lib/watir/elements/area.rb +0 -2
- data/lib/watir/elements/button.rb +1 -3
- data/lib/watir/elements/cell.rb +0 -1
- data/lib/watir/elements/checkbox.rb +5 -7
- data/lib/watir/elements/date_field.rb +5 -9
- data/lib/watir/elements/date_time_field.rb +6 -10
- data/lib/watir/elements/dlist.rb +2 -4
- data/lib/watir/elements/element.rb +201 -99
- data/lib/watir/elements/file_field.rb +3 -4
- data/lib/watir/elements/font.rb +2 -4
- data/lib/watir/elements/form.rb +0 -2
- data/lib/watir/elements/hidden.rb +3 -4
- data/lib/watir/elements/html_elements.rb +24 -76
- data/lib/watir/elements/iframe.rb +57 -71
- data/lib/watir/elements/image.rb +3 -4
- data/lib/watir/elements/input.rb +0 -2
- data/lib/watir/elements/link.rb +2 -5
- data/lib/watir/elements/list.rb +4 -4
- data/lib/watir/elements/option.rb +3 -6
- data/lib/watir/elements/radio.rb +4 -6
- data/lib/watir/elements/row.rb +0 -1
- data/lib/watir/elements/select.rb +41 -43
- data/lib/watir/elements/svg_elements.rb +0 -116
- data/lib/watir/elements/table.rb +1 -2
- data/lib/watir/elements/table_cell.rb +2 -3
- data/lib/watir/elements/text_field.rb +4 -6
- data/lib/watir/exception.rb +0 -1
- data/lib/watir/extensions/nokogiri.rb +2 -4
- data/lib/watir/generator.rb +3 -3
- data/lib/watir/generator/base.rb +10 -10
- data/lib/watir/generator/base/generator.rb +26 -29
- data/lib/watir/generator/base/idl_sorter.rb +34 -32
- data/lib/watir/generator/base/spec_extractor.rb +132 -114
- data/lib/watir/generator/base/util.rb +1 -3
- data/lib/watir/generator/base/visitor.rb +140 -140
- data/lib/watir/generator/html.rb +4 -4
- data/lib/watir/generator/html/generator.rb +2 -4
- data/lib/watir/generator/html/spec_extractor.rb +33 -33
- data/lib/watir/generator/html/visitor.rb +14 -14
- data/lib/watir/generator/svg.rb +3 -3
- data/lib/watir/generator/svg/generator.rb +1 -3
- data/lib/watir/generator/svg/spec_extractor.rb +35 -35
- data/lib/watir/generator/svg/visitor.rb +14 -14
- data/lib/watir/has_window.rb +2 -4
- data/lib/watir/js_execution.rb +7 -9
- data/lib/watir/js_snippets.rb +3 -3
- data/lib/watir/js_snippets/attributeValues.js +11 -0
- data/lib/watir/legacy_wait.rb +7 -12
- data/lib/watir/locators.rb +9 -11
- data/lib/watir/locators/button/locator.rb +2 -3
- data/lib/watir/locators/button/selector_builder.rb +9 -9
- data/lib/watir/locators/button/selector_builder/xpath.rb +1 -1
- data/lib/watir/locators/button/validator.rb +2 -2
- data/lib/watir/locators/cell/locator.rb +0 -2
- data/lib/watir/locators/cell/selector_builder.rb +3 -5
- data/lib/watir/locators/element/locator.rb +85 -64
- data/lib/watir/locators/element/selector_builder.rb +40 -38
- data/lib/watir/locators/element/selector_builder/xpath.rb +20 -18
- data/lib/watir/locators/element/validator.rb +1 -1
- data/lib/watir/locators/row/locator.rb +0 -2
- data/lib/watir/locators/row/selector_builder.rb +6 -9
- data/lib/watir/locators/text_area/selector_builder.rb +1 -1
- data/lib/watir/locators/text_field/locator.rb +1 -3
- data/lib/watir/locators/text_field/selector_builder.rb +5 -5
- data/lib/watir/locators/text_field/selector_builder/xpath.rb +1 -1
- data/lib/watir/locators/text_field/validator.rb +3 -2
- data/lib/watir/logger.rb +11 -21
- data/lib/watir/navigation.rb +49 -0
- data/lib/watir/radio_set.rb +17 -18
- data/lib/watir/row_container.rb +3 -5
- data/lib/watir/screenshot.rb +2 -4
- data/lib/watir/user_editable.rb +13 -8
- data/lib/watir/version.rb +3 -0
- data/lib/watir/wait.rb +56 -55
- data/lib/watir/wait/timer.rb +1 -3
- data/lib/watir/window.rb +36 -45
- data/lib/watir/xpath_support.rb +1 -3
- data/lib/watirspec.rb +11 -11
- data/lib/watirspec/guards.rb +10 -7
- data/lib/watirspec/implementation.rb +3 -4
- data/lib/watirspec/rake_tasks.rb +30 -29
- data/lib/watirspec/remote_server.rb +3 -3
- data/lib/watirspec/runner.rb +1 -2
- data/lib/watirspec/server.rb +3 -0
- data/lib/watirspec/server/app.rb +14 -6
- data/spec/implementation_spec.rb +9 -9
- data/spec/locator_spec_helper.rb +3 -4
- data/spec/spec_helper.rb +3 -7
- data/spec/unit/container_spec.rb +9 -10
- data/spec/unit/element_locator_spec.rb +224 -219
- data/spec/unit/logger_spec.rb +4 -4
- data/spec/unit/unit_helper.rb +0 -2
- data/spec/unit/wait_spec.rb +26 -28
- data/spec/watirspec/adjacent_spec.rb +130 -130
- data/spec/watirspec/after_hooks_spec.rb +63 -63
- data/spec/watirspec/alert_spec.rb +6 -6
- data/spec/watirspec/attributes_spec.rb +6 -6
- data/spec/watirspec/browser_spec.rb +161 -162
- data/spec/watirspec/click_spec.rb +9 -9
- data/spec/watirspec/cookies_spec.rb +15 -14
- data/spec/watirspec/drag_and_drop_spec.rb +15 -16
- data/spec/watirspec/element_hidden_spec.rb +19 -21
- data/spec/watirspec/elements/area_spec.rb +18 -21
- data/spec/watirspec/elements/areas_spec.rb +13 -15
- data/spec/watirspec/elements/button_spec.rb +96 -99
- data/spec/watirspec/elements/buttons_spec.rb +17 -19
- data/spec/watirspec/elements/checkbox_spec.rb +102 -100
- data/spec/watirspec/elements/checkboxes_spec.rb +13 -15
- data/spec/watirspec/elements/collections_spec.rb +35 -37
- data/spec/watirspec/elements/date_field_spec.rb +46 -47
- data/spec/watirspec/elements/date_fields_spec.rb +13 -15
- data/spec/watirspec/elements/date_time_field_spec.rb +62 -57
- data/spec/watirspec/elements/date_time_fields_spec.rb +14 -15
- data/spec/watirspec/elements/dd_spec.rb +46 -48
- data/spec/watirspec/elements/dds_spec.rb +13 -15
- data/spec/watirspec/elements/del_spec.rb +27 -28
- data/spec/watirspec/elements/dels_spec.rb +13 -15
- data/spec/watirspec/elements/div_spec.rb +89 -91
- data/spec/watirspec/elements/divs_spec.rb +17 -19
- data/spec/watirspec/elements/dl_spec.rb +52 -54
- data/spec/watirspec/elements/dls_spec.rb +13 -15
- data/spec/watirspec/elements/dt_spec.rb +46 -48
- data/spec/watirspec/elements/dts_spec.rb +13 -15
- data/spec/watirspec/elements/element_spec.rb +240 -189
- data/spec/watirspec/elements/elements_spec.rb +16 -16
- data/spec/watirspec/elements/em_spec.rb +38 -40
- data/spec/watirspec/elements/ems_spec.rb +13 -15
- data/spec/watirspec/elements/filefield_spec.rb +45 -46
- data/spec/watirspec/elements/filefields_spec.rb +13 -15
- data/spec/watirspec/elements/font_spec.rb +11 -13
- data/spec/watirspec/elements/form_spec.rb +13 -15
- data/spec/watirspec/elements/forms_spec.rb +13 -15
- data/spec/watirspec/elements/frame_spec.rb +48 -50
- data/spec/watirspec/elements/frames_spec.rb +13 -15
- data/spec/watirspec/elements/hidden_spec.rb +23 -25
- data/spec/watirspec/elements/hiddens_spec.rb +13 -15
- data/spec/watirspec/elements/hn_spec.rb +22 -24
- data/spec/watirspec/elements/hns_spec.rb +13 -13
- data/spec/watirspec/elements/iframe_spec.rb +106 -74
- data/spec/watirspec/elements/iframes_spec.rb +16 -18
- data/spec/watirspec/elements/image_spec.rb +30 -32
- data/spec/watirspec/elements/images_spec.rb +13 -15
- data/spec/watirspec/elements/input_spec.rb +4 -5
- data/spec/watirspec/elements/ins_spec.rb +27 -29
- data/spec/watirspec/elements/inses_spec.rb +13 -15
- data/spec/watirspec/elements/label_spec.rb +17 -19
- data/spec/watirspec/elements/labels_spec.rb +13 -15
- data/spec/watirspec/elements/li_spec.rb +23 -25
- data/spec/watirspec/elements/link_spec.rb +45 -48
- data/spec/watirspec/elements/links_spec.rb +14 -16
- data/spec/watirspec/elements/lis_spec.rb +13 -15
- data/spec/watirspec/elements/list_spec.rb +14 -15
- data/spec/watirspec/elements/map_spec.rb +19 -20
- data/spec/watirspec/elements/maps_spec.rb +13 -15
- data/spec/watirspec/elements/meta_spec.rb +10 -10
- data/spec/watirspec/elements/metas_spec.rb +13 -15
- data/spec/watirspec/elements/ol_spec.rb +20 -21
- data/spec/watirspec/elements/ols_spec.rb +13 -15
- data/spec/watirspec/elements/option_spec.rb +63 -63
- data/spec/watirspec/elements/p_spec.rb +27 -26
- data/spec/watirspec/elements/pre_spec.rb +24 -25
- data/spec/watirspec/elements/pres_spec.rb +13 -15
- data/spec/watirspec/elements/ps_spec.rb +13 -15
- data/spec/watirspec/elements/radio_spec.rb +96 -97
- data/spec/watirspec/elements/radios_spec.rb +13 -15
- data/spec/watirspec/elements/select_list_spec.rb +244 -237
- data/spec/watirspec/elements/select_lists_spec.rb +15 -16
- data/spec/watirspec/elements/span_spec.rb +32 -31
- data/spec/watirspec/elements/spans_spec.rb +13 -15
- data/spec/watirspec/elements/strong_spec.rb +23 -24
- data/spec/watirspec/elements/strongs_spec.rb +13 -15
- data/spec/watirspec/elements/table_nesting_spec.rb +15 -14
- data/spec/watirspec/elements/table_spec.rb +61 -62
- data/spec/watirspec/elements/tables_spec.rb +15 -17
- data/spec/watirspec/elements/tbody_spec.rb +25 -26
- data/spec/watirspec/elements/tbodys_spec.rb +17 -19
- data/spec/watirspec/elements/td_spec.rb +20 -22
- data/spec/watirspec/elements/tds_spec.rb +9 -11
- data/spec/watirspec/elements/text_field_spec.rb +55 -56
- data/spec/watirspec/elements/text_fields_spec.rb +15 -16
- data/spec/watirspec/elements/textarea_spec.rb +2 -2
- data/spec/watirspec/elements/textareas_spec.rb +1 -1
- data/spec/watirspec/elements/tfoot_spec.rb +22 -23
- data/spec/watirspec/elements/tfoots_spec.rb +19 -19
- data/spec/watirspec/elements/thead_spec.rb +21 -23
- data/spec/watirspec/elements/theads_spec.rb +19 -19
- data/spec/watirspec/elements/tr_spec.rb +20 -22
- data/spec/watirspec/elements/trs_spec.rb +17 -19
- data/spec/watirspec/elements/ul_spec.rb +17 -19
- data/spec/watirspec/elements/uls_spec.rb +13 -14
- data/spec/watirspec/html/data_attributes.html +1 -0
- data/spec/watirspec/radio_set_spec.rb +100 -99
- data/spec/watirspec/relaxed_locate_spec.rb +19 -43
- data/spec/watirspec/screenshot_spec.rb +4 -4
- data/spec/watirspec/special_chars_spec.rb +2 -4
- data/spec/watirspec/support/rspec_matchers.rb +85 -22
- data/spec/watirspec/user_editable_spec.rb +84 -85
- data/spec/watirspec/wait_spec.rb +74 -95
- data/spec/watirspec/window_switching_spec.rb +131 -132
- data/spec/watirspec_helper.rb +12 -9
- data/support/travis.sh +4 -0
- data/support/version_differ.rb +12 -13
- data/watir.gemspec +29 -22
- metadata +76 -50
data/spec/watirspec/wait_spec.rb
CHANGED
@@ -1,31 +1,32 @@
|
|
1
|
-
require
|
1
|
+
require 'watirspec_helper'
|
2
2
|
|
3
3
|
describe Watir::Element do
|
4
4
|
before do
|
5
|
-
browser.goto WatirSpec.url_for(
|
5
|
+
browser.goto WatirSpec.url_for('wait.html')
|
6
6
|
end
|
7
7
|
|
8
8
|
# TODO: This is deprecated; remove in future version
|
9
9
|
not_compliant_on :relaxed_locate do
|
10
|
-
describe
|
11
|
-
it
|
10
|
+
describe '#when_present' do
|
11
|
+
it 'invokes subsequent method calls when the element becomes present' do
|
12
12
|
browser.a(id: 'show_bar').click
|
13
13
|
|
14
14
|
bar = browser.div(id: 'bar')
|
15
15
|
bar.when_present(2).click
|
16
|
-
expect(bar.text).to eq
|
16
|
+
expect(bar.text).to eq 'changed'
|
17
17
|
end
|
18
18
|
|
19
|
-
it
|
19
|
+
it 'times out when given a block' do
|
20
20
|
expect { browser.div(id: 'bar').when_present(1) {} }.to raise_error(Watir::Wait::TimeoutError)
|
21
21
|
end
|
22
22
|
|
23
|
-
it
|
24
|
-
|
25
|
-
|
23
|
+
it 'times out when not given a block' do
|
24
|
+
locator = '(\{:id=>"bar", :tag_name=>"div"\}|\{:tag_name=>"div", :id=>"bar"\})'
|
25
|
+
msg = /^timed out after 1 seconds, waiting for #{locator} to become present$/
|
26
|
+
expect { browser.div(id: 'bar').when_present(1).click }.to raise_error(Watir::Wait::TimeoutError, msg)
|
26
27
|
end
|
27
28
|
|
28
|
-
it
|
29
|
+
it 'responds to Element methods' do
|
29
30
|
decorator = browser.div.when_present
|
30
31
|
|
31
32
|
expect(decorator).to respond_to(:exist?)
|
@@ -33,17 +34,17 @@ describe Watir::Element do
|
|
33
34
|
expect(decorator).to respond_to(:click)
|
34
35
|
end
|
35
36
|
|
36
|
-
it
|
37
|
+
it 'delegates present? to element' do
|
37
38
|
Object.class_eval do
|
38
39
|
def present?
|
39
40
|
false
|
40
41
|
end
|
41
42
|
end
|
42
|
-
element = browser.a(id:
|
43
|
+
element = browser.a(id: 'show_bar').when_present(1)
|
43
44
|
expect(element).to be_present
|
44
45
|
end
|
45
46
|
|
46
|
-
it
|
47
|
+
it 'processes before calling present?' do
|
47
48
|
browser.a(id: 'show_bar').click
|
48
49
|
expect(browser.div(id: 'bar').when_present.present?).to be true
|
49
50
|
end
|
@@ -51,7 +52,7 @@ describe Watir::Element do
|
|
51
52
|
end
|
52
53
|
|
53
54
|
compliant_on :relaxed_locate do
|
54
|
-
it
|
55
|
+
it 'clicking automatically waits until the element appears' do
|
55
56
|
browser.a(id: 'show_bar').click
|
56
57
|
expect { browser.div(id: 'bar').click }.to_not raise_exception
|
57
58
|
expect(browser.div(id: 'bar').text).to eq 'changed'
|
@@ -64,12 +65,11 @@ describe Watir::Element do
|
|
64
65
|
it "raises exception if the element doesn't become enabled" do
|
65
66
|
expect { browser.button(id: 'btn').click }.to raise_object_disabled_exception
|
66
67
|
end
|
67
|
-
|
68
68
|
end
|
69
69
|
|
70
70
|
not_compliant_on :relaxed_locate do
|
71
|
-
describe
|
72
|
-
it
|
71
|
+
describe '#wait_until &:enabled?' do
|
72
|
+
it 'invokes subsequent method calls when the element becomes enabled' do
|
73
73
|
browser.a(id: 'enable_btn').click
|
74
74
|
|
75
75
|
btn = browser.button(id: 'btn')
|
@@ -78,7 +78,7 @@ describe Watir::Element do
|
|
78
78
|
expect(btn.disabled?).to be true
|
79
79
|
end
|
80
80
|
|
81
|
-
it
|
81
|
+
it 'times out' do
|
82
82
|
error = Watir::Wait::TimeoutError
|
83
83
|
inspected = '#<Watir::Button: located: true; {:id=>"btn", :tag_name=>"button"}>'
|
84
84
|
message = "timed out after 1 seconds, waiting for true condition on #{inspected}"
|
@@ -86,7 +86,7 @@ describe Watir::Element do
|
|
86
86
|
expect { element.wait_until(timeout: 1, &:enabled?).click }.to raise_error(error, message)
|
87
87
|
end
|
88
88
|
|
89
|
-
it
|
89
|
+
it 'responds to Element methods' do
|
90
90
|
element = browser.button.wait_until { true }
|
91
91
|
|
92
92
|
expect(element).to respond_to(:exist?)
|
@@ -94,7 +94,7 @@ describe Watir::Element do
|
|
94
94
|
expect(element).to respond_to(:click)
|
95
95
|
end
|
96
96
|
|
97
|
-
it
|
97
|
+
it 'can be chained with #wait_until &:present?' do
|
98
98
|
browser.a(id: 'show_and_enable_btn').click
|
99
99
|
browser.button(id: 'btn2').wait_until(&:present?).wait_until(&:enabled?).click
|
100
100
|
|
@@ -104,13 +104,13 @@ describe Watir::Element do
|
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
-
describe
|
108
|
-
it
|
107
|
+
describe '#wait_until_present' do
|
108
|
+
it 'waits until the element appears' do
|
109
109
|
browser.a(id: 'show_bar').click
|
110
110
|
expect { browser.div(id: 'bar').wait_until_present(timeout: 5) }.to_not raise_exception
|
111
111
|
end
|
112
112
|
|
113
|
-
it
|
113
|
+
it 'waits until the element re-appears' do
|
114
114
|
browser.link(id: 'readd_bar').click
|
115
115
|
expect { browser.div(id: 'bar').wait_until_present }.to_not raise_exception
|
116
116
|
end
|
@@ -118,24 +118,21 @@ describe Watir::Element do
|
|
118
118
|
it "times out if the element doesn't appear" do
|
119
119
|
inspected = '#<Watir::Div: located: true; {:id=>"bar", :tag_name=>"div"}>'
|
120
120
|
error = Watir::Wait::TimeoutError
|
121
|
-
message = "timed out after 1 seconds, waiting for
|
121
|
+
message = "timed out after 1 seconds, waiting for element #{inspected} to become present"
|
122
122
|
|
123
123
|
expect { browser.div(id: 'bar').wait_until_present(timeout: 1) }.to raise_error(error, message)
|
124
124
|
end
|
125
125
|
|
126
|
-
it
|
126
|
+
it 'uses provided interval' do
|
127
127
|
element = browser.div(id: 'bar')
|
128
128
|
expect(element).to receive(:present?).twice
|
129
129
|
|
130
|
-
|
131
|
-
element.wait_until_present(timeout: 0.4, interval: 0.2)
|
132
|
-
rescue Watir::Wait::TimeoutError
|
133
|
-
end
|
130
|
+
expect { element.wait_until_present(timeout: 0.4, interval: 0.2) }.to raise_timeout_exception
|
134
131
|
end
|
135
132
|
end
|
136
133
|
|
137
|
-
describe
|
138
|
-
it
|
134
|
+
describe '#wait_while_present' do
|
135
|
+
it 'waits until the element disappears' do
|
139
136
|
browser.a(id: 'hide_foo').click
|
140
137
|
expect { browser.div(id: 'foo').wait_while_present(timeout: 2) }.to_not raise_exception
|
141
138
|
end
|
@@ -143,21 +140,18 @@ describe Watir::Element do
|
|
143
140
|
it "times out if the element doesn't disappear" do
|
144
141
|
error = Watir::Wait::TimeoutError
|
145
142
|
inspected = '#<Watir::Div: located: true; {:id=>"foo", :tag_name=>"div"}>'
|
146
|
-
message = "timed out after 1 seconds, waiting for
|
143
|
+
message = "timed out after 1 seconds, waiting for element #{inspected} not to be present"
|
147
144
|
expect { browser.div(id: 'foo').wait_while_present(timeout: 1) }.to raise_error(error, message)
|
148
145
|
end
|
149
146
|
|
150
|
-
it
|
147
|
+
it 'uses provided interval' do
|
151
148
|
element = browser.div(id: 'foo')
|
152
149
|
expect(element).to receive(:present?).twice
|
153
150
|
|
154
|
-
|
155
|
-
element.wait_until_present(timeout: 0.4, interval: 0.2)
|
156
|
-
rescue Watir::Wait::TimeoutError
|
157
|
-
end
|
151
|
+
expect { element.wait_until_present(timeout: 0.4, interval: 0.2) }.to raise_timeout_exception
|
158
152
|
end
|
159
153
|
|
160
|
-
it
|
154
|
+
it 'does not error when element goes stale' do
|
161
155
|
element = browser.div(id: 'foo').tap(&:exists?)
|
162
156
|
|
163
157
|
allow(element).to receive(:stale?).and_return(false, true)
|
@@ -166,161 +160,161 @@ describe Watir::Element do
|
|
166
160
|
expect { element.wait_while_present(timeout: 1) }.to_not raise_exception
|
167
161
|
end
|
168
162
|
|
169
|
-
it
|
163
|
+
it 'waits until the selector no longer matches' do
|
170
164
|
element = browser.link(name: 'add_select').wait_until(&:exists?)
|
171
165
|
browser.link(id: 'change_select').click
|
172
166
|
expect { element.wait_while_present }.not_to raise_error
|
173
167
|
end
|
174
168
|
end
|
175
169
|
|
176
|
-
describe
|
177
|
-
it
|
170
|
+
describe '#wait_until' do
|
171
|
+
it 'returns element for additional actions' do
|
178
172
|
element = browser.div(id: 'foo')
|
179
173
|
expect(element.wait_until(&:exist?)).to eq element
|
180
174
|
end
|
181
175
|
|
182
|
-
it
|
176
|
+
it 'accepts self in block' do
|
183
177
|
element = browser.div(id: 'bar')
|
184
178
|
browser.a(id: 'show_bar').click
|
185
179
|
expect { element.wait_until { |el| el.text == 'bar' } }.to_not raise_exception
|
186
180
|
end
|
187
181
|
|
188
|
-
it
|
182
|
+
it 'accepts any values in block' do
|
189
183
|
element = browser.div(id: 'bar')
|
190
184
|
expect { element.wait_until { true } }.to_not raise_exception
|
191
185
|
end
|
192
186
|
|
193
|
-
it
|
187
|
+
it 'accepts just a timeout parameter' do
|
194
188
|
element = browser.div(id: 'bar')
|
195
189
|
expect { element.wait_until(timeout: 0) { true } }.to_not raise_exception
|
196
190
|
end
|
197
191
|
|
198
|
-
it
|
192
|
+
it 'accepts just a message parameter' do
|
199
193
|
element = browser.div(id: 'bar')
|
200
194
|
expect { element.wait_until(message: 'no') { true } }.to_not raise_exception
|
201
195
|
end
|
202
196
|
|
203
|
-
it
|
197
|
+
it 'accepts just an interval parameter' do
|
204
198
|
element = browser.div(id: 'bar')
|
205
199
|
expect { element.wait_until(interval: 0.1) { true } }.to_not raise_exception
|
206
200
|
end
|
207
201
|
|
208
|
-
context
|
202
|
+
context 'accepts keywords instead of block' do
|
209
203
|
before { browser.refresh }
|
210
204
|
|
211
|
-
it
|
205
|
+
it 'accepts text keyword' do
|
212
206
|
element = browser.div(id: 'bar')
|
213
207
|
browser.a(id: 'show_bar').click
|
214
208
|
expect { element.wait_until(text: 'bar') }.to_not raise_exception
|
215
209
|
end
|
216
210
|
|
217
|
-
it
|
211
|
+
it 'accepts regular expression value' do
|
218
212
|
element = browser.div(id: 'bar')
|
219
213
|
browser.a(id: 'show_bar').click
|
220
214
|
expect { element.wait_until(style: /block/) }.to_not raise_exception
|
221
215
|
end
|
222
216
|
|
223
|
-
it
|
217
|
+
it 'accepts multiple keywords' do
|
224
218
|
element = browser.div(id: 'bar')
|
225
219
|
browser.a(id: 'show_bar').click
|
226
220
|
expect { element.wait_until(text: 'bar', style: /block/) }.to_not raise_exception
|
227
221
|
end
|
228
222
|
|
229
|
-
it
|
223
|
+
it 'accepts custom keyword' do
|
230
224
|
element = browser.div(id: 'bar')
|
231
225
|
browser.a(id: 'show_bar').click
|
232
226
|
expect { element.wait_until(custom: 'bar') }.to_not raise_exception
|
233
227
|
end
|
234
228
|
|
235
|
-
it
|
229
|
+
it 'times out when single keyword not met' do
|
236
230
|
element = browser.div(id: 'bar')
|
237
231
|
expect { element.wait_until(id: 'foo') }.to raise_timeout_exception
|
238
232
|
end
|
239
233
|
|
240
|
-
it
|
234
|
+
it 'times out when one of multiple keywords not met' do
|
241
235
|
element = browser.div(id: 'bar')
|
242
236
|
expect { element.wait_until(id: 'bar', text: 'foo') }.to raise_timeout_exception
|
243
237
|
end
|
244
238
|
|
245
|
-
it
|
239
|
+
it 'times out when a custom keywords not met' do
|
246
240
|
element = browser.div(id: 'bar')
|
247
241
|
expect { element.wait_until(custom: 'foo') }.to raise_timeout_exception
|
248
242
|
end
|
249
243
|
end
|
250
244
|
end
|
251
245
|
|
252
|
-
describe
|
253
|
-
it
|
246
|
+
describe '#wait_while' do
|
247
|
+
it 'returns element for additional actions' do
|
254
248
|
element = browser.div(id: 'foo')
|
255
249
|
browser.a(id: 'hide_foo').click
|
256
250
|
expect(element.wait_while(&:present?)).to eq element
|
257
251
|
end
|
258
252
|
|
259
253
|
not_compliant_on :safari do
|
260
|
-
it
|
254
|
+
it 'accepts self in block' do
|
261
255
|
element = browser.div(id: 'foo')
|
262
256
|
browser.a(id: 'hide_foo').click
|
263
257
|
expect { element.wait_while { |el| el.text == 'foo' } }.to_not raise_exception
|
264
258
|
end
|
265
259
|
end
|
266
260
|
|
267
|
-
it
|
261
|
+
it 'accepts any values in block' do
|
268
262
|
element = browser.div(id: 'foo')
|
269
263
|
expect { element.wait_while { false } }.to_not raise_exception
|
270
264
|
end
|
271
265
|
|
272
|
-
it
|
266
|
+
it 'accepts just a timeout parameter' do
|
273
267
|
element = browser.div(id: 'foo')
|
274
268
|
expect { element.wait_while(timeout: 0) { false } }.to_not raise_exception
|
275
269
|
end
|
276
270
|
|
277
|
-
it
|
271
|
+
it 'accepts just a message parameter' do
|
278
272
|
element = browser.div(id: 'foo')
|
279
273
|
expect { element.wait_while(message: 'no') { false } }.to_not raise_exception
|
280
274
|
end
|
281
275
|
|
282
|
-
it
|
276
|
+
it 'accepts just an interval parameter' do
|
283
277
|
element = browser.div(id: 'foo')
|
284
278
|
expect { element.wait_while(interval: 0.1) { false } }.to_not raise_exception
|
285
279
|
end
|
286
280
|
|
287
|
-
context
|
288
|
-
it
|
281
|
+
context 'accepts keywords instead of block' do
|
282
|
+
it 'accepts text keyword' do
|
289
283
|
element = browser.div(id: 'foo')
|
290
284
|
browser.a(id: 'hide_foo').click
|
291
285
|
expect { element.wait_while(text: 'foo') }.to_not raise_exception
|
292
286
|
end
|
293
287
|
|
294
|
-
it
|
288
|
+
it 'accepts regular expression value' do
|
295
289
|
element = browser.div(id: 'foo')
|
296
290
|
browser.a(id: 'hide_foo').click
|
297
291
|
expect { element.wait_while(style: /block/) }.to_not raise_exception
|
298
292
|
end
|
299
293
|
|
300
|
-
it
|
294
|
+
it 'accepts multiple keywords' do
|
301
295
|
element = browser.div(id: 'foo')
|
302
296
|
browser.a(id: 'hide_foo').click
|
303
297
|
expect { element.wait_while(text: 'foo', style: /block/) }.to_not raise_exception
|
304
298
|
end
|
305
299
|
|
306
|
-
it
|
300
|
+
it 'accepts custom attributes' do
|
307
301
|
element = browser.div(id: 'foo')
|
308
302
|
browser.a(id: 'hide_foo').click
|
309
303
|
expect { element.wait_while(custom: '') }.to_not raise_exception
|
310
304
|
end
|
311
305
|
|
312
|
-
it
|
306
|
+
it 'times out when single keyword not met' do
|
313
307
|
element = browser.div(id: 'foo')
|
314
308
|
expect { element.wait_while(id: 'foo') }.to raise_timeout_exception
|
315
309
|
end
|
316
310
|
|
317
|
-
it
|
311
|
+
it 'times out when one of multiple keywords not met' do
|
318
312
|
element = browser.div(id: 'foo')
|
319
313
|
browser.a(id: 'hide_foo').click
|
320
314
|
expect { element.wait_while(id: 'foo', style: /block/) }.to raise_timeout_exception
|
321
315
|
end
|
322
316
|
|
323
|
-
it
|
317
|
+
it 'times out when one of custom keywords not met' do
|
324
318
|
element = browser.div(id: 'foo')
|
325
319
|
expect { element.wait_while(custom: '') }.to raise_timeout_exception
|
326
320
|
end
|
@@ -329,41 +323,26 @@ describe Watir::Element do
|
|
329
323
|
end
|
330
324
|
|
331
325
|
describe Watir do
|
332
|
-
describe
|
326
|
+
describe '#default_timeout' do
|
333
327
|
before do
|
334
|
-
|
335
|
-
|
336
|
-
browser.goto WatirSpec.url_for("wait.html")
|
337
|
-
end
|
338
|
-
|
339
|
-
after do
|
340
|
-
# Reset the default timeout
|
341
|
-
Watir.default_timeout = 30
|
328
|
+
browser.goto WatirSpec.url_for('wait.html')
|
342
329
|
end
|
343
330
|
|
344
|
-
context
|
345
|
-
it
|
346
|
-
expect {
|
347
|
-
Watir::Wait.until { false }
|
348
|
-
}.to raise_error(Watir::Wait::TimeoutError)
|
331
|
+
context 'when no timeout is specified' do
|
332
|
+
it 'is used by Wait#until' do
|
333
|
+
expect { Watir::Wait.until { false } }.to wait_and_raise_timeout_exception(timeout: 1)
|
349
334
|
end
|
350
335
|
|
351
|
-
it
|
352
|
-
expect {
|
353
|
-
Watir::Wait.while { true }
|
354
|
-
}.to raise_error(Watir::Wait::TimeoutError)
|
336
|
+
it 'is used by Wait#while' do
|
337
|
+
expect { Watir::Wait.while { true } }.to wait_and_raise_timeout_exception(timeout: 1)
|
355
338
|
end
|
356
339
|
|
357
|
-
it
|
358
|
-
expect {
|
359
|
-
browser.div(id: 'bar').wait_until_present
|
360
|
-
}.to raise_error(Watir::Wait::TimeoutError)
|
340
|
+
it 'is used by Element#wait_until_present' do
|
341
|
+
expect { browser.div(id: 'bar').wait_until_present }.to wait_and_raise_timeout_exception(timeout: 1)
|
361
342
|
end
|
362
343
|
|
363
|
-
it
|
364
|
-
expect {
|
365
|
-
browser.div(id: 'foo').wait_while_present
|
366
|
-
}.to raise_error(Watir::Wait::TimeoutError)
|
344
|
+
it 'is used by Element#wait_while_present' do
|
345
|
+
expect { browser.div(id: 'foo').wait_while_present }.to wait_and_raise_timeout_exception(timeout: 1)
|
367
346
|
end
|
368
347
|
end
|
369
348
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require 'watirspec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe 'Browser' do
|
4
4
|
before do
|
5
|
-
url = WatirSpec.url_for(
|
5
|
+
url = WatirSpec.url_for('window_switching.html')
|
6
6
|
browser.goto url
|
7
|
-
browser.a(id:
|
7
|
+
browser.a(id: 'open').click
|
8
8
|
Watir::Wait.until { browser.windows.size == 2 }
|
9
9
|
end
|
10
10
|
|
@@ -13,93 +13,94 @@ describe "Browser" do
|
|
13
13
|
browser.windows.reject(&:current?).each(&:close)
|
14
14
|
end
|
15
15
|
|
16
|
-
describe
|
17
|
-
it
|
16
|
+
describe '#windows' do
|
17
|
+
it 'returns an array of window handles' do
|
18
18
|
wins = browser.windows
|
19
19
|
expect(wins).to_not be_empty
|
20
20
|
wins.each { |win| expect(win).to be_kind_of(Watir::Window) }
|
21
21
|
end
|
22
22
|
|
23
|
-
it
|
24
|
-
|
23
|
+
it 'only returns windows matching the given selector' do
|
24
|
+
browser.wait_until { |b| b.window(title: 'closeable window').exists? }
|
25
|
+
expect(browser.windows(title: 'closeable window').size).to eq 1
|
25
26
|
end
|
26
27
|
|
27
|
-
it
|
28
|
-
expect { browser.windows(name:
|
28
|
+
it 'raises ArgumentError if the selector is invalid' do
|
29
|
+
expect { browser.windows(name: 'foo') }.to raise_error(ArgumentError)
|
29
30
|
end
|
30
31
|
|
31
|
-
it
|
32
|
-
expect(browser.windows(title:
|
32
|
+
it 'returns an empty array if no window matches the selector' do
|
33
|
+
expect(browser.windows(title: 'noop')).to eq []
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
36
|
-
describe
|
37
|
-
it
|
37
|
+
describe '#window' do
|
38
|
+
it 'finds window by :url' do
|
38
39
|
w = browser.window(url: /closeable\.html/).use
|
39
40
|
expect(w).to be_kind_of(Watir::Window)
|
40
41
|
end
|
41
42
|
|
42
|
-
it
|
43
|
-
w = browser.window(title:
|
43
|
+
it 'finds window by :title' do
|
44
|
+
w = browser.window(title: 'closeable window').use
|
44
45
|
expect(w).to be_kind_of(Watir::Window)
|
45
46
|
end
|
46
47
|
|
47
|
-
it
|
48
|
+
it 'finds window by :index' do
|
48
49
|
w = browser.window(index: 1).use
|
49
50
|
expect(w).to be_kind_of(Watir::Window)
|
50
51
|
end
|
51
52
|
|
52
|
-
it
|
53
|
+
it 'should not find incorrect handle' do
|
53
54
|
expect(browser.window(handle: 'bar')).to_not be_present
|
54
55
|
end
|
55
56
|
|
56
|
-
it
|
57
|
+
it 'returns the current window if no argument is given' do
|
57
58
|
expect(browser.window.url).to match(/window_switching\.html/)
|
58
59
|
end
|
59
60
|
|
60
|
-
it
|
61
|
+
it 'stores the reference to a window when no argument is given' do
|
61
62
|
original_window = browser.window
|
62
63
|
browser.window(index: 1).use
|
63
64
|
expect(original_window.url).to match(/window_switching\.html/)
|
64
65
|
end
|
65
66
|
|
66
|
-
bug
|
67
|
+
bug 'https://bugzilla.mozilla.org/show_bug.cgi?id=1223277', :firefox do
|
67
68
|
not_compliant_on :headless do
|
68
|
-
it
|
69
|
-
browser.window(title:
|
70
|
-
link = browser.a(id:
|
69
|
+
it 'it executes the given block in the window' do
|
70
|
+
browser.window(title: 'closeable window') {
|
71
|
+
link = browser.a(id: 'close')
|
71
72
|
expect(link).to exist
|
72
73
|
link.click
|
73
|
-
|
74
|
+
}.wait_while(&:present?)
|
74
75
|
|
75
76
|
expect(browser.windows.size).to eq 1
|
76
77
|
end
|
77
78
|
end
|
78
79
|
end
|
79
80
|
|
80
|
-
it
|
81
|
-
expect { browser.window(name:
|
81
|
+
it 'raises ArgumentError if the selector is invalid' do
|
82
|
+
expect { browser.window(name: 'foo') }.to raise_error(ArgumentError)
|
82
83
|
end
|
83
84
|
|
84
|
-
it
|
85
|
-
expect { browser.window(title:
|
85
|
+
it 'raises a NoMatchingWindowFoundException error if no window matches the selector' do
|
86
|
+
expect { browser.window(title: 'noop').use }.to raise_no_matching_window_exception
|
86
87
|
end
|
87
88
|
|
88
89
|
it "raises a NoMatchingWindowFoundException error if there's no window at the given index" do
|
89
90
|
expect { browser.window(index: 100).use }.to raise_no_matching_window_exception
|
90
91
|
end
|
91
92
|
|
92
|
-
it
|
93
|
+
it 'raises NoMatchingWindowFoundException error when attempting to use a window with an incorrect handle' do
|
93
94
|
expect { browser.window(handle: 'bar').use }.to raise_no_matching_window_exception
|
94
95
|
end
|
95
96
|
end
|
96
97
|
end
|
97
98
|
|
98
|
-
describe
|
99
|
+
describe 'Window' do
|
99
100
|
context 'multiple windows' do
|
100
101
|
before do
|
101
|
-
browser.goto WatirSpec.url_for(
|
102
|
-
browser.a(id:
|
102
|
+
browser.goto WatirSpec.url_for('window_switching.html')
|
103
|
+
browser.a(id: 'open').click
|
103
104
|
Watir::Wait.until { browser.windows.size == 2 }
|
104
105
|
end
|
105
106
|
|
@@ -108,78 +109,78 @@ describe "Window" do
|
|
108
109
|
browser.windows.reject(&:current?).each(&:close)
|
109
110
|
end
|
110
111
|
|
111
|
-
not_compliant_on :safari, %i
|
112
|
-
describe
|
113
|
-
it
|
114
|
-
browser.a(id:
|
112
|
+
not_compliant_on :safari, %i[firefox linux] do
|
113
|
+
describe '#close' do
|
114
|
+
it 'closes a window' do
|
115
|
+
browser.a(id: 'open').click
|
115
116
|
Watir::Wait.until { browser.windows.size == 3 }
|
116
117
|
|
117
|
-
browser.window(title:
|
118
|
+
browser.window(title: 'closeable window').close
|
118
119
|
expect(browser.windows.size).to eq 2
|
119
120
|
end
|
120
121
|
end
|
121
122
|
|
122
|
-
it
|
123
|
-
browser.a(id:
|
123
|
+
it 'closes the current window' do
|
124
|
+
browser.a(id: 'open').click
|
124
125
|
Watir::Wait.until { browser.windows.size == 3 }
|
125
126
|
|
126
|
-
window = browser.window(title:
|
127
|
+
window = browser.window(title: 'closeable window').use
|
127
128
|
window.close
|
128
129
|
expect(browser.windows.size).to eq 2
|
129
130
|
end
|
130
131
|
end
|
131
132
|
|
132
|
-
describe
|
133
|
-
it
|
134
|
-
browser.window(title:
|
135
|
-
expect(browser.title).to eq
|
133
|
+
describe '#use' do
|
134
|
+
it 'switches to the window' do
|
135
|
+
browser.window(title: 'closeable window').use
|
136
|
+
expect(browser.title).to eq 'closeable window'
|
136
137
|
end
|
137
138
|
end
|
138
139
|
|
139
|
-
describe
|
140
|
-
it
|
140
|
+
describe '#current?' do
|
141
|
+
it 'returns true if it is the current window' do
|
141
142
|
expect(browser.window(title: browser.title)).to be_current
|
142
143
|
end
|
143
144
|
|
144
|
-
it
|
145
|
-
expect(browser.window(title:
|
145
|
+
it 'returns false if it is not the current window' do
|
146
|
+
expect(browser.window(title: 'closeable window')).to_not be_current
|
146
147
|
end
|
147
148
|
end
|
148
149
|
|
149
|
-
describe
|
150
|
-
it
|
150
|
+
describe '#title' do
|
151
|
+
it 'returns the title of the window' do
|
151
152
|
titles = browser.windows.map(&:title)
|
152
153
|
expect(titles.size).to eq 2
|
153
154
|
|
154
|
-
expect(titles.sort).to eq [
|
155
|
+
expect(titles.sort).to eq ['window switching', 'closeable window'].sort
|
155
156
|
end
|
156
157
|
|
157
|
-
it
|
158
|
-
expect(browser.title).to eq
|
159
|
-
expect(browser.windows.find { |w| w.title ==
|
160
|
-
expect(browser.title).to eq
|
158
|
+
it 'does not change the current window' do
|
159
|
+
expect(browser.title).to eq 'window switching'
|
160
|
+
expect(browser.windows.find { |w| w.title == 'closeable window' }).to_not be_nil
|
161
|
+
expect(browser.title).to eq 'window switching'
|
161
162
|
end
|
162
163
|
end
|
163
164
|
|
164
|
-
describe
|
165
|
-
it
|
166
|
-
expect(browser.windows.select { |w| w.url =~
|
167
|
-
expect(browser.windows.select { |w| w.url =~
|
165
|
+
describe '#url' do
|
166
|
+
it 'returns the url of the window' do
|
167
|
+
expect(browser.windows.select { |w| w.url =~ /window_switching\.html/ }.size).to eq 1
|
168
|
+
expect(browser.windows.select { |w| w.url =~ /closeable\.html$/ }.size).to eq 1
|
168
169
|
end
|
169
170
|
|
170
|
-
it
|
171
|
+
it 'does not change the current window' do
|
171
172
|
expect(browser.url).to match(/window_switching\.html/)
|
172
|
-
expect(browser.windows.find { |w| w.url =~
|
173
|
+
expect(browser.windows.find { |w| w.url =~ /closeable\.html/ }).to_not be_nil
|
173
174
|
expect(browser.url).to match(/window_switching/)
|
174
175
|
end
|
175
176
|
end
|
176
177
|
|
177
|
-
describe
|
178
|
-
it
|
178
|
+
describe '#eql?' do
|
179
|
+
it 'knows when two windows are equal' do
|
179
180
|
expect(browser.window).to eq browser.window(index: 0)
|
180
181
|
end
|
181
182
|
|
182
|
-
it
|
183
|
+
it 'knows when two windows are not equal' do
|
183
184
|
win1 = browser.window(index: 0)
|
184
185
|
win2 = browser.window(index: 1)
|
185
186
|
|
@@ -188,20 +189,20 @@ describe "Window" do
|
|
188
189
|
end
|
189
190
|
|
190
191
|
not_compliant_on :relaxed_locate do
|
191
|
-
describe
|
192
|
-
it
|
192
|
+
describe '#wait_until &:present?' do
|
193
|
+
it 'times out waiting for a non-present window' do
|
193
194
|
expect {
|
194
|
-
browser.window(title:
|
195
|
+
browser.window(title: 'noop').wait_until(timeout: 0.5, &:present?)
|
195
196
|
}.to raise_error(Watir::Wait::TimeoutError)
|
196
197
|
end
|
197
198
|
end
|
198
199
|
end
|
199
200
|
end
|
200
201
|
|
201
|
-
context
|
202
|
+
context 'with a closed window' do
|
202
203
|
before do
|
203
|
-
browser.goto WatirSpec.url_for(
|
204
|
-
browser.a(id:
|
204
|
+
browser.goto WatirSpec.url_for('window_switching.html')
|
205
|
+
browser.a(id: 'open').click
|
205
206
|
Watir::Wait.until { browser.windows.size == 2 }
|
206
207
|
end
|
207
208
|
|
@@ -210,20 +211,20 @@ describe "Window" do
|
|
210
211
|
browser.windows.reject(&:current?).each(&:close)
|
211
212
|
end
|
212
213
|
|
213
|
-
bug
|
214
|
+
bug 'https://bugzilla.mozilla.org/show_bug.cgi?id=1223277', :firefox do
|
214
215
|
not_compliant_on :headless do
|
215
|
-
describe
|
216
|
-
it
|
217
|
-
window = browser.window(title:
|
216
|
+
describe '#exists?' do
|
217
|
+
it 'returns false if previously referenced window is closed' do
|
218
|
+
window = browser.window(title: 'closeable window')
|
218
219
|
window.use
|
219
|
-
browser.a(id:
|
220
|
+
browser.a(id: 'close').click
|
220
221
|
Watir::Wait.until { browser.windows.size == 1 }
|
221
222
|
expect(window).to_not be_present
|
222
223
|
end
|
223
224
|
|
224
|
-
it
|
225
|
-
browser.window(title:
|
226
|
-
browser.a(id:
|
225
|
+
it 'returns false if closed window is referenced' do
|
226
|
+
browser.window(title: 'closeable window').use
|
227
|
+
browser.a(id: 'close').click
|
227
228
|
Watir::Wait.until { browser.windows.size == 1 }
|
228
229
|
expect(browser.window).to_not be_present
|
229
230
|
end
|
@@ -231,18 +232,18 @@ describe "Window" do
|
|
231
232
|
end
|
232
233
|
end
|
233
234
|
|
234
|
-
describe
|
235
|
-
it
|
235
|
+
describe '#current?' do
|
236
|
+
it 'returns false if the referenced window is closed' do
|
236
237
|
original_window = browser.window
|
237
|
-
browser.window(title:
|
238
|
+
browser.window(title: 'closeable window').use
|
238
239
|
original_window.close
|
239
240
|
expect(original_window).to_not be_current
|
240
241
|
end
|
241
242
|
end
|
242
243
|
|
243
244
|
not_compliant_on :safari, :headless do
|
244
|
-
describe
|
245
|
-
it
|
245
|
+
describe '#eql?' do
|
246
|
+
it 'should return false when checking equivalence to a closed window' do
|
246
247
|
original_window = browser.window
|
247
248
|
other_window = browser.window(index: 1)
|
248
249
|
other_window.use
|
@@ -253,18 +254,18 @@ describe "Window" do
|
|
253
254
|
end
|
254
255
|
|
255
256
|
not_compliant_on :headless do
|
256
|
-
describe
|
257
|
-
it
|
257
|
+
describe '#use' do
|
258
|
+
it 'raises NoMatchingWindowFoundException error when attempting to use a referenced window that is closed' do
|
258
259
|
original_window = browser.window
|
259
260
|
browser.window(index: 1).use
|
260
261
|
original_window.close
|
261
262
|
expect { original_window.use }.to raise_no_matching_window_exception
|
262
263
|
end
|
263
264
|
|
264
|
-
bug
|
265
|
-
it
|
266
|
-
browser.window(title:
|
267
|
-
browser.a(id:
|
265
|
+
bug 'https://bugzilla.mozilla.org/show_bug.cgi?id=1223277', :firefox do
|
266
|
+
it 'raises NoMatchingWindowFoundException error when attempting to use the current window if it is closed' do
|
267
|
+
browser.window(title: 'closeable window').use
|
268
|
+
browser.a(id: 'close').click
|
268
269
|
Watir::Wait.until { browser.windows.size == 1 }
|
269
270
|
expect { browser.window.use }.to raise_no_matching_window_exception
|
270
271
|
end
|
@@ -273,15 +274,15 @@ describe "Window" do
|
|
273
274
|
end
|
274
275
|
end
|
275
276
|
|
276
|
-
bug
|
277
|
+
bug 'https://bugzilla.mozilla.org/show_bug.cgi?id=1223277', :firefox do
|
277
278
|
not_compliant_on :headless do
|
278
|
-
context
|
279
|
+
context 'with current window closed' do
|
279
280
|
before do
|
280
|
-
browser.goto WatirSpec.url_for(
|
281
|
-
browser.a(id:
|
281
|
+
browser.goto WatirSpec.url_for('window_switching.html')
|
282
|
+
browser.a(id: 'open').click
|
282
283
|
Watir::Wait.until { browser.windows.size == 2 }
|
283
|
-
browser.window(title:
|
284
|
-
browser.a(id:
|
284
|
+
browser.window(title: 'closeable window').use
|
285
|
+
browser.a(id: 'close').click
|
285
286
|
Watir::Wait.until { browser.windows.size == 1 }
|
286
287
|
end
|
287
288
|
|
@@ -290,65 +291,63 @@ describe "Window" do
|
|
290
291
|
browser.windows[1..-1].each(&:close)
|
291
292
|
end
|
292
293
|
|
293
|
-
describe
|
294
|
-
it
|
294
|
+
describe '#present?' do
|
295
|
+
it 'should find window by index' do
|
295
296
|
expect(browser.window(index: 0)).to be_present
|
296
297
|
end
|
297
298
|
|
298
|
-
it
|
299
|
+
it 'should find window by url' do
|
299
300
|
expect(browser.window(url: /window_switching\.html/)).to be_present
|
300
301
|
end
|
301
302
|
|
302
|
-
it
|
303
|
-
expect(browser.window(title:
|
303
|
+
it 'should find window by title' do
|
304
|
+
expect(browser.window(title: 'window switching')).to be_present
|
304
305
|
end
|
305
306
|
end
|
306
307
|
|
307
|
-
describe
|
308
|
-
|
309
|
-
|
310
|
-
it "by index" do
|
308
|
+
describe '#use' do
|
309
|
+
context 'switching windows without blocks' do
|
310
|
+
it 'by index' do
|
311
311
|
browser.window(index: 0).use
|
312
|
-
expect(browser.title).to be ==
|
312
|
+
expect(browser.title).to be == 'window switching'
|
313
313
|
end
|
314
314
|
|
315
|
-
it
|
315
|
+
it 'by url' do
|
316
316
|
browser.window(url: /window_switching\.html/).use
|
317
|
-
expect(browser.title).to be ==
|
317
|
+
expect(browser.title).to be == 'window switching'
|
318
318
|
end
|
319
319
|
|
320
|
-
it
|
321
|
-
browser.window(title:
|
320
|
+
it 'by title' do
|
321
|
+
browser.window(title: 'window switching').use
|
322
322
|
expect(browser.url).to match(/window_switching\.html/)
|
323
323
|
end
|
324
324
|
end
|
325
325
|
|
326
|
-
context
|
327
|
-
it
|
328
|
-
browser.window(index: 0).use { expect(browser.title).to be ==
|
326
|
+
context 'Switching windows with blocks' do
|
327
|
+
it 'by index' do
|
328
|
+
browser.window(index: 0).use { expect(browser.title).to be == 'window switching' }
|
329
329
|
end
|
330
330
|
|
331
|
-
it
|
332
|
-
browser.window(url: /window_switching\.html/).use { expect(browser.title).to be ==
|
331
|
+
it 'by url' do
|
332
|
+
browser.window(url: /window_switching\.html/).use { expect(browser.title).to be == 'window switching' }
|
333
333
|
end
|
334
334
|
|
335
|
-
it
|
336
|
-
browser.window(title:
|
335
|
+
it 'by title' do
|
336
|
+
browser.window(title: 'window switching').use { expect(browser.url).to match(/window_switching\.html/) }
|
337
337
|
end
|
338
338
|
end
|
339
|
-
|
340
339
|
end
|
341
340
|
end
|
342
341
|
end
|
343
342
|
end
|
344
343
|
|
345
|
-
context
|
344
|
+
context 'manipulating size and position' do
|
346
345
|
before do
|
347
|
-
browser.goto WatirSpec.url_for(
|
346
|
+
browser.goto WatirSpec.url_for('window_switching.html')
|
348
347
|
end
|
349
348
|
|
350
349
|
not_compliant_on :headless do
|
351
|
-
it
|
350
|
+
it 'should get the size of the current window' do
|
352
351
|
size = browser.window.size
|
353
352
|
|
354
353
|
expect(size.width).to be > 0
|
@@ -356,7 +355,7 @@ describe "Window" do
|
|
356
355
|
end
|
357
356
|
end
|
358
357
|
|
359
|
-
it
|
358
|
+
it 'should get the position of the current window' do
|
360
359
|
pos = browser.window.position
|
361
360
|
|
362
361
|
expect(pos.x).to be >= 0
|
@@ -364,11 +363,11 @@ describe "Window" do
|
|
364
363
|
end
|
365
364
|
|
366
365
|
not_compliant_on :headless do
|
367
|
-
it
|
366
|
+
it 'should resize the window' do
|
368
367
|
initial_size = browser.window.size
|
369
368
|
browser.window.resize_to(
|
370
|
-
|
371
|
-
|
369
|
+
initial_size.width - 20,
|
370
|
+
initial_size.height - 20
|
372
371
|
)
|
373
372
|
|
374
373
|
new_size = browser.window.size
|
@@ -378,13 +377,13 @@ describe "Window" do
|
|
378
377
|
end
|
379
378
|
end
|
380
379
|
|
381
|
-
not_compliant_on :headless, %i
|
382
|
-
it
|
380
|
+
not_compliant_on :headless, %i[remote firefox] do
|
381
|
+
it 'should move the window' do
|
383
382
|
initial_pos = browser.window.position
|
384
383
|
|
385
384
|
browser.window.move_to(
|
386
|
-
|
387
|
-
|
385
|
+
initial_pos.x + 2,
|
386
|
+
initial_pos.y + 2
|
388
387
|
)
|
389
388
|
|
390
389
|
new_pos = browser.window.position
|
@@ -395,11 +394,11 @@ describe "Window" do
|
|
395
394
|
|
396
395
|
not_compliant_on :headless do
|
397
396
|
compliant_on :window_manager do
|
398
|
-
it
|
397
|
+
it 'should maximize the window' do
|
399
398
|
initial_size = browser.window.size
|
400
399
|
browser.window.resize_to(
|
401
|
-
|
402
|
-
|
400
|
+
initial_size.width,
|
401
|
+
initial_size.height - 20
|
403
402
|
)
|
404
403
|
|
405
404
|
browser.window.maximize
|