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
@@ -1,31 +1,30 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
describe "Dts" do
|
1
|
+
require 'watirspec_helper'
|
4
2
|
|
3
|
+
describe 'Dts' do
|
5
4
|
before :each do
|
6
|
-
browser.goto(WatirSpec.url_for(
|
5
|
+
browser.goto(WatirSpec.url_for('definition_lists.html'))
|
7
6
|
end
|
8
7
|
|
9
|
-
describe
|
10
|
-
it
|
11
|
-
expect(browser.dts(class:
|
8
|
+
describe 'with selectors' do
|
9
|
+
it 'returns the matching elements' do
|
10
|
+
expect(browser.dts(class: 'current-industry').to_a).to eq [browser.dt(class: 'current-industry')]
|
12
11
|
end
|
13
12
|
end
|
14
13
|
|
15
|
-
describe
|
16
|
-
it
|
14
|
+
describe '#length' do
|
15
|
+
it 'returns the number of dts' do
|
17
16
|
expect(browser.dts.length).to eq 11
|
18
17
|
end
|
19
18
|
end
|
20
19
|
|
21
|
-
describe
|
22
|
-
it
|
23
|
-
expect(browser.dts[0].id).to eq
|
20
|
+
describe '#[]' do
|
21
|
+
it 'returns the dt at the given index' do
|
22
|
+
expect(browser.dts[0].id).to eq 'experience'
|
24
23
|
end
|
25
24
|
end
|
26
25
|
|
27
|
-
describe
|
28
|
-
it
|
26
|
+
describe '#each' do
|
27
|
+
it 'iterates through dts correctly' do
|
29
28
|
count = 0
|
30
29
|
|
31
30
|
browser.dts.each_with_index do |d, index|
|
@@ -38,5 +37,4 @@ describe "Dts" do
|
|
38
37
|
expect(count).to be > 0
|
39
38
|
end
|
40
39
|
end
|
41
|
-
|
42
40
|
end
|
@@ -1,33 +1,32 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
describe "Element" do
|
1
|
+
require 'watirspec_helper'
|
4
2
|
|
3
|
+
describe 'Element' do
|
5
4
|
before :each do
|
6
|
-
browser.goto(WatirSpec.url_for(
|
5
|
+
browser.goto(WatirSpec.url_for('forms_with_input_elements.html'))
|
7
6
|
end
|
8
7
|
|
9
|
-
describe
|
8
|
+
describe '.new' do
|
10
9
|
it "finds elements matching the conditions when given a hash of :how => 'what' arguments" do
|
11
10
|
expect(browser.checkbox(name: 'new_user_interests', title: 'Dancing is fun!').value).to eq 'dancing'
|
12
11
|
expect(browser.text_field(class_name: 'name', index: 1).id).to eq 'new_user_last_name'
|
13
12
|
end
|
14
13
|
|
15
|
-
it "raises UnknownObjectException
|
16
|
-
expect { browser.text_field(index: 100, name:
|
14
|
+
it "raises UnknownObjectException when given a hash of :how => 'what' arguments (non-existing object)" do
|
15
|
+
expect { browser.text_field(index: 100, name: 'foo').id }.to raise_unknown_object_exception
|
17
16
|
end
|
18
17
|
|
19
|
-
it
|
20
|
-
container = double(
|
18
|
+
it 'raises ArgumentError if given the wrong number of arguments' do
|
19
|
+
container = double('container').as_null_object
|
21
20
|
expect { Watir::Element.new(container, 1, 2, 3, 4) }.to raise_error(ArgumentError)
|
22
|
-
expect { Watir::Element.new(container,
|
21
|
+
expect { Watir::Element.new(container, 'foo') }.to raise_error(ArgumentError)
|
23
22
|
end
|
24
23
|
end
|
25
24
|
|
26
|
-
describe
|
25
|
+
describe '#element_call' do
|
27
26
|
it 'handles exceptions when taking an action on a stale element' do
|
28
27
|
browser.goto WatirSpec.url_for('removed_element.html')
|
29
28
|
|
30
|
-
element = browser.div(id:
|
29
|
+
element = browser.div(id: 'text').tap(&:exists?)
|
31
30
|
|
32
31
|
browser.refresh
|
33
32
|
|
@@ -36,18 +35,18 @@ describe "Element" do
|
|
36
35
|
end
|
37
36
|
end
|
38
37
|
|
39
|
-
describe
|
40
|
-
before { browser.goto WatirSpec.url_for(
|
38
|
+
describe '#eq and #eql?' do
|
39
|
+
before { browser.goto WatirSpec.url_for('definition_lists.html') }
|
41
40
|
|
42
|
-
it
|
43
|
-
a = browser.dl(id:
|
41
|
+
it 'returns true if the two elements point to the same DOM element' do
|
42
|
+
a = browser.dl(id: 'experience-list')
|
44
43
|
b = browser.dl
|
45
44
|
|
46
45
|
expect(a).to eq b
|
47
46
|
expect(a).to eql(b)
|
48
47
|
end
|
49
48
|
|
50
|
-
it
|
49
|
+
it 'returns false if the two elements are not the same' do
|
51
50
|
a = browser.dls[0]
|
52
51
|
b = browser.dls[1]
|
53
52
|
|
@@ -55,99 +54,99 @@ describe "Element" do
|
|
55
54
|
expect(a).to_not eql(b)
|
56
55
|
end
|
57
56
|
|
58
|
-
it
|
57
|
+
it 'returns false if the other object is not an Element' do
|
59
58
|
expect(browser.dl).to_not eq 1
|
60
59
|
end
|
61
60
|
end
|
62
61
|
|
63
|
-
describe
|
64
|
-
before { browser.goto WatirSpec.url_for(
|
62
|
+
describe 'data-* attributes' do
|
63
|
+
before { browser.goto WatirSpec.url_for('data_attributes.html') }
|
65
64
|
|
66
|
-
it
|
67
|
-
expect(browser.p(data_type:
|
65
|
+
it 'finds elements by a data-* attribute' do
|
66
|
+
expect(browser.p(data_type: 'ruby-library')).to exist
|
68
67
|
end
|
69
68
|
|
70
|
-
it
|
71
|
-
expect(browser.p.data_type).to eq
|
69
|
+
it 'returns the value of a data-* attribute' do
|
70
|
+
expect(browser.p.data_type).to eq 'ruby-library'
|
72
71
|
end
|
73
72
|
end
|
74
73
|
|
75
|
-
describe
|
76
|
-
before { browser.goto WatirSpec.url_for(
|
74
|
+
describe 'aria-* attributes' do
|
75
|
+
before { browser.goto WatirSpec.url_for('aria_attributes.html') }
|
77
76
|
|
78
|
-
it
|
79
|
-
expect(browser.p(aria_label:
|
77
|
+
it 'finds elements by a aria-* attribute' do
|
78
|
+
expect(browser.p(aria_label: 'ruby-library')).to exist
|
80
79
|
end
|
81
80
|
|
82
|
-
it
|
83
|
-
expect(browser.p.aria_label).to eq
|
81
|
+
it 'returns the value of a aria-* attribute' do
|
82
|
+
expect(browser.p.aria_label).to eq 'ruby-library'
|
84
83
|
end
|
85
84
|
end
|
86
85
|
|
87
|
-
describe
|
88
|
-
it
|
86
|
+
describe 'visible text' do
|
87
|
+
it 'finds elements by visible text' do
|
89
88
|
browser.goto WatirSpec.url_for('non_control_elements.html')
|
90
89
|
|
91
|
-
expect(browser.link(visible_text:
|
90
|
+
expect(browser.link(visible_text: 'all visible')).to exist
|
92
91
|
expect(browser.link(visible_text: /all visible/)).to exist
|
93
|
-
expect(browser.link(visible_text:
|
92
|
+
expect(browser.link(visible_text: 'some visible')).to exist
|
94
93
|
expect(browser.link(visible_text: /some visible/)).to exist
|
95
|
-
expect(browser.link(visible_text:
|
94
|
+
expect(browser.link(visible_text: 'none visible')).not_to exist
|
96
95
|
expect(browser.link(visible_text: /none visible/)).not_to exist
|
97
96
|
|
98
|
-
expect(browser.link(visible_text:
|
99
|
-
expect(browser.link(visible_text: /Link 2/, class:
|
97
|
+
expect(browser.link(visible_text: 'Link 2', class: 'external')).to exist
|
98
|
+
expect(browser.link(visible_text: /Link 2/, class: 'external')).to exist
|
100
99
|
|
101
|
-
expect(browser.element(visible_text:
|
100
|
+
expect(browser.element(visible_text: 'all visible')).to exist
|
102
101
|
expect(browser.element(visible_text: /all visible/)).to exist
|
103
|
-
expect(browser.element(visible_text:
|
102
|
+
expect(browser.element(visible_text: 'some visible')).to exist
|
104
103
|
expect(browser.element(visible_text: /some visible/)).to exist
|
105
104
|
end
|
106
105
|
end
|
107
106
|
|
108
|
-
describe
|
109
|
-
it
|
107
|
+
describe 'finding with unknown tag name' do
|
108
|
+
it 'finds an element without arguments' do
|
110
109
|
expect(browser.element).to exist
|
111
110
|
end
|
112
111
|
|
113
|
-
it
|
112
|
+
it 'finds an element by xpath' do
|
114
113
|
expect(browser.element(xpath: "//*[@for='new_user_first_name']")).to exist
|
115
114
|
end
|
116
115
|
|
117
|
-
it
|
118
|
-
expect(browser.element(title:
|
116
|
+
it 'finds an element by arbitrary attribute' do
|
117
|
+
expect(browser.element(title: 'no title')).to exist
|
119
118
|
end
|
120
119
|
|
121
|
-
it
|
122
|
-
expect(browser.elements(xpath:
|
120
|
+
it 'finds several elements by xpath' do
|
121
|
+
expect(browser.elements(xpath: '//a').length).to eq 1
|
123
122
|
end
|
124
123
|
|
125
|
-
it
|
124
|
+
it 'finds several elements by arbitrary attribute' do
|
126
125
|
expect(browser.elements(id: /^new_user/).length).to eq 33
|
127
126
|
end
|
128
127
|
|
129
128
|
it "finds an element from an element's subtree" do
|
130
|
-
expect(browser.fieldset.element(id:
|
131
|
-
expect(browser.field_set.element(id:
|
129
|
+
expect(browser.fieldset.element(id: 'first_label')).to exist
|
130
|
+
expect(browser.field_set.element(id: 'first_label')).to exist
|
132
131
|
end
|
133
132
|
|
134
133
|
it "finds several elements from an element's subtree" do
|
135
|
-
expect(browser.fieldset.elements(xpath:
|
134
|
+
expect(browser.fieldset.elements(xpath: './/label').length).to eq 22
|
136
135
|
end
|
137
136
|
end
|
138
137
|
|
139
|
-
describe
|
140
|
-
it
|
138
|
+
describe '#to_subtype' do
|
139
|
+
it 'returns a CheckBox instance' do
|
141
140
|
e = browser.input(xpath: "//input[@type='checkbox']").to_subtype
|
142
141
|
expect(e).to be_kind_of(Watir::CheckBox)
|
143
142
|
end
|
144
143
|
|
145
|
-
it
|
144
|
+
it 'returns a Radio instance' do
|
146
145
|
e = browser.input(xpath: "//input[@type='radio']").to_subtype
|
147
146
|
expect(e).to be_kind_of(Watir::Radio)
|
148
147
|
end
|
149
148
|
|
150
|
-
it
|
149
|
+
it 'returns a Button instance' do
|
151
150
|
es = [
|
152
151
|
browser.input(xpath: "//input[@type='button']").to_subtype,
|
153
152
|
browser.input(xpath: "//input[@type='submit']").to_subtype,
|
@@ -158,35 +157,35 @@ describe "Element" do
|
|
158
157
|
es.all? { |e| expect(e).to be_kind_of(Watir::Button) }
|
159
158
|
end
|
160
159
|
|
161
|
-
it
|
160
|
+
it 'returns a TextField instance' do
|
162
161
|
e = browser.input(xpath: "//input[@type='text']").to_subtype
|
163
162
|
expect(e).to be_kind_of(Watir::TextField)
|
164
163
|
end
|
165
164
|
|
166
|
-
it
|
165
|
+
it 'returns a FileField instance' do
|
167
166
|
e = browser.input(xpath: "//input[@type='file']").to_subtype
|
168
167
|
expect(e).to be_kind_of(Watir::FileField)
|
169
168
|
end
|
170
169
|
|
171
|
-
it
|
170
|
+
it 'returns a Div instance' do
|
172
171
|
el = browser.element(xpath: "//*[@id='messages']").to_subtype
|
173
172
|
expect(el).to be_kind_of(Watir::Div)
|
174
173
|
end
|
175
174
|
end
|
176
175
|
|
177
|
-
describe
|
178
|
-
it
|
179
|
-
tf = browser.text_field(id:
|
180
|
-
expect(tf.value).to eq
|
176
|
+
describe '#focus' do
|
177
|
+
it 'fires the onfocus event for the given element' do
|
178
|
+
tf = browser.text_field(id: 'new_user_occupation')
|
179
|
+
expect(tf.value).to eq 'Developer'
|
181
180
|
tf.focus
|
182
|
-
expect(browser.div(id:
|
181
|
+
expect(browser.div(id: 'onfocus_test').text).to eq 'changed by onfocus event'
|
183
182
|
end
|
184
183
|
end
|
185
184
|
|
186
|
-
bug
|
187
|
-
bug
|
188
|
-
describe
|
189
|
-
it
|
185
|
+
bug 'https://github.com/SeleniumHQ/selenium/issues/2555', %i[remote firefox] do
|
186
|
+
bug 'https://github.com/SeleniumHQ/selenium/issues/1795', %i[remote edge] do
|
187
|
+
describe '#focused?' do
|
188
|
+
it 'knows if the element is focused' do
|
190
189
|
expect(browser.element(id: 'new_user_first_name')).to be_focused
|
191
190
|
expect(browser.element(id: 'new_user_last_name')).to_not be_focused
|
192
191
|
end
|
@@ -194,31 +193,31 @@ describe "Element" do
|
|
194
193
|
end
|
195
194
|
end
|
196
195
|
|
197
|
-
describe
|
198
|
-
it
|
199
|
-
expect(browser.div(id:
|
200
|
-
browser.text_field(id:
|
201
|
-
expect(browser.div(id:
|
196
|
+
describe '#fire_event' do
|
197
|
+
it 'should fire the given event' do
|
198
|
+
expect(browser.div(id: 'onfocus_test').text).to be_empty
|
199
|
+
browser.text_field(id: 'new_user_occupation').fire_event('onfocus')
|
200
|
+
expect(browser.div(id: 'onfocus_test').text).to eq 'changed by onfocus event'
|
202
201
|
end
|
203
202
|
end
|
204
203
|
|
205
|
-
describe
|
206
|
-
it
|
204
|
+
describe '#visible?' do
|
205
|
+
it 'returns true if the element is visible' do
|
207
206
|
msg = /WARN Watir \[\"visible_element\"\]/
|
208
207
|
expect {
|
209
|
-
expect(browser.text_field(id:
|
208
|
+
expect(browser.text_field(id: 'new_user_email')).to be_visible
|
210
209
|
}.to output(msg).to_stdout_from_any_process
|
211
210
|
end
|
212
211
|
|
213
|
-
it
|
212
|
+
it 'raises UnknownObjectException exception if the element does not exist' do
|
214
213
|
msg = /WARN Watir \[\"visible_element\"\]/
|
215
214
|
expect {
|
216
|
-
expect { browser.text_field(id:
|
215
|
+
expect { browser.text_field(id: 'no_such_id').visible? }.to raise_unknown_object_exception
|
217
216
|
}.to output(msg).to_stdout_from_any_process
|
218
217
|
end
|
219
218
|
|
220
|
-
it
|
221
|
-
element = browser.text_field(id:
|
219
|
+
it 'raises UnknownObjectException exception if the element is stale' do
|
220
|
+
element = browser.text_field(id: 'new_user_email').tap(&:exists?)
|
222
221
|
|
223
222
|
browser.refresh
|
224
223
|
|
@@ -231,12 +230,12 @@ describe "Element" do
|
|
231
230
|
it "returns true if the element has style='visibility: visible' even if parent has style='visibility: hidden'" do
|
232
231
|
msg = /WARN Watir \[\"visible_element\"\]/
|
233
232
|
expect {
|
234
|
-
expect(browser.div(id:
|
233
|
+
expect(browser.div(id: 'visible_child')).to be_visible
|
235
234
|
}.to output(msg).to_stdout_from_any_process
|
236
235
|
end
|
237
236
|
|
238
237
|
it "returns false if the element is input element where type eq 'hidden'" do
|
239
|
-
expect(browser.hidden(id:
|
238
|
+
expect(browser.hidden(id: 'new_user_interests_dolls')).to_not be_visible
|
240
239
|
end
|
241
240
|
|
242
241
|
it "returns false if the element has style='display: none;'" do
|
@@ -247,27 +246,21 @@ describe "Element" do
|
|
247
246
|
end
|
248
247
|
|
249
248
|
it "returns false if the element has style='visibility: hidden;" do
|
250
|
-
|
251
|
-
expect {
|
252
|
-
expect(browser.div(id: 'wants_newsletter')).to_not be_visible
|
253
|
-
}
|
249
|
+
expect { expect(browser.div(id: 'wants_newsletter')).to_not be_visible }
|
254
250
|
end
|
255
251
|
|
256
|
-
it
|
257
|
-
|
258
|
-
expect {
|
259
|
-
expect(browser.div(id: 'hidden_parent')).to_not be_visible
|
260
|
-
}
|
252
|
+
it 'returns false if one of the parent elements is hidden' do
|
253
|
+
expect { expect(browser.div(id: 'hidden_parent')).to_not be_visible }
|
261
254
|
end
|
262
255
|
end
|
263
256
|
|
264
|
-
describe
|
257
|
+
describe '#exists?' do
|
265
258
|
before do
|
266
259
|
browser.goto WatirSpec.url_for('removed_element.html')
|
267
260
|
end
|
268
261
|
|
269
|
-
it
|
270
|
-
element = browser.divs(id:
|
262
|
+
it 'element from a collection returns false when it becomes stale' do
|
263
|
+
element = browser.divs(id: 'text').first.tap(&:exists?)
|
271
264
|
|
272
265
|
browser.refresh
|
273
266
|
|
@@ -275,15 +268,15 @@ describe "Element" do
|
|
275
268
|
expect(element).to_not exist
|
276
269
|
end
|
277
270
|
|
278
|
-
it
|
279
|
-
watir_element = browser.span(id:
|
271
|
+
it 'returns false when tag name does not match id' do
|
272
|
+
watir_element = browser.span(id: 'text')
|
280
273
|
expect(watir_element).to_not exist
|
281
274
|
end
|
282
275
|
end
|
283
276
|
|
284
277
|
describe '#present?' do
|
285
278
|
before do
|
286
|
-
browser.goto(WatirSpec.url_for(
|
279
|
+
browser.goto(WatirSpec.url_for('wait.html'))
|
287
280
|
end
|
288
281
|
|
289
282
|
it 'returns true if the element exists and is visible' do
|
@@ -298,9 +291,8 @@ describe "Element" do
|
|
298
291
|
expect(browser.div(id: 'should-not-exist')).to_not be_present
|
299
292
|
end
|
300
293
|
|
301
|
-
|
302
|
-
|
303
|
-
element = browser.div(id: "foo").tap(&:exists?)
|
294
|
+
it 'returns false if the element is stale' do
|
295
|
+
element = browser.div(id: 'foo').tap(&:exists?)
|
304
296
|
|
305
297
|
browser.refresh
|
306
298
|
|
@@ -311,9 +303,16 @@ describe "Element" do
|
|
311
303
|
}.to have_deprecated_stale_present
|
312
304
|
end
|
313
305
|
|
314
|
-
|
315
|
-
|
316
|
-
|
306
|
+
it 'does not raise staleness deprecation if element no longer exists in DOM' do
|
307
|
+
element = browser.div(id: 'foo').tap(&:exists?)
|
308
|
+
browser.goto(WatirSpec.url_for('iframes.html'))
|
309
|
+
|
310
|
+
expect { element.present? }.to_not have_deprecated_stale_present
|
311
|
+
end
|
312
|
+
|
313
|
+
# TODO: Documents Current Behavior, but needs to be refactored/removed
|
314
|
+
it 'returns true the second time if the element is stale' do
|
315
|
+
element = browser.div(id: 'foo').tap(&:exists?)
|
317
316
|
|
318
317
|
browser.refresh
|
319
318
|
|
@@ -324,29 +323,28 @@ describe "Element" do
|
|
324
323
|
}.to have_deprecated_stale_present
|
325
324
|
expect(element).to be_present
|
326
325
|
end
|
327
|
-
|
328
326
|
end
|
329
327
|
|
330
|
-
describe
|
328
|
+
describe '#enabled?' do
|
331
329
|
before do
|
332
|
-
browser.goto(WatirSpec.url_for(
|
330
|
+
browser.goto(WatirSpec.url_for('forms_with_input_elements.html'))
|
333
331
|
end
|
334
332
|
|
335
|
-
it
|
333
|
+
it 'returns true if the element is enabled' do
|
336
334
|
expect(browser.button(name: 'new_user_submit')).to be_enabled
|
337
335
|
end
|
338
336
|
|
339
|
-
it
|
337
|
+
it 'returns false if the element is disabled' do
|
340
338
|
expect(browser.button(name: 'new_user_submit_disabled')).to_not be_enabled
|
341
339
|
end
|
342
340
|
|
343
341
|
it "raises UnknownObjectException if the element doesn't exist" do
|
344
|
-
expect { browser.button(name:
|
342
|
+
expect { browser.button(name: 'no_such_name').enabled? }.to raise_unknown_object_exception
|
345
343
|
end
|
346
344
|
end
|
347
345
|
|
348
|
-
describe
|
349
|
-
it
|
346
|
+
describe '#stale?' do
|
347
|
+
it 'returns true if the element is stale' do
|
350
348
|
element = browser.button(name: 'new_user_submit_disabled').tap(&:exists?)
|
351
349
|
|
352
350
|
browser.refresh
|
@@ -354,93 +352,93 @@ describe "Element" do
|
|
354
352
|
expect(element).to be_stale
|
355
353
|
end
|
356
354
|
|
357
|
-
it
|
355
|
+
it 'returns false if the element is not stale' do
|
358
356
|
element = browser.button(name: 'new_user_submit_disabled').tap(&:exists?)
|
359
357
|
|
360
358
|
expect(element).to_not be_stale
|
361
359
|
end
|
362
360
|
end
|
363
361
|
|
364
|
-
describe
|
365
|
-
context
|
362
|
+
describe '#exist?' do
|
363
|
+
context ':class locator' do
|
366
364
|
before do
|
367
|
-
browser.goto(WatirSpec.url_for(
|
365
|
+
browser.goto(WatirSpec.url_for('class_locator.html'))
|
368
366
|
end
|
369
367
|
|
370
|
-
it
|
371
|
-
e = browser.div(class:
|
368
|
+
it 'matches when the element has a single class' do
|
369
|
+
e = browser.div(class: 'a')
|
372
370
|
expect(e).to exist
|
373
|
-
expect(e.class_name).to eq
|
371
|
+
expect(e.class_name).to eq 'a'
|
374
372
|
end
|
375
373
|
|
376
|
-
it
|
377
|
-
e = browser.div(class:
|
374
|
+
it 'matches when the element has several classes' do
|
375
|
+
e = browser.div(class: 'b')
|
378
376
|
expect(e).to exist
|
379
|
-
expect(e.class_name).to eq
|
377
|
+
expect(e.class_name).to eq 'a b c'
|
380
378
|
end
|
381
379
|
|
382
|
-
it
|
383
|
-
expect(browser.div(class:
|
380
|
+
it 'does not match only part of the class name' do
|
381
|
+
expect(browser.div(class: 'bc')).to_not exist
|
384
382
|
end
|
385
383
|
|
386
|
-
it
|
384
|
+
it 'matches part of the class name when given a regexp' do
|
387
385
|
expect(browser.div(class: /c/)).to exist
|
388
386
|
end
|
389
387
|
|
390
|
-
context
|
391
|
-
it
|
392
|
-
e = browser.div(class: [
|
388
|
+
context 'with multiple classes' do
|
389
|
+
it 'matches when the element has a single class' do
|
390
|
+
e = browser.div(class: ['a'])
|
393
391
|
expect(e).to exist
|
394
|
-
expect(e.class_name).to eq
|
392
|
+
expect(e.class_name).to eq 'a'
|
395
393
|
end
|
396
394
|
|
397
|
-
it
|
398
|
-
e = browser.div(class: [
|
395
|
+
it 'matches a non-ordered subset' do
|
396
|
+
e = browser.div(class: %w[c a])
|
399
397
|
expect(e).to exist
|
400
|
-
expect(e.class_name).to eq
|
398
|
+
expect(e.class_name).to eq 'a b c'
|
401
399
|
end
|
402
400
|
|
403
|
-
it
|
404
|
-
e = browser.div(class: [
|
401
|
+
it 'matches one with a negation' do
|
402
|
+
e = browser.div(class: ['!a'])
|
405
403
|
expect(e).to exist
|
406
|
-
expect(e.class_name).to eq
|
404
|
+
expect(e.class_name).to eq 'abc'
|
407
405
|
end
|
408
406
|
|
409
|
-
it
|
410
|
-
e = browser.div(class: [
|
407
|
+
it 'matches multiple with a negation' do
|
408
|
+
e = browser.div(class: ['a', '!c', 'b'])
|
411
409
|
expect(e).to exist
|
412
|
-
expect(e.class_name).to eq
|
410
|
+
expect(e.class_name).to eq 'a b'
|
413
411
|
end
|
414
412
|
end
|
415
413
|
end
|
416
414
|
|
417
|
-
context
|
418
|
-
before { browser.goto WatirSpec.url_for(
|
415
|
+
context 'attribute presence' do
|
416
|
+
before { browser.goto WatirSpec.url_for('data_attributes.html') }
|
419
417
|
|
420
|
-
it
|
418
|
+
it 'finds element by attribute presence' do
|
421
419
|
expect(browser.p(data_type: true)).to exist
|
422
420
|
expect(browser.p(class: true)).not_to exist
|
423
421
|
end
|
424
422
|
|
425
|
-
it
|
423
|
+
it 'finds element by attribute absence' do
|
426
424
|
expect(browser.p(data_type: false)).not_to exist
|
427
425
|
expect(browser.p(class: false)).to exist
|
428
426
|
end
|
429
427
|
end
|
430
428
|
|
431
|
-
context
|
432
|
-
before { browser.goto WatirSpec.url_for(
|
429
|
+
context ':index locator' do
|
430
|
+
before { browser.goto WatirSpec.url_for('data_attributes.html') }
|
433
431
|
|
434
|
-
it
|
435
|
-
expect(browser.element(index: 0).tag_name).to eq
|
432
|
+
it 'finds the first element by index: 0' do
|
433
|
+
expect(browser.element(index: 0).tag_name).to eq 'html'
|
436
434
|
end
|
437
435
|
|
438
|
-
it
|
439
|
-
expect(browser.element(index: 1).tag_name).to eq
|
436
|
+
it 'finds the second element by index: 1' do
|
437
|
+
expect(browser.element(index: 1).tag_name).to eq 'head'
|
440
438
|
end
|
441
439
|
|
442
|
-
it
|
443
|
-
expect(browser.element(index: -1).tag_name).to eq
|
440
|
+
it 'finds the last element by index: -1' do
|
441
|
+
expect(browser.element(index: -1).tag_name).to eq 'div'
|
444
442
|
end
|
445
443
|
end
|
446
444
|
|
@@ -448,33 +446,33 @@ describe "Element" do
|
|
448
446
|
expect(browser.div(id: 'no_such_div').link(id: 'no_such_id')).to_not exist
|
449
447
|
end
|
450
448
|
|
451
|
-
it
|
452
|
-
expect { browser.div(xpath:
|
449
|
+
it 'raises if both :xpath and :css are given' do
|
450
|
+
expect { browser.div(xpath: '//div', css: 'div').exists? }.to raise_error(ArgumentError)
|
453
451
|
end
|
454
452
|
|
455
453
|
it "doesn't raise when selector has with :xpath has :index" do
|
456
|
-
expect(browser.div(xpath:
|
454
|
+
expect(browser.div(xpath: '//div', index: 1)).to exist
|
457
455
|
end
|
458
456
|
|
459
|
-
it
|
460
|
-
expect { browser.div(xpath:
|
457
|
+
it 'raises ArgumentError error if selector hash with :xpath has multiple entries' do
|
458
|
+
expect { browser.div(xpath: '//div', class: 'foo').exists? }.to raise_error(ArgumentError)
|
461
459
|
end
|
462
460
|
|
463
461
|
it "doesn't raise when selector has with :css has :index" do
|
464
|
-
expect(browser.div(css:
|
462
|
+
expect(browser.div(css: 'div', index: 1)).to exist
|
465
463
|
end
|
466
464
|
|
467
|
-
it
|
468
|
-
expect { browser.div(css:
|
465
|
+
it 'raises ArgumentError error if selector hash with :css has multiple entries' do
|
466
|
+
expect { browser.div(css: 'div', class: 'foo').exists? }.to raise_error(ArgumentError)
|
469
467
|
end
|
470
468
|
|
471
|
-
it
|
472
|
-
expect(browser.element(name:
|
469
|
+
it 'finds element by Selenium name locator' do
|
470
|
+
expect(browser.element(name: 'new_user_first_name')).to exist
|
473
471
|
expect(browser.element(name: /new_user_first_name/)).to exist
|
474
472
|
end
|
475
473
|
|
476
|
-
it
|
477
|
-
watir_element = browser.span(id:
|
474
|
+
it 'returns false when tag name does not match id' do
|
475
|
+
watir_element = browser.span(id: 'text')
|
478
476
|
expect(watir_element).to_not exist
|
479
477
|
end
|
480
478
|
end
|
@@ -500,7 +498,7 @@ describe "Element" do
|
|
500
498
|
expect(events).to eq 10
|
501
499
|
end
|
502
500
|
|
503
|
-
bug
|
501
|
+
bug 'http://code.google.com/p/chromium/issues/detail?id=93879', :chrome do
|
504
502
|
not_compliant_on :safari, :firefox do
|
505
503
|
it 'performs key combinations' do
|
506
504
|
receiver.send_keys 'foo'
|
@@ -526,7 +524,7 @@ describe "Element" do
|
|
526
524
|
end
|
527
525
|
end
|
528
526
|
|
529
|
-
describe
|
527
|
+
describe '#flash' do
|
530
528
|
let(:h2) { browser.h2(text: 'Add user') }
|
531
529
|
let(:h1) { browser.h1(text: 'User administration') }
|
532
530
|
|
@@ -545,69 +543,68 @@ describe "Element" do
|
|
545
543
|
expect(h1.flash(:fast)).to eq h1
|
546
544
|
expect(h2.flash(:long)).to eq h2
|
547
545
|
end
|
548
|
-
|
549
546
|
end
|
550
547
|
|
551
|
-
describe
|
548
|
+
describe '#hover' do
|
552
549
|
not_compliant_on :internet_explorer, :safari do
|
553
|
-
it
|
550
|
+
it 'should hover over the element' do
|
554
551
|
browser.goto WatirSpec.url_for('hover.html')
|
555
552
|
link = browser.a
|
556
553
|
|
557
|
-
expect(link.style(
|
554
|
+
expect(link.style('font-size')).to eq '10px'
|
558
555
|
link.hover
|
559
|
-
link.wait_until { |l| l.style(
|
560
|
-
expect(link.style(
|
556
|
+
link.wait_until { |l| l.style('font-size') == '20px' }
|
557
|
+
expect(link.style('font-size')).to eq '20px'
|
561
558
|
end
|
562
559
|
end
|
563
560
|
end
|
564
561
|
|
565
|
-
describe
|
566
|
-
before(:each) { browser.goto(WatirSpec.url_for(
|
562
|
+
describe '#inspect' do
|
563
|
+
before(:each) { browser.goto(WatirSpec.url_for('nested_iframes.html')) }
|
567
564
|
|
568
|
-
it
|
565
|
+
it 'does displays specified element type' do
|
569
566
|
expect(browser.div.inspect).to include('Watir::Div')
|
570
567
|
end
|
571
568
|
|
572
|
-
it
|
569
|
+
it 'does not display element type if not specified' do
|
573
570
|
element = browser.element(index: 4)
|
574
571
|
expect(element.inspect).to include('Watir::HTMLElement')
|
575
572
|
end
|
576
573
|
|
577
|
-
it
|
574
|
+
it 'displays keyword if specified' do
|
578
575
|
element = browser.h3
|
579
576
|
element.keyword = 'foo'
|
580
577
|
expect(element.inspect).to include('keyword: foo')
|
581
578
|
end
|
582
579
|
|
583
|
-
it
|
580
|
+
it 'does not display keyword if not specified' do
|
584
581
|
element = browser.h3
|
585
582
|
expect(element.inspect).to_not include('keyword')
|
586
583
|
end
|
587
584
|
|
588
|
-
it
|
585
|
+
it 'locate is false when not located' do
|
589
586
|
element = browser.div(id: 'not_present')
|
590
587
|
expect(element.inspect).to include('located: false')
|
591
588
|
end
|
592
589
|
|
593
|
-
it
|
590
|
+
it 'locate is true when located' do
|
594
591
|
element = browser.h3
|
595
592
|
element.exists?
|
596
593
|
expect(element.inspect).to include('located: true')
|
597
594
|
end
|
598
595
|
|
599
|
-
it
|
596
|
+
it 'displays selector string for element from colection' do
|
600
597
|
elements = browser.frames
|
601
598
|
expect(elements.last.inspect).to include '{:tag_name=>"frame", :index=>-1}'
|
602
599
|
end
|
603
600
|
|
604
|
-
it
|
605
|
-
browser.goto(WatirSpec.url_for(
|
601
|
+
it 'displays selector string for nested element' do
|
602
|
+
browser.goto(WatirSpec.url_for('wait.html'))
|
606
603
|
element = browser.div(index: 1).div(id: 'div2')
|
607
604
|
expect(element.inspect).to include '{:index=>1, :tag_name=>"div"} --> {:id=>"div2", :tag_name=>"div"}'
|
608
605
|
end
|
609
606
|
|
610
|
-
it
|
607
|
+
it 'displays selector string for nested element under frame' do
|
611
608
|
element = browser.iframe(id: 'one').iframe(id: 'three')
|
612
609
|
expect(element.inspect).to include '{:id=>"one", :tag_name=>"iframe"} --> {:id=>"three", :tag_name=>"iframe"}'
|
613
610
|
end
|
@@ -632,7 +629,7 @@ describe "Element" do
|
|
632
629
|
it 'returns inner HTML code of element' do
|
633
630
|
browser.goto WatirSpec.url_for('non_control_elements.html')
|
634
631
|
div = browser.div(id: 'shown')
|
635
|
-
expected_text =
|
632
|
+
expected_text = '<div id="hidden" style="display: none;">Not shown</div><div>Not hidden</div>'
|
636
633
|
expect(div.inner_html).to eq expected_text
|
637
634
|
end
|
638
635
|
end
|
@@ -641,23 +638,23 @@ describe "Element" do
|
|
641
638
|
it 'returns outer (inner + element itself) HTML code of element' do
|
642
639
|
browser.goto WatirSpec.url_for('non_control_elements.html')
|
643
640
|
div = browser.div(id: 'shown')
|
644
|
-
|
645
|
-
expect(div.outer_html).to eq
|
641
|
+
text = '<div id="shown"><div id="hidden" style="display: none;">Not shown</div><div>Not hidden</div></div>'
|
642
|
+
expect(div.outer_html).to eq text
|
646
643
|
end
|
647
644
|
end
|
648
645
|
|
649
|
-
not_compliant_on %i
|
646
|
+
not_compliant_on %i[remote firefox] do
|
650
647
|
describe '#scroll_into_view' do
|
651
648
|
it 'scrolls element into view' do
|
652
649
|
el = browser.button(name: 'new_user_image')
|
653
650
|
element_center = el.center['y']
|
654
651
|
|
655
652
|
bottom_viewport_script = 'return window.pageYOffset + window.innerHeight'
|
656
|
-
expect(browser.execute_script
|
653
|
+
expect(browser.execute_script(bottom_viewport_script)).to be < element_center
|
657
654
|
|
658
655
|
expect(el.scroll_into_view).to be_a Selenium::WebDriver::Point
|
659
656
|
|
660
|
-
expect(browser.execute_script
|
657
|
+
expect(browser.execute_script(bottom_viewport_script)).to be > element_center
|
661
658
|
end
|
662
659
|
end
|
663
660
|
end
|
@@ -696,7 +693,6 @@ describe "Element" do
|
|
696
693
|
|
697
694
|
expect(width).to eq 104.0
|
698
695
|
end
|
699
|
-
|
700
696
|
end
|
701
697
|
|
702
698
|
describe '#center' do
|
@@ -710,14 +706,69 @@ describe "Element" do
|
|
710
706
|
end
|
711
707
|
|
712
708
|
describe '#attribute_value' do
|
713
|
-
before { browser.goto WatirSpec.url_for(
|
709
|
+
before { browser.goto WatirSpec.url_for('data_attributes.html') }
|
714
710
|
|
715
711
|
it 'returns attribute value by string attribute name' do
|
716
|
-
expect(browser.p.attribute_value('data-type')).to eq
|
712
|
+
expect(browser.p.attribute_value('data-type')).to eq 'ruby-library'
|
717
713
|
end
|
718
714
|
|
719
715
|
it 'returns attribute value by symbol attribute name' do
|
720
|
-
expect(browser.p.attribute_value(:data_type)).to eq
|
716
|
+
expect(browser.p.attribute_value(:data_type)).to eq 'ruby-library'
|
717
|
+
end
|
718
|
+
end
|
719
|
+
|
720
|
+
describe '#attribute_values' do
|
721
|
+
before { browser.goto WatirSpec.url_for('data_attributes.html') }
|
722
|
+
|
723
|
+
it 'returns a Hash object' do
|
724
|
+
expect(browser.p.attribute_values).to be_an_instance_of(Hash)
|
725
|
+
end
|
726
|
+
|
727
|
+
it 'returns attribute values from an element' do
|
728
|
+
expected = {data_type: 'ruby-library'}
|
729
|
+
expect(browser.p.attribute_values).to eq expected
|
730
|
+
end
|
731
|
+
|
732
|
+
it 'returns attribute with special characters' do
|
733
|
+
expected = {data_type: 'description', 'data-type_$p3c!a1' => 'special-description'}
|
734
|
+
expect(browser.div.attribute_values).to eq expected
|
735
|
+
end
|
736
|
+
|
737
|
+
it 'returns attribute with special characters as a String' do
|
738
|
+
expect(browser.div.attribute_values.keys[0]).to be_an_instance_of(String)
|
739
|
+
end
|
740
|
+
end
|
741
|
+
|
742
|
+
describe '#attribute_list' do
|
743
|
+
before { browser.goto WatirSpec.url_for('data_attributes.html') }
|
744
|
+
|
745
|
+
it 'returns an Array object' do
|
746
|
+
expect(browser.div.attribute_list).to be_an_instance_of(Array)
|
747
|
+
end
|
748
|
+
|
749
|
+
it 'returns list of attributes from an element' do
|
750
|
+
expect(browser.p.attribute_list).to eq [:data_type]
|
751
|
+
end
|
752
|
+
|
753
|
+
it 'returns attribute name with special characters as a String' do
|
754
|
+
expect(browser.div.attribute_list[0]).to be_an_instance_of(String)
|
755
|
+
end
|
756
|
+
end
|
757
|
+
|
758
|
+
describe '#located?' do
|
759
|
+
it 'returns true if element has been located' do
|
760
|
+
expect(browser.form(id: 'new_user')).to_not be_located
|
761
|
+
end
|
762
|
+
|
763
|
+
it 'returns false if element has not been located' do
|
764
|
+
expect(browser.form(id: 'new_user').tap(&:exists?)).to be_located
|
765
|
+
end
|
766
|
+
end
|
767
|
+
|
768
|
+
describe '#wd' do
|
769
|
+
it 'returns a Selenium::WebDriver::Element instance' do
|
770
|
+
element = browser.text_field(id: 'new_user_email')
|
771
|
+
expect(element.wd).to be_a(Selenium::WebDriver::Element)
|
721
772
|
end
|
722
773
|
end
|
723
774
|
end
|