watir 6.14.0 → 6.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +24 -6
- data/CHANGES.md +10 -0
- data/Gemfile +0 -2
- data/README.md +1 -1
- data/Rakefile +2 -2
- data/lib/watir.rb +2 -3
- data/lib/watir/adjacent.rb +2 -2
- data/lib/watir/alert.rb +5 -9
- data/lib/watir/attribute_helper.rb +2 -3
- data/lib/watir/browser.rb +5 -17
- data/lib/watir/capabilities.rb +11 -0
- data/lib/watir/cell_container.rb +2 -2
- data/lib/watir/container.rb +7 -8
- data/lib/watir/cookies.rb +2 -12
- data/lib/watir/element_collection.rb +2 -2
- data/lib/watir/elements/button.rb +2 -11
- data/lib/watir/elements/element.rb +43 -25
- data/lib/watir/elements/hidden.rb +1 -1
- data/lib/watir/elements/iframe.rb +7 -5
- data/lib/watir/elements/option.rb +2 -13
- data/lib/watir/elements/select.rb +6 -22
- data/lib/watir/elements/table.rb +2 -2
- data/lib/watir/exception.rb +1 -2
- data/lib/watir/generator/base/idl_sorter.rb +1 -1
- data/lib/watir/generator/base/spec_extractor.rb +2 -2
- data/lib/watir/generator/base/visitor.rb +1 -1
- data/lib/watir/generator/html/generator.rb +0 -1
- data/lib/watir/generator/html/spec_extractor.rb +1 -1
- data/lib/watir/generator/html/visitor.rb +1 -1
- data/lib/watir/generator/svg/spec_extractor.rb +1 -1
- data/lib/watir/generator/svg/visitor.rb +1 -1
- data/lib/watir/js_execution.rb +11 -0
- data/lib/watir/js_snippets.rb +1 -1
- data/lib/watir/js_snippets/elementObscured.js +14 -0
- data/lib/watir/js_snippets/selectedText.js +17 -0
- data/lib/watir/legacy_wait.rb +5 -5
- data/lib/watir/locators.rb +16 -5
- data/lib/watir/locators/anchor/selector_builder.rb +38 -0
- data/lib/watir/locators/button/locator.rb +14 -12
- data/lib/watir/locators/button/selector_builder.rb +0 -22
- data/lib/watir/locators/button/selector_builder/xpath.rb +67 -12
- data/lib/watir/locators/button/validator.rb +2 -1
- data/lib/watir/locators/cell/selector_builder.rb +0 -14
- data/lib/watir/locators/cell/selector_builder/xpath.rb +21 -0
- data/lib/watir/locators/element/locator.rb +60 -153
- data/lib/watir/locators/element/selector_builder.rb +103 -84
- data/lib/watir/locators/element/selector_builder/regexp_disassembler.rb +66 -0
- data/lib/watir/locators/element/selector_builder/xpath.rb +195 -82
- data/lib/watir/locators/element/selector_builder/xpath_support.rb +27 -0
- data/lib/watir/locators/element/validator.rb +2 -9
- data/lib/watir/locators/row/selector_builder.rb +5 -22
- data/lib/watir/locators/row/selector_builder/xpath.rb +53 -0
- data/lib/watir/locators/text_area/selector_builder.rb +1 -1
- data/lib/watir/locators/text_area/selector_builder/xpath.rb +19 -0
- data/lib/watir/locators/text_field/locator.rb +11 -8
- data/lib/watir/locators/text_field/selector_builder.rb +0 -23
- data/lib/watir/locators/text_field/selector_builder/xpath.rb +33 -4
- data/lib/watir/locators/text_field/validator.rb +4 -4
- data/lib/watir/radio_set.rb +5 -5
- data/lib/watir/row_container.rb +2 -2
- data/lib/watir/user_editable.rb +2 -2
- data/lib/watir/version.rb +1 -1
- data/lib/watir/wait.rb +24 -37
- data/lib/watir/window.rb +11 -8
- data/lib/watirspec/remote_server.rb +3 -1
- data/spec/locator_spec_helper.rb +1 -1
- data/spec/spec_helper.rb +25 -1
- data/spec/unit/anchor_locator_spec.rb +68 -0
- data/spec/unit/capabilities_spec.rb +27 -0
- data/spec/unit/element_locator_spec.rb +184 -101
- data/spec/unit/logger_spec.rb +5 -0
- data/spec/watirspec/adjacent_spec.rb +34 -34
- data/spec/watirspec/after_hooks_spec.rb +78 -35
- data/spec/watirspec/alert_spec.rb +10 -0
- data/spec/watirspec/browser_spec.rb +27 -1
- data/spec/watirspec/element_hidden_spec.rb +6 -0
- data/spec/watirspec/elements/button_spec.rb +5 -11
- data/spec/watirspec/elements/buttons_spec.rb +1 -1
- data/spec/watirspec/elements/checkbox_spec.rb +2 -15
- data/spec/watirspec/elements/date_time_field_spec.rb +6 -1
- data/spec/watirspec/elements/dd_spec.rb +0 -17
- data/spec/watirspec/elements/del_spec.rb +0 -14
- data/spec/watirspec/elements/div_spec.rb +0 -18
- data/spec/watirspec/elements/dl_spec.rb +0 -17
- data/spec/watirspec/elements/dt_spec.rb +0 -17
- data/spec/watirspec/elements/element_spec.rb +177 -17
- data/spec/watirspec/elements/elements_spec.rb +7 -6
- data/spec/watirspec/elements/em_spec.rb +0 -13
- data/spec/watirspec/elements/filefield_spec.rb +0 -11
- data/spec/watirspec/elements/form_spec.rb +6 -0
- data/spec/watirspec/elements/hn_spec.rb +0 -14
- data/spec/watirspec/elements/iframe_spec.rb +15 -0
- data/spec/watirspec/elements/ins_spec.rb +0 -14
- data/spec/watirspec/elements/labels_spec.rb +1 -1
- data/spec/watirspec/elements/li_spec.rb +0 -14
- data/spec/watirspec/elements/link_spec.rb +22 -14
- data/spec/watirspec/elements/links_spec.rb +13 -0
- data/spec/watirspec/elements/list_spec.rb +15 -0
- data/spec/watirspec/elements/ol_spec.rb +0 -14
- data/spec/watirspec/elements/option_spec.rb +0 -10
- data/spec/watirspec/elements/p_spec.rb +0 -14
- data/spec/watirspec/elements/pre_spec.rb +0 -14
- data/spec/watirspec/elements/radio_spec.rb +0 -14
- data/spec/watirspec/elements/select_list_spec.rb +0 -10
- data/spec/watirspec/elements/span_spec.rb +4 -15
- data/spec/watirspec/elements/strong_spec.rb +4 -15
- data/spec/watirspec/elements/table_nesting_spec.rb +1 -1
- data/spec/watirspec/elements/table_spec.rb +7 -0
- data/spec/watirspec/elements/text_field_spec.rb +10 -2
- data/spec/watirspec/elements/text_fields_spec.rb +1 -1
- data/spec/watirspec/elements/tr_spec.rb +1 -1
- data/spec/watirspec/elements/ul_spec.rb +0 -14
- data/spec/watirspec/html/closeable.html +8 -0
- data/spec/watirspec/html/forms_with_input_elements.html +28 -23
- data/spec/watirspec/html/nested_elements.html +9 -9
- data/spec/watirspec/html/obscured.html +34 -0
- data/spec/watirspec/html/tables.html +13 -13
- data/spec/watirspec/radio_set_spec.rb +5 -0
- data/spec/watirspec/selector_builder/button_spec.rb +254 -0
- data/spec/watirspec/selector_builder/cell_spec.rb +93 -0
- data/spec/watirspec/selector_builder/element_spec.rb +639 -0
- data/spec/watirspec/selector_builder/row_spec.rb +150 -0
- data/spec/watirspec/selector_builder/text_spec.rb +170 -0
- data/spec/watirspec/support/rspec_matchers.rb +6 -1
- data/spec/watirspec/user_editable_spec.rb +4 -0
- data/spec/watirspec/wait_spec.rb +65 -14
- data/spec/watirspec/window_switching_spec.rb +54 -1
- data/spec/watirspec_helper.rb +2 -0
- data/watir.gemspec +7 -1
- metadata +86 -8
- data/lib/watir/locators/text_area/locator.rb +0 -13
- data/lib/watir/xpath_support.rb +0 -18
@@ -28,19 +28,6 @@ describe 'Em' do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
# Attribute methods
|
31
|
-
describe '#class_name' do
|
32
|
-
it 'returns the class attribute if the element exists' do
|
33
|
-
expect(browser.em(id: 'important-id').class_name).to eq 'important-class'
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'raises UnknownObjectException if the element does not exist' do
|
37
|
-
expect { browser.em(id: 'no_such_id').class_name }.to raise_unknown_object_exception
|
38
|
-
expect { browser.em(title: 'no_such_title').class_name }.to raise_unknown_object_exception
|
39
|
-
expect { browser.em(index: 1337).class_name }.to raise_unknown_object_exception
|
40
|
-
expect { browser.em(xpath: "//em[@id='no_such_id']").class_name }.to raise_unknown_object_exception
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
31
|
describe '#id' do
|
45
32
|
it 'returns the id attribute if the element exists' do
|
46
33
|
expect(browser.em(class: 'important-class').id).to eq 'important-id'
|
@@ -42,17 +42,6 @@ describe 'FileField' do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
# Attribute methods
|
45
|
-
|
46
|
-
describe '#class_name' do
|
47
|
-
it 'returns the class attribute if the text field exists' do
|
48
|
-
expect(browser.file_field(index: 0).class_name).to eq 'portrait'
|
49
|
-
end
|
50
|
-
|
51
|
-
it "raises UnknownObjectException if the text field doesn't exist" do
|
52
|
-
expect { browser.file_field(index: 1337).class_name }.to raise_unknown_object_exception
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
45
|
describe '#id' do
|
57
46
|
it 'returns the id attribute if the text field exists' do
|
58
47
|
expect(browser.file_field(index: 0).id).to eq 'new_user_portrait'
|
@@ -60,5 +60,11 @@ describe 'Form' do
|
|
60
60
|
expect(messages[0]).to eq 'submit'
|
61
61
|
end
|
62
62
|
end
|
63
|
+
|
64
|
+
compliant_on :relaxed_locate do
|
65
|
+
it 'times out when submitting an element that is not displayed' do
|
66
|
+
expect { browser.form(name: 'no').submit }.to raise_unknown_object_exception
|
67
|
+
end
|
68
|
+
end
|
63
69
|
end
|
64
70
|
end
|
@@ -36,20 +36,6 @@ describe ['H1', 'H2', 'H3', 'H4', 'H5', 'H6'] do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
# Attribute methods
|
39
|
-
describe '#class_name' do
|
40
|
-
it 'returns the class attribute' do
|
41
|
-
expect(browser.h1(index: 0).class_name).to eq 'primary'
|
42
|
-
end
|
43
|
-
|
44
|
-
it "returns an empty string if the element exists and the attribute doesn't" do
|
45
|
-
expect(browser.h2(index: 0).class_name).to eq ''
|
46
|
-
end
|
47
|
-
|
48
|
-
it "raises UnknownObjectException if the p doesn't exist" do
|
49
|
-
expect { browser.h2(id: 'no_such_id').class_name }.to raise_unknown_object_exception
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
39
|
describe '#id' do
|
54
40
|
it 'returns the id attribute' do
|
55
41
|
expect(browser.h1(index: 0).id).to eq 'first_header'
|
@@ -224,3 +224,18 @@ describe 'IFrame' do
|
|
224
224
|
end
|
225
225
|
end
|
226
226
|
end
|
227
|
+
|
228
|
+
describe 'FramedDriver' do
|
229
|
+
it 'raises name error if method is not defined on driver or element' do
|
230
|
+
browser.goto WatirSpec.url_for('iframes.html')
|
231
|
+
expect(browser.iframe(id: 'iframe_1').wd).not_to respond_to :foo
|
232
|
+
expect { browser.iframe(id: 'iframe_1').wd.foo }.to raise_exception NoMethodError
|
233
|
+
end
|
234
|
+
|
235
|
+
it 'raises exception when attempting to switch to a non-frame element' do
|
236
|
+
browser.goto WatirSpec.url_for('iframes.html')
|
237
|
+
element = browser.h1.wd
|
238
|
+
fd = Watir::FramedDriver.new(element, browser)
|
239
|
+
expect { fd.switch! }.to raise_exception Watir::Exception::UnknownFrameException
|
240
|
+
end
|
241
|
+
end
|
@@ -39,20 +39,6 @@ describe 'Ins' do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
# Attribute methods
|
42
|
-
describe '#class_name' do
|
43
|
-
it 'returns the class attribute' do
|
44
|
-
expect(browser.ins(index: 0).class_name).to eq 'lead'
|
45
|
-
end
|
46
|
-
|
47
|
-
it "returns an empty string if the element exists and the attribute doesn't" do
|
48
|
-
expect(browser.ins(index: 2).class_name).to eq ''
|
49
|
-
end
|
50
|
-
|
51
|
-
it "raises UnknownObjectException if the ins doesn't exist" do
|
52
|
-
expect { browser.ins(id: 'no_such_id').class_name }.to raise_unknown_object_exception
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
42
|
describe '#id' do
|
57
43
|
it 'returns the id attribute' do
|
58
44
|
expect(browser.ins(index: 0).id).to eq 'lead'
|
@@ -39,20 +39,6 @@ describe 'Li' do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
# Attribute methods
|
42
|
-
describe '#class_name' do
|
43
|
-
it 'returns the class attribute' do
|
44
|
-
expect(browser.li(id: 'non_link_1').class_name).to eq 'nonlink'
|
45
|
-
end
|
46
|
-
|
47
|
-
it "returns an empty string if the element exists and the attribute doesn't" do
|
48
|
-
expect(browser.li(index: 0).class_name).to eq ''
|
49
|
-
end
|
50
|
-
|
51
|
-
it "raises UnknownObjectException if the li doesn't exist" do
|
52
|
-
expect { browser.li(id: 'no_such_id').class_name }.to raise_unknown_object_exception
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
42
|
describe '#id' do
|
57
43
|
it 'returns the id attribute' do
|
58
44
|
expect(browser.li(class: 'nonlink').id).to eq 'non_link_1'
|
@@ -49,20 +49,6 @@ describe 'Link' do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
# Attribute methods
|
52
|
-
describe '#class_name' do
|
53
|
-
it 'returns the type attribute if the link exists' do
|
54
|
-
expect(browser.link(index: 1).class_name).to eq 'external'
|
55
|
-
end
|
56
|
-
|
57
|
-
it "returns an empty string if the link exists and the attribute doesn't" do
|
58
|
-
expect(browser.link(index: 0).class_name).to eq ''
|
59
|
-
end
|
60
|
-
|
61
|
-
it "raises an UnknownObjectException if the link doesn't exist" do
|
62
|
-
expect { browser.link(index: 1337).class_name }.to raise_unknown_object_exception
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
52
|
describe '#href' do
|
67
53
|
it 'returns the href attribute if the link exists' do
|
68
54
|
expect(browser.link(index: 1).href).to match(/non_control_elements/)
|
@@ -164,4 +150,26 @@ describe 'Link' do
|
|
164
150
|
expect(browser.title).to eq 'definition_lists'
|
165
151
|
end
|
166
152
|
end
|
153
|
+
|
154
|
+
describe 'visible text' do
|
155
|
+
it 'finds links by visible text' do
|
156
|
+
browser.goto WatirSpec.url_for('non_control_elements.html')
|
157
|
+
|
158
|
+
expect(browser.link(visible_text: 'all visible')).to exist
|
159
|
+
expect(browser.link(visible_text: /all visible/)).to exist
|
160
|
+
expect(browser.link(visible_text: 'some visible')).to exist
|
161
|
+
expect(browser.link(visible_text: /some visible/)).to exist
|
162
|
+
expect(browser.link(visible_text: 'none visible')).not_to exist
|
163
|
+
expect(browser.link(visible_text: /none visible/)).not_to exist
|
164
|
+
|
165
|
+
expect(browser.link(visible_text: 'Link 2', class: 'external')).to exist
|
166
|
+
expect(browser.link(visible_text: /Link 2/, class: 'external')).to exist
|
167
|
+
end
|
168
|
+
|
169
|
+
it 'raises exception unless value is a String or a RegExp' do
|
170
|
+
browser.goto WatirSpec.url_for('non_control_elements.html')
|
171
|
+
msg = /expected string_or_regexp, got 7\:(Fixnum|Integer)/
|
172
|
+
expect { browser.link(visible_text: 7).exists? }.to raise_exception(TypeError, msg)
|
173
|
+
end
|
174
|
+
end
|
167
175
|
end
|
@@ -39,4 +39,17 @@ describe 'Links' do
|
|
39
39
|
expect(count).to be > 0
|
40
40
|
end
|
41
41
|
end
|
42
|
+
|
43
|
+
describe 'visible text' do
|
44
|
+
it 'finds links by visible text' do
|
45
|
+
browser.goto WatirSpec.url_for('non_control_elements.html')
|
46
|
+
container = browser.div(id: 'visible_text')
|
47
|
+
expect(container.links(visible_text: 'all visible').count).to eq(1)
|
48
|
+
expect(container.links(visible_text: /all visible/).count).to eq(1)
|
49
|
+
expect(container.links(visible_text: 'some visible').count).to eq(1)
|
50
|
+
expect(container.links(visible_text: /some visible/).count).to eq(1)
|
51
|
+
expect(container.links(visible_text: 'none visible').count).to eq(0)
|
52
|
+
expect(container.links(visible_text: /none visible/).count).to eq(0)
|
53
|
+
end
|
54
|
+
end
|
42
55
|
end
|
@@ -17,6 +17,21 @@ describe 'List' do
|
|
17
17
|
expect(items).to all(be_a Watir::LI)
|
18
18
|
end
|
19
19
|
|
20
|
+
it 'gets the size of a list' do
|
21
|
+
ul = browser.ul(id: 'navbar')
|
22
|
+
expect(ul.size).to eq 7
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'iterates over a list' do
|
26
|
+
ul = browser.ul(id: 'navbar')
|
27
|
+
expect(ul.map(&:tag_name)).to eq Array.new(7, 'li')
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'gets a list item at the specified index' do
|
31
|
+
ul = browser.ul(id: 'navbar')
|
32
|
+
expect(ul[4].text).to eq 'Non-link 1'
|
33
|
+
end
|
34
|
+
|
20
35
|
it 'returns the list item size' do
|
21
36
|
items = browser.ol(id: 'favorite_compounds').list_items
|
22
37
|
expect(items.size).to eq 5
|
@@ -46,20 +46,6 @@ describe 'Ol' do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
# Attribute methods
|
49
|
-
describe '#class_name' do
|
50
|
-
it 'returns the class attribute' do
|
51
|
-
expect(browser.ol(id: 'favorite_compounds').class_name).to eq 'chemistry'
|
52
|
-
end
|
53
|
-
|
54
|
-
it "returns an empty string if the element exists and the attribute doesn't" do
|
55
|
-
expect(browser.ol(index: 1).class_name).to eq ''
|
56
|
-
end
|
57
|
-
|
58
|
-
it "raises UnknownObjectException if the ol doesn't exist" do
|
59
|
-
expect { browser.ol(id: 'no_such_id').class_name }.to raise_unknown_object_exception
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
49
|
describe '#id' do
|
64
50
|
it 'returns the id attribute' do
|
65
51
|
expect(browser.ol(class: 'chemistry').id).to eq 'favorite_compounds'
|
@@ -101,16 +101,6 @@ describe 'Option' do
|
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
|
-
describe '#class_name' do
|
105
|
-
it 'is able to get attributes (page context)' do
|
106
|
-
expect(browser.option(text: 'Sweden').class_name).to eq 'scandinavia'
|
107
|
-
end
|
108
|
-
|
109
|
-
it 'is able to get attributes (select_list context)' do
|
110
|
-
expect(browser.select_list(name: 'new_user_country').option(text: 'Sweden').class_name).to eq 'scandinavia'
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
104
|
describe '#respond_to?' do
|
115
105
|
it 'returns true for all attribute methods' do
|
116
106
|
expect(browser.select_list(name: 'new_user_country').option(text: 'Sweden')).to respond_to(:class_name)
|
@@ -39,20 +39,6 @@ describe 'P' do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
# Attribute methods
|
42
|
-
describe '#class_name' do
|
43
|
-
it 'returns the class attribute' do
|
44
|
-
expect(browser.p(index: 0).class_name).to eq 'lead'
|
45
|
-
end
|
46
|
-
|
47
|
-
it "returns an empty string if the element exists and the attribute doesn't" do
|
48
|
-
expect(browser.p(index: 2).class_name).to eq ''
|
49
|
-
end
|
50
|
-
|
51
|
-
it "raises UnknownObjectException if the p doesn't exist" do
|
52
|
-
expect { browser.p(id: 'no_such_id').class_name }.to raise_unknown_object_exception
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
42
|
describe '#id' do
|
57
43
|
it 'returns the id attribute' do
|
58
44
|
expect(browser.p(index: 0).id).to eq 'lead'
|
@@ -39,20 +39,6 @@ describe 'Pre' do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
# Attribute methods
|
42
|
-
describe '#class_name' do
|
43
|
-
it 'returns the class attribute' do
|
44
|
-
expect(browser.pre(id: 'rspec').class_name).to eq 'ruby'
|
45
|
-
end
|
46
|
-
|
47
|
-
it "returns an empty string if the element exists and the attribute doesn't" do
|
48
|
-
expect(browser.pre(index: 0).class_name).to eq ''
|
49
|
-
end
|
50
|
-
|
51
|
-
it "raises UnknownObjectException if the p doesn't exist" do
|
52
|
-
expect { browser.pre(id: 'no_such_id').class_name }.to raise_unknown_object_exception
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
42
|
describe '#id' do
|
57
43
|
it 'returns the id attribute' do
|
58
44
|
expect(browser.pre(class: 'ruby').id).to eq 'rspec'
|
@@ -68,20 +68,6 @@ describe 'Radio' do
|
|
68
68
|
end
|
69
69
|
|
70
70
|
# Attribute methods
|
71
|
-
describe '#class_name' do
|
72
|
-
it 'returns the class name if the radio exists and has an attribute' do
|
73
|
-
expect(browser.radio(id: 'new_user_newsletter_yes').class_name).to eq 'huge'
|
74
|
-
end
|
75
|
-
|
76
|
-
it "returns an empty string if the radio exists and the attribute doesn't" do
|
77
|
-
expect(browser.radio(id: 'new_user_newsletter_no').class_name).to eq ''
|
78
|
-
end
|
79
|
-
|
80
|
-
it "raises UnknownObjectException if the radio doesn't exist" do
|
81
|
-
expect { browser.radio(id: 'no_such_id').class_name }.to raise_unknown_object_exception
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
71
|
describe '#id' do
|
86
72
|
it 'returns the id attribute if the radio exists and has an attribute' do
|
87
73
|
expect(browser.radio(index: 0).id).to eq 'new_user_newsletter_yes'
|
@@ -43,16 +43,6 @@ describe 'SelectList' do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
# Attribute methods
|
46
|
-
describe '#class_name' do
|
47
|
-
it 'returns the class name of the select list' do
|
48
|
-
expect(browser.select_list(name: 'new_user_country').class_name).to eq 'country'
|
49
|
-
end
|
50
|
-
|
51
|
-
it "raises UnknownObjectException if the select list doesn't exist" do
|
52
|
-
expect { browser.select_list(name: 'no_such_name').class_name }.to raise_unknown_object_exception
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
46
|
describe '#id' do
|
57
47
|
it 'returns the id of the element' do
|
58
48
|
expect(browser.select_list(index: 0).id).to eq 'new_user_country'
|
@@ -11,13 +11,16 @@ describe 'Span' do
|
|
11
11
|
expect(browser.span(id: 'lead')).to exist
|
12
12
|
expect(browser.span(id: /lead/)).to exist
|
13
13
|
expect(browser.span(text: 'Dubito, ergo cogito, ergo sum.')).to exist
|
14
|
-
expect(browser.span(text: /Dubito, ergo cogito, ergo sum/)).to exist
|
15
14
|
expect(browser.span(class: 'lead')).to exist
|
16
15
|
expect(browser.span(class: /lead/)).to exist
|
17
16
|
expect(browser.span(index: 0)).to exist
|
18
17
|
expect(browser.span(xpath: "//span[@id='lead']")).to exist
|
19
18
|
end
|
20
19
|
|
20
|
+
it 'visible text is found by regular expression with text locator' do
|
21
|
+
expect(browser.span(text: /Dubito, ergo cogito, ergo sum/)).to exist
|
22
|
+
end
|
23
|
+
|
21
24
|
it 'returns the first span if given no args' do
|
22
25
|
expect(browser.span).to exist
|
23
26
|
end
|
@@ -39,20 +42,6 @@ describe 'Span' do
|
|
39
42
|
end
|
40
43
|
|
41
44
|
# Attribute methods
|
42
|
-
describe '#class_name' do
|
43
|
-
it 'returns the class attribute' do
|
44
|
-
expect(browser.span(index: 0).class_name).to eq 'lead'
|
45
|
-
end
|
46
|
-
|
47
|
-
it "returns an empty string if the element exists and the attribute doesn't" do
|
48
|
-
expect(browser.span(index: 2).class_name).to eq ''
|
49
|
-
end
|
50
|
-
|
51
|
-
it "raises UnknownObjectException if the span doesn't exist" do
|
52
|
-
expect { browser.span(id: 'no_such_id').class_name }.to raise_unknown_object_exception
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
45
|
describe '#id' do
|
57
46
|
it 'returns the id attribute' do
|
58
47
|
expect(browser.span(index: 0).id).to eq 'lead'
|
@@ -11,13 +11,16 @@ describe 'Strong' do
|
|
11
11
|
expect(browser.strong(id: 'descartes')).to exist
|
12
12
|
expect(browser.strong(id: /descartes/)).to exist
|
13
13
|
expect(browser.strong(text: 'Dubito, ergo cogito, ergo sum.')).to exist
|
14
|
-
expect(browser.strong(text: /Dubito, ergo cogito, ergo sum/)).to exist
|
15
14
|
expect(browser.strong(class: 'descartes')).to exist
|
16
15
|
expect(browser.strong(class: /descartes/)).to exist
|
17
16
|
expect(browser.strong(index: 0)).to exist
|
18
17
|
expect(browser.strong(xpath: "//strong[@id='descartes']")).to exist
|
19
18
|
end
|
20
19
|
|
20
|
+
it 'visible text is found by regular expression with text locator' do
|
21
|
+
expect(browser.strong(text: /Dubito, ergo cogito, ergo sum/)).to exist
|
22
|
+
end
|
23
|
+
|
21
24
|
it 'returns the first strong if given no args' do
|
22
25
|
expect(browser.strong).to exist
|
23
26
|
end
|
@@ -39,20 +42,6 @@ describe 'Strong' do
|
|
39
42
|
end
|
40
43
|
|
41
44
|
# Attribute methods
|
42
|
-
describe '#class_name' do
|
43
|
-
it 'returns the class attribute' do
|
44
|
-
expect(browser.strong(index: 0).class_name).to eq 'descartes'
|
45
|
-
end
|
46
|
-
|
47
|
-
it "returns an empty string if the element exists and the attribute doesn't" do
|
48
|
-
expect(browser.strong(index: 1).class_name).to eq ''
|
49
|
-
end
|
50
|
-
|
51
|
-
it "raises UnknownObjectException if the element doesn't exist" do
|
52
|
-
expect { browser.strong(id: 'no_such_id').class_name }.to raise_unknown_object_exception
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
45
|
describe '#id' do
|
57
46
|
it 'returns the id attribute' do
|
58
47
|
expect(browser.strong(index: 0).id).to eq 'descartes'
|
@@ -7,7 +7,7 @@ describe 'Table' do
|
|
7
7
|
|
8
8
|
# not a selenium bug - IE seems unable to deal with the invalid nesting
|
9
9
|
not_compliant_on :internet_explorer do
|
10
|
-
it 'returns the correct number of rows under a table' do
|
10
|
+
it 'returns the correct number of rows under a table element' do
|
11
11
|
tables = browser.div(id: 'table-rows-test').tables(id: /^tbl/)
|
12
12
|
expect(tables.length).to be > 0
|
13
13
|
|
@@ -103,6 +103,7 @@ describe 'Table' do
|
|
103
103
|
|
104
104
|
it 'finds rows belonging to this table' do
|
105
105
|
expect(table.row(id: 'outer_last')).to exist
|
106
|
+
table.row(text: 'Table 1, Row 1, Cell 1').locate
|
106
107
|
expect(table.row(text: /Table 1, Row 1, Cell 1/)).to exist
|
107
108
|
end
|
108
109
|
|
@@ -148,4 +149,10 @@ describe 'Table' do
|
|
148
149
|
expect(bodies[1].id).to eq 'second'
|
149
150
|
end
|
150
151
|
end
|
152
|
+
|
153
|
+
describe '#each' do
|
154
|
+
it 'allows iterating over the rows in a table' do
|
155
|
+
expect(browser.table(id: 'inner').to_a).to all be_a Watir::Row
|
156
|
+
end
|
157
|
+
end
|
151
158
|
end
|