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/unit/logger_spec.rb
CHANGED
@@ -44,8 +44,9 @@ module Watir
|
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'allows to selectively ignore deprecations with Strings' do
|
47
|
-
Watir.logger.ignore(
|
48
|
-
expect { Watir.logger.deprecate('#old', '#new', ids: ['old deprecated']) }
|
47
|
+
Watir.logger.ignore('old deprecated')
|
48
|
+
expect { Watir.logger.deprecate('#old', '#new', ids: ['old deprecated']) }
|
49
|
+
.to_not output.to_stdout_from_any_process
|
49
50
|
end
|
50
51
|
|
51
52
|
it 'allows to selectively ignore deprecations with Symbols' do
|
@@ -69,10 +70,9 @@ module Watir
|
|
69
70
|
end
|
70
71
|
|
71
72
|
it 'allows to ignore multiple ids' do
|
72
|
-
Watir.logger.ignore([
|
73
|
+
Watir.logger.ignore(%i[foo bar])
|
73
74
|
expect { Watir.logger.warn('warning', ids: [:foo]) }.to_not output.to_stdout_from_any_process
|
74
75
|
expect { Watir.logger.warn('warning', ids: [:bar]) }.to_not output.to_stdout_from_any_process
|
75
76
|
end
|
76
|
-
|
77
77
|
end
|
78
78
|
end
|
data/spec/unit/unit_helper.rb
CHANGED
data/spec/unit/wait_spec.rb
CHANGED
@@ -1,92 +1,90 @@
|
|
1
1
|
require_relative 'unit_helper'
|
2
2
|
|
3
3
|
describe Watir::Wait do
|
4
|
-
describe
|
5
|
-
it
|
4
|
+
describe '#until' do
|
5
|
+
it 'waits until the block returns true' do
|
6
6
|
Watir::Wait.until(timeout: 0.5) { @result = true }
|
7
7
|
expect(@result).to be true
|
8
8
|
end
|
9
9
|
|
10
|
-
it
|
10
|
+
it 'executes block if timeout is zero' do
|
11
11
|
Watir::Wait.until(timeout: 0) { @result = true }
|
12
12
|
expect(@result).to be true
|
13
13
|
end
|
14
14
|
|
15
|
-
it
|
15
|
+
it 'times out' do
|
16
16
|
expect { Watir::Wait.until(timeout: 0.5) { false } }.to raise_error(Watir::Wait::TimeoutError)
|
17
17
|
end
|
18
18
|
|
19
|
-
it
|
19
|
+
it 'times out with a custom message' do
|
20
20
|
expect {
|
21
|
-
Watir::Wait.until(timeout: 0.5, message:
|
22
|
-
}.to raise_error(Watir::Wait::TimeoutError,
|
21
|
+
Watir::Wait.until(timeout: 0.5, message: 'oops') { false }
|
22
|
+
}.to raise_error(Watir::Wait::TimeoutError, 'timed out after 0.5 seconds, oops')
|
23
23
|
end
|
24
24
|
|
25
|
-
it
|
26
|
-
|
25
|
+
it 'uses provided interval' do
|
26
|
+
expect {
|
27
27
|
Watir::Wait.until(timeout: 0.4, interval: 0.2) do
|
28
28
|
@result = @result.nil? ? 1 : @result + 1
|
29
29
|
false
|
30
30
|
end
|
31
|
-
|
32
|
-
end
|
31
|
+
}.to raise_timeout_exception
|
33
32
|
expect(@result).to eq 2
|
34
33
|
end
|
35
34
|
|
36
|
-
it
|
35
|
+
it 'uses timer for waiting' do
|
37
36
|
timer = Watir::Wait.timer
|
38
37
|
expect(timer).to receive(:wait).with(0.5).and_call_original
|
39
38
|
Watir::Wait.until(timeout: 0.5) { true }
|
40
39
|
end
|
41
40
|
end
|
42
41
|
|
43
|
-
describe
|
44
|
-
it
|
42
|
+
describe '#while' do
|
43
|
+
it 'waits while the block returns true' do
|
45
44
|
expect(Watir::Wait.while(timeout: 0.5) { false }).to be_nil
|
46
45
|
end
|
47
46
|
|
48
|
-
it
|
47
|
+
it 'executes block if timeout is zero' do
|
49
48
|
expect(Watir::Wait.while(timeout: 0) { false }).to be_nil
|
50
49
|
end
|
51
50
|
|
52
|
-
it
|
51
|
+
it 'times out' do
|
53
52
|
expect { Watir::Wait.while(timeout: 0.5) { true } }.to raise_error(Watir::Wait::TimeoutError)
|
54
53
|
end
|
55
54
|
|
56
|
-
it
|
55
|
+
it 'times out with a custom message' do
|
57
56
|
expect {
|
58
|
-
Watir::Wait.while(timeout: 0.5, message:
|
59
|
-
}.to raise_error(Watir::Wait::TimeoutError,
|
57
|
+
Watir::Wait.while(timeout: 0.5, message: 'oops') { true }
|
58
|
+
}.to raise_error(Watir::Wait::TimeoutError, 'timed out after 0.5 seconds, oops')
|
60
59
|
end
|
61
60
|
|
62
|
-
it
|
63
|
-
|
61
|
+
it 'uses provided interval' do
|
62
|
+
expect {
|
64
63
|
Watir::Wait.while(timeout: 0.4, interval: 0.2) do
|
65
64
|
@result = @result.nil? ? 1 : @result + 1
|
66
65
|
true
|
67
66
|
end
|
68
|
-
|
69
|
-
end
|
67
|
+
}.to raise_timeout_exception
|
70
68
|
expect(@result).to eq 2
|
71
69
|
end
|
72
70
|
|
73
|
-
it
|
71
|
+
it 'uses timer for waiting' do
|
74
72
|
timer = Watir::Wait.timer
|
75
73
|
expect(timer).to receive(:wait).with(0.5).and_call_original
|
76
74
|
Watir::Wait.while(timeout: 0.5) { false }
|
77
75
|
end
|
78
76
|
end
|
79
77
|
|
80
|
-
describe
|
81
|
-
it
|
78
|
+
describe '#timer' do
|
79
|
+
it 'returns default timer' do
|
82
80
|
expect(Watir::Wait.timer).to be_a(Watir::Wait::Timer)
|
83
81
|
end
|
84
82
|
end
|
85
83
|
|
86
|
-
describe
|
84
|
+
describe '#timer=' do
|
87
85
|
after { Watir::Wait.timer = nil }
|
88
86
|
|
89
|
-
it
|
87
|
+
it 'changes default timer' do
|
90
88
|
timer = Class.new
|
91
89
|
Watir::Wait.timer = timer
|
92
90
|
expect(Watir::Wait.timer).to eq(timer)
|
@@ -1,69 +1,69 @@
|
|
1
|
-
require
|
1
|
+
require 'watirspec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe 'Adjacent Elements' do
|
4
4
|
before(:all) do
|
5
|
-
browser.goto(WatirSpec.url_for(
|
5
|
+
browser.goto(WatirSpec.url_for('nested_elements.html'))
|
6
6
|
end
|
7
7
|
|
8
|
-
describe
|
9
|
-
it
|
10
|
-
expect(browser.div(id:
|
11
|
-
expect(browser.div(id:
|
8
|
+
describe '#parent' do
|
9
|
+
it 'gets immediate parent of an element by default' do
|
10
|
+
expect(browser.div(id: 'first_sibling').parent.id).to eq 'parent'
|
11
|
+
expect(browser.div(id: 'first_sibling').parent).to be_a Watir::HTMLElement
|
12
12
|
end
|
13
13
|
|
14
|
-
it
|
15
|
-
expect(browser.div(id:
|
16
|
-
expect(browser.div(id:
|
14
|
+
it 'accepts index argument' do
|
15
|
+
expect(browser.div(id: 'first_sibling').parent(index: 2).id).to eq 'grandparent'
|
16
|
+
expect(browser.div(id: 'first_sibling').parent(index: 2)).to be_a Watir::HTMLElement
|
17
17
|
end
|
18
18
|
|
19
|
-
it
|
20
|
-
expect(browser.div(id:
|
21
|
-
expect(browser.div(id:
|
19
|
+
it 'accepts tag_name argument' do
|
20
|
+
expect(browser.div(id: 'first_sibling').parent(tag_name: :div).id).to eq 'parent'
|
21
|
+
expect(browser.div(id: 'first_sibling').parent(tag_name: :div)).to be_a Watir::Div
|
22
22
|
end
|
23
23
|
|
24
|
-
it
|
25
|
-
expect(browser.div(id:
|
26
|
-
expect(browser.div(id:
|
24
|
+
it 'accepts custom tag_name argument' do
|
25
|
+
expect(browser.div(id: 'regular_child').parent(tag_name: :grandelement).id).to eq 'custom_grandparent'
|
26
|
+
expect(browser.div(id: 'regular_child').parent(tag_name: :grandelement)).to be_a Watir::HTMLElement
|
27
27
|
end
|
28
28
|
|
29
|
-
it
|
30
|
-
expect(browser.div(id:
|
29
|
+
it 'accepts class_name argument' do
|
30
|
+
expect(browser.div(id: 'first_sibling').parent(class_name: 'parent').id).to eq 'parent_span'
|
31
31
|
end
|
32
32
|
|
33
|
-
it
|
34
|
-
expect(browser.div(id:
|
35
|
-
expect(browser.div(id:
|
33
|
+
it 'accepts index and tag_name arguments' do
|
34
|
+
expect(browser.div(id: 'first_sibling').parent(tag_name: :div, index: 1).id).to eq 'grandparent'
|
35
|
+
expect(browser.div(id: 'first_sibling').parent(tag_name: :div, index: 1)).to be_a Watir::Div
|
36
36
|
end
|
37
37
|
|
38
|
-
it
|
38
|
+
it 'does not error when no parent element of an index exists' do
|
39
39
|
expect(browser.body.parent(index: 2)).to_not exist
|
40
40
|
end
|
41
41
|
|
42
|
-
it
|
43
|
-
expect(browser.div(id:
|
42
|
+
it 'does not error when no parent element of a tag_name exists' do
|
43
|
+
expect(browser.div(id: 'first_sibling').parent(tag_name: :table)).to_not exist
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
describe
|
48
|
-
it
|
49
|
-
expect(browser.div(id:
|
50
|
-
expect(browser.div(id:
|
47
|
+
describe '#siblings' do
|
48
|
+
it 'gets collection of all siblings of an element' do
|
49
|
+
expect(browser.div(id: 'second_sibling').siblings).to be_a Watir::HTMLElementCollection
|
50
|
+
expect(browser.div(id: 'second_sibling').siblings.size).to eq 5
|
51
51
|
end
|
52
52
|
|
53
|
-
it
|
54
|
-
siblings = browser.div(id:
|
53
|
+
it 'accepts a tag name argument' do
|
54
|
+
siblings = browser.div(id: 'second_sibling').siblings(tag_name: :div)
|
55
55
|
expect(siblings.size).to eq 3
|
56
56
|
expect(siblings.all? { |sib| sib.is_a? Watir::Div }).to eq true
|
57
57
|
end
|
58
58
|
|
59
|
-
it
|
60
|
-
siblings = browser.div(id:
|
59
|
+
it 'accepts custom tag name argument' do
|
60
|
+
siblings = browser.div(id: 'regular_child').siblings(tag_name: :childelement)
|
61
61
|
expect(siblings.size).to eq 3
|
62
62
|
expect(siblings.all? { |sib| sib.is_a? Watir::HTMLElement }).to eq true
|
63
63
|
end
|
64
64
|
|
65
|
-
it
|
66
|
-
siblings = browser.div(id:
|
65
|
+
it 'accepts a class_name argument' do
|
66
|
+
siblings = browser.div(id: 'second_sibling').siblings(class_name: 'b')
|
67
67
|
expect(siblings.first).to be_a Watir::Div
|
68
68
|
expect(siblings[0]).to be_a Watir::Div
|
69
69
|
expect(siblings.size).to eq 2
|
@@ -71,182 +71,182 @@ describe "Adjacent Elements" do
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
-
describe
|
75
|
-
it
|
76
|
-
expect(browser.div(id:
|
77
|
-
expect(browser.div(id:
|
74
|
+
describe '#following_sibling' do
|
75
|
+
it 'gets immediate following sibling of an element by default' do
|
76
|
+
expect(browser.div(id: 'first_sibling').following_sibling.id).to eq 'between_siblings1'
|
77
|
+
expect(browser.div(id: 'first_sibling').following_sibling).to be_a Watir::HTMLElement
|
78
78
|
end
|
79
79
|
|
80
|
-
it
|
81
|
-
expect(browser.div(id:
|
82
|
-
expect(browser.div(id:
|
80
|
+
it 'accepts index argument' do
|
81
|
+
expect(browser.div(id: 'first_sibling').following_sibling(index: 2).id).to eq 'between_siblings2'
|
82
|
+
expect(browser.div(id: 'first_sibling').following_sibling(index: 2)).to be_a Watir::HTMLElement
|
83
83
|
end
|
84
84
|
|
85
|
-
it
|
86
|
-
expect(browser.div(id:
|
87
|
-
expect(browser.div(id:
|
85
|
+
it 'accepts tag_name argument' do
|
86
|
+
expect(browser.div(id: 'first_sibling').following_sibling(tag_name: :div).id).to eq 'second_sibling'
|
87
|
+
expect(browser.div(id: 'first_sibling').following_sibling(tag_name: :div)).to be_a Watir::Div
|
88
88
|
end
|
89
89
|
|
90
|
-
it
|
91
|
-
expect(browser.div(id:
|
90
|
+
it 'accepts class_name argument' do
|
91
|
+
expect(browser.div(id: 'first_sibling').following_sibling(class_name: 'b').id).to eq 'second_sibling'
|
92
92
|
end
|
93
93
|
|
94
|
-
it
|
95
|
-
expect(browser.div(id:
|
96
|
-
expect(browser.div(id:
|
94
|
+
it 'accepts index and tag_name arguments' do
|
95
|
+
expect(browser.div(id: 'first_sibling').following_sibling(tag_name: :div, index: 1).id).to eq 'third_sibling'
|
96
|
+
expect(browser.div(id: 'first_sibling').following_sibling(tag_name: :div, index: 1)).to be_a Watir::Div
|
97
97
|
end
|
98
98
|
|
99
|
-
it
|
100
|
-
expect(browser.div(id:
|
99
|
+
it 'accepts text as Regexp' do
|
100
|
+
expect(browser.div(id: 'first_sibling').following_sibling(text: /t/).id).to eq 'third_sibling'
|
101
101
|
end
|
102
102
|
|
103
|
-
it
|
104
|
-
expect(browser.div(id:
|
103
|
+
it 'accepts text as String' do
|
104
|
+
expect(browser.div(id: 'first_sibling').following_sibling(text: 'text').id).to eq 'third_sibling'
|
105
105
|
end
|
106
106
|
|
107
|
-
it
|
107
|
+
it 'does not error when no next sibling of an index exists' do
|
108
108
|
expect(browser.body.following_sibling(index: 1)).to_not exist
|
109
109
|
end
|
110
110
|
|
111
|
-
it
|
112
|
-
expect(browser.div(id:
|
111
|
+
it 'does not error when no next sibling of a tag_name exists' do
|
112
|
+
expect(browser.div(id: 'first_sibling').following_sibling(tag_name: :table)).to_not exist
|
113
113
|
end
|
114
114
|
end
|
115
115
|
|
116
|
-
describe
|
117
|
-
it
|
118
|
-
expect(browser.div(id:
|
119
|
-
expect(browser.div(id:
|
116
|
+
describe '#following_siblings' do
|
117
|
+
it 'gets collection of subsequent siblings of an element by default' do
|
118
|
+
expect(browser.div(id: 'second_sibling').following_siblings).to be_a Watir::HTMLElementCollection
|
119
|
+
expect(browser.div(id: 'second_sibling').following_siblings.size).to eq 2
|
120
120
|
end
|
121
121
|
|
122
|
-
it
|
123
|
-
expect(browser.div(id:
|
124
|
-
expect(browser.div(id:
|
122
|
+
it 'accepts tag_name argument' do
|
123
|
+
expect(browser.div(id: 'second_sibling').following_siblings(tag_name: :div).size).to eq 1
|
124
|
+
expect(browser.div(id: 'second_sibling').following_siblings(tag_name: :div).first).to be_a Watir::Div
|
125
125
|
end
|
126
126
|
|
127
|
-
it
|
128
|
-
expect(browser.div(id:
|
129
|
-
expect(browser.div(id:
|
127
|
+
it 'accepts class_name argument for single class' do
|
128
|
+
expect(browser.div(id: 'second_sibling').following_siblings(class_name: 'b').size).to eq 1
|
129
|
+
expect(browser.div(id: 'second_sibling').following_siblings(class_name: 'b').first).to be_a Watir::Div
|
130
130
|
end
|
131
131
|
|
132
|
-
it
|
133
|
-
expect(browser.div(id:
|
134
|
-
expect(browser.div(id:
|
132
|
+
it 'accepts class_name argument for multiple classes' do
|
133
|
+
expect(browser.div(id: 'second_sibling').following_siblings(class_name: %w[a b]).size).to eq 1
|
134
|
+
expect(browser.div(id: 'second_sibling').following_siblings(class_name: %w[a b]).first).to be_a Watir::Div
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
138
|
-
describe
|
139
|
-
it
|
140
|
-
expect(browser.div(id:
|
141
|
-
expect(browser.div(id:
|
138
|
+
describe '#previous_sibling' do
|
139
|
+
it 'gets immediate preceeding sibling of an element by default' do
|
140
|
+
expect(browser.div(id: 'third_sibling').previous_sibling.id).to eq 'between_siblings2'
|
141
|
+
expect(browser.div(id: 'third_sibling').previous_sibling).to be_a Watir::HTMLElement
|
142
142
|
end
|
143
143
|
|
144
|
-
it
|
145
|
-
expect(browser.div(id:
|
146
|
-
expect(browser.div(id:
|
144
|
+
it 'accepts index argument' do
|
145
|
+
expect(browser.div(id: 'third_sibling').previous_sibling(index: 2).id).to eq 'between_siblings1'
|
146
|
+
expect(browser.div(id: 'third_sibling').previous_sibling(index: 2)).to be_a Watir::HTMLElement
|
147
147
|
end
|
148
148
|
|
149
|
-
it
|
150
|
-
expect(browser.div(id:
|
151
|
-
expect(browser.div(id:
|
149
|
+
it 'accepts tag_name argument' do
|
150
|
+
expect(browser.div(id: 'third_sibling').previous_sibling(tag_name: :div).id).to eq 'second_sibling'
|
151
|
+
expect(browser.div(id: 'third_sibling').previous_sibling(tag_name: :div)).to be_a Watir::Div
|
152
152
|
end
|
153
153
|
|
154
|
-
it
|
155
|
-
expect(browser.div(id:
|
154
|
+
it 'accepts class_name argument' do
|
155
|
+
expect(browser.div(id: 'third_sibling').previous_sibling(class_name: 'a').id).to eq 'between_siblings2'
|
156
156
|
end
|
157
157
|
|
158
|
-
it
|
159
|
-
expect(browser.div(id:
|
160
|
-
expect(browser.div(id:
|
158
|
+
it 'accepts index and tag_name arguments' do
|
159
|
+
expect(browser.div(id: 'third_sibling').previous_sibling(tag_name: :div, index: 1).id).to eq 'first_sibling'
|
160
|
+
expect(browser.div(id: 'third_sibling').previous_sibling(tag_name: :div, index: 1)).to be_a Watir::Div
|
161
161
|
end
|
162
162
|
|
163
|
-
it
|
163
|
+
it 'does not error when no next sibling of an index exists' do
|
164
164
|
expect(browser.body.previous_sibling(index: 1)).to_not exist
|
165
165
|
end
|
166
166
|
|
167
|
-
it
|
168
|
-
expect(browser.div(id:
|
167
|
+
it 'does not error when no next sibling of a tag_name exists' do
|
168
|
+
expect(browser.div(id: 'third_sibling').previous_sibling(tag_name: :table)).to_not exist
|
169
169
|
end
|
170
170
|
end
|
171
171
|
|
172
|
-
describe
|
173
|
-
it
|
174
|
-
expect(browser.div(id:
|
175
|
-
expect(browser.div(id:
|
172
|
+
describe '#previous_siblings' do
|
173
|
+
it 'gets collection of previous siblings of an element by default' do
|
174
|
+
expect(browser.div(id: 'second_sibling').previous_siblings).to be_a Watir::HTMLElementCollection
|
175
|
+
expect(browser.div(id: 'second_sibling').previous_siblings.size).to eq 2
|
176
176
|
end
|
177
177
|
|
178
|
-
it
|
179
|
-
expect(browser.div(id:
|
180
|
-
expect(browser.div(id:
|
178
|
+
it 'accepts tag_name argument' do
|
179
|
+
expect(browser.div(id: 'second_sibling').previous_siblings(tag_name: :div).size).to eq 1
|
180
|
+
expect(browser.div(id: 'second_sibling').previous_siblings(tag_name: :div).first).to be_a Watir::Div
|
181
181
|
end
|
182
182
|
|
183
|
-
it
|
184
|
-
expect(browser.div(id:
|
185
|
-
expect(browser.div(id:
|
183
|
+
it 'accepts class_name argument' do
|
184
|
+
expect(browser.div(id: 'second_sibling').previous_siblings(class_name: 'a').size).to eq 1
|
185
|
+
expect(browser.div(id: 'second_sibling').previous_siblings(class_name: 'a').first.id).to eq 'between_siblings1'
|
186
186
|
end
|
187
187
|
end
|
188
188
|
|
189
|
-
describe
|
190
|
-
it
|
191
|
-
expect(browser.div(id:
|
192
|
-
expect(browser.div(id:
|
189
|
+
describe '#child' do
|
190
|
+
it 'gets immediate child of an element by default' do
|
191
|
+
expect(browser.div(id: 'parent').child.id).to eq 'first_sibling'
|
192
|
+
expect(browser.div(id: 'parent').child).to be_a Watir::HTMLElement
|
193
193
|
end
|
194
194
|
|
195
|
-
it
|
196
|
-
expect(browser.div(id:
|
197
|
-
expect(browser.div(id:
|
195
|
+
it 'accepts index argument' do
|
196
|
+
expect(browser.div(id: 'parent').child(index: 2).id).to eq 'second_sibling'
|
197
|
+
expect(browser.div(id: 'parent').child(index: 2)).to be_a Watir::HTMLElement
|
198
198
|
end
|
199
199
|
|
200
|
-
it
|
201
|
-
expect(browser.div(id:
|
202
|
-
expect(browser.div(id:
|
200
|
+
it 'accepts tag_name argument' do
|
201
|
+
expect(browser.div(id: 'parent').child(tag_name: :span).id).to eq 'between_siblings1'
|
202
|
+
expect(browser.div(id: 'parent').child(tag_name: :span)).to be_a Watir::Span
|
203
203
|
end
|
204
204
|
|
205
|
-
it
|
206
|
-
expect(browser.element(id:
|
207
|
-
expect(browser.element(id:
|
205
|
+
it 'accepts custom tag_name argument' do
|
206
|
+
expect(browser.element(id: 'custom_parent').child(tag_name: :childelement).id).to eq 'custom_child'
|
207
|
+
expect(browser.element(id: 'custom_parent').child(tag_name: :childelement)).to be_a Watir::HTMLElement
|
208
208
|
end
|
209
209
|
|
210
|
-
it
|
211
|
-
expect(browser.div(id:
|
210
|
+
it 'accepts class_name argument' do
|
211
|
+
expect(browser.div(id: 'parent').child(class_name: 'b').id).to eq 'second_sibling'
|
212
212
|
end
|
213
213
|
|
214
|
-
it
|
215
|
-
expect(browser.div(id:
|
216
|
-
expect(browser.div(id:
|
214
|
+
it 'accepts index and tag_name arguments' do
|
215
|
+
expect(browser.div(id: 'parent').child(tag_name: :div, index: 1).id).to eq 'second_sibling'
|
216
|
+
expect(browser.div(id: 'parent').child(tag_name: :div, index: 1)).to be_a Watir::Div
|
217
217
|
end
|
218
218
|
|
219
|
-
it
|
220
|
-
expect(browser.div(id:
|
219
|
+
it 'does not error when no next sibling of an index exists' do
|
220
|
+
expect(browser.div(id: 'second_sibling').child(index: 1)).to_not exist
|
221
221
|
end
|
222
222
|
|
223
|
-
it
|
224
|
-
expect(browser.div(id:
|
223
|
+
it 'does not error when no next sibling of a tag_name exists' do
|
224
|
+
expect(browser.div(id: 'parent').child(tag_name: :table)).to_not exist
|
225
225
|
end
|
226
226
|
end
|
227
227
|
|
228
|
-
describe
|
229
|
-
it
|
230
|
-
expect(browser.div(id:
|
231
|
-
expect(browser.div(id:
|
228
|
+
describe '#children' do
|
229
|
+
it 'gets collection of children of an element by default' do
|
230
|
+
expect(browser.div(id: 'parent').children).to be_a Watir::HTMLElementCollection
|
231
|
+
expect(browser.div(id: 'parent').children.size).to eq 5
|
232
232
|
end
|
233
233
|
|
234
|
-
it
|
235
|
-
children = browser.div(id:
|
234
|
+
it 'accepts tag_name argument' do
|
235
|
+
children = browser.div(id: 'parent').children(tag_name: :div)
|
236
236
|
expect(children.size).to eq 3
|
237
237
|
expect(children.all? { |child| child.is_a? Watir::Div }).to eq true
|
238
238
|
end
|
239
239
|
|
240
|
-
it
|
241
|
-
children = browser.element(id:
|
240
|
+
it 'accepts custom tag_name argument' do
|
241
|
+
children = browser.element(id: 'custom_parent').children(tag_name: :childelement)
|
242
242
|
expect(children.size).to eq 3
|
243
243
|
expect(children.all? { |child| child.is_a? Watir::HTMLElement }).to eq true
|
244
244
|
end
|
245
245
|
|
246
|
-
it
|
247
|
-
children = browser.div(id:
|
246
|
+
it 'accepts a class_name argument' do
|
247
|
+
children = browser.div(id: 'parent').children(class_name: 'b')
|
248
248
|
expect(children.size).to eq 2
|
249
249
|
expect(children.all? { |child| child.is_a? Watir::Div }).to eq true
|
250
250
|
end
|
251
251
|
end
|
252
|
-
end
|
252
|
+
end
|