watir 7.0.0 → 7.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/chrome.yml +29 -16
- data/.github/workflows/edge.yml +19 -11
- data/.github/workflows/firefox.yml +28 -16
- data/.github/workflows/ie.yml +13 -7
- data/.github/workflows/safari.yml +22 -11
- data/.github/workflows/unit.yml +31 -23
- data/.rubocop.yml +33 -13
- data/.rubocop_todo.yml +7 -26
- data/CHANGES.md +33 -0
- data/Gemfile +6 -1
- data/LICENSE +2 -2
- data/README.md +15 -11
- data/Rakefile +9 -7
- data/lib/watir/adjacent.rb +3 -1
- data/lib/watir/after_hooks.rb +5 -3
- data/lib/watir/alert.rb +2 -0
- data/lib/watir/aliases.rb +2 -0
- data/lib/watir/attribute_helper.rb +4 -2
- data/lib/watir/browser.rb +10 -14
- data/lib/watir/capabilities.rb +53 -33
- data/lib/watir/cell_container.rb +2 -0
- data/lib/watir/container.rb +2 -0
- data/lib/watir/cookies.rb +5 -5
- data/lib/watir/element_collection.rb +3 -1
- data/lib/watir/elements/button.rb +2 -0
- data/lib/watir/elements/cell.rb +2 -0
- data/lib/watir/elements/checkbox.rb +2 -0
- data/lib/watir/elements/date_field.rb +2 -0
- data/lib/watir/elements/date_time_field.rb +2 -0
- data/lib/watir/elements/dlist.rb +3 -1
- data/lib/watir/elements/element.rb +68 -118
- data/lib/watir/elements/file_field.rb +2 -0
- data/lib/watir/elements/font.rb +2 -0
- data/lib/watir/elements/form.rb +2 -0
- data/lib/watir/elements/hidden.rb +2 -0
- data/lib/watir/elements/iframe.rb +2 -0
- data/lib/watir/elements/image.rb +2 -0
- data/lib/watir/elements/input.rb +2 -0
- data/lib/watir/elements/link.rb +2 -0
- data/lib/watir/elements/list.rb +2 -0
- data/lib/watir/elements/option.rb +2 -0
- data/lib/watir/elements/radio.rb +2 -0
- data/lib/watir/elements/row.rb +2 -0
- data/lib/watir/elements/select.rb +2 -0
- data/lib/watir/elements/table.rb +3 -1
- data/lib/watir/elements/table_cell.rb +2 -0
- data/lib/watir/elements/table_row.rb +2 -0
- data/lib/watir/elements/table_section.rb +2 -0
- data/lib/watir/elements/text_area.rb +2 -0
- data/lib/watir/elements/text_field.rb +2 -0
- data/lib/watir/exception.rb +2 -0
- data/lib/watir/extensions/nokogiri.rb +2 -0
- data/lib/watir/generator/base/generator.rb +2 -0
- data/lib/watir/generator/base/idl_sorter.rb +3 -1
- data/lib/watir/generator/base/spec_extractor.rb +6 -4
- data/lib/watir/generator/base/util.rb +2 -0
- data/lib/watir/generator/base/visitor.rb +5 -5
- data/lib/watir/generator/base.rb +2 -1
- data/lib/watir/generator/html/generator.rb +2 -0
- data/lib/watir/generator/html/spec_extractor.rb +2 -0
- data/lib/watir/generator/html/visitor.rb +2 -0
- data/lib/watir/generator/html.rb +2 -0
- data/lib/watir/generator/svg/generator.rb +2 -0
- data/lib/watir/generator/svg/spec_extractor.rb +2 -0
- data/lib/watir/generator/svg/visitor.rb +2 -0
- data/lib/watir/generator/svg.rb +2 -0
- data/lib/watir/generator.rb +2 -0
- data/lib/watir/has_window.rb +3 -1
- data/lib/watir/http_client.rb +2 -0
- data/lib/watir/js_execution.rb +2 -0
- data/lib/watir/js_snippets/isElementInViewport.js +20 -0
- data/lib/watir/js_snippets.rb +2 -0
- data/lib/watir/locators/anchor/selector_builder.rb +5 -0
- data/lib/watir/locators/button/matcher.rb +2 -0
- data/lib/watir/locators/button/selector_builder/xpath.rb +15 -19
- data/lib/watir/locators/button/selector_builder.rb +2 -0
- data/lib/watir/locators/cell/selector_builder/xpath.rb +2 -0
- data/lib/watir/locators/cell/selector_builder.rb +2 -0
- data/lib/watir/locators/element/locator.rb +2 -0
- data/lib/watir/locators/element/matcher.rb +4 -1
- data/lib/watir/locators/element/selector_builder/regexp_disassembler.rb +4 -1
- data/lib/watir/locators/element/selector_builder/xpath.rb +16 -15
- data/lib/watir/locators/element/selector_builder/xpath_support.rb +4 -2
- data/lib/watir/locators/element/selector_builder.rb +16 -6
- data/lib/watir/locators/option/matcher.rb +2 -0
- data/lib/watir/locators/option/selector_builder/xpath.rb +2 -0
- data/lib/watir/locators/option/selector_builder.rb +2 -0
- data/lib/watir/locators/row/selector_builder/xpath.rb +2 -0
- data/lib/watir/locators/row/selector_builder.rb +2 -0
- data/lib/watir/locators/text_area/selector_builder/xpath.rb +2 -0
- data/lib/watir/locators/text_area/selector_builder.rb +2 -0
- data/lib/watir/locators/text_field/matcher.rb +2 -4
- data/lib/watir/locators/text_field/selector_builder/xpath.rb +2 -0
- data/lib/watir/locators/text_field/selector_builder.rb +2 -0
- data/lib/watir/locators.rb +2 -0
- data/lib/watir/logger.rb +2 -0
- data/lib/watir/navigation.rb +3 -1
- data/lib/watir/radio_set.rb +2 -0
- data/lib/watir/row_container.rb +2 -0
- data/lib/watir/screenshot.rb +2 -0
- data/lib/watir/scroll.rb +29 -3
- data/lib/watir/search_context.rb +96 -0
- data/lib/watir/shadow_root.rb +60 -0
- data/lib/watir/user_editable.rb +3 -1
- data/lib/watir/version.rb +3 -1
- data/lib/watir/wait/timer.rb +3 -1
- data/lib/watir/wait.rb +5 -5
- data/lib/watir/window.rb +7 -3
- data/lib/watir/window_collection.rb +4 -1
- data/lib/watir.rb +4 -0
- data/lib/watirspec/guards.rb +2 -0
- data/lib/watirspec/implementation.rb +14 -10
- data/lib/watirspec/rake_tasks.rb +4 -4
- data/lib/watirspec/remote_server.rb +5 -3
- data/lib/watirspec/runner.rb +3 -1
- data/lib/watirspec/server/app.rb +2 -0
- data/lib/watirspec/server.rb +2 -0
- data/lib/watirspec.rb +7 -4
- data/spec/locator_spec_helper.rb +2 -8
- data/spec/spec_helper.rb +2 -0
- data/spec/unit/capabilities_spec.rb +561 -550
- data/spec/unit/element_locator_spec.rb +71 -58
- data/spec/unit/match_elements/button_spec.rb +58 -49
- data/spec/unit/match_elements/element_spec.rb +305 -309
- data/spec/unit/match_elements/text_field_spec.rb +78 -73
- data/spec/unit/selector_builder/anchor_spec.rb +41 -33
- data/spec/unit/selector_builder/button_spec.rb +211 -201
- data/spec/unit/selector_builder/cell_spec.rb +50 -42
- data/spec/unit/selector_builder/element_spec.rb +636 -628
- data/spec/unit/selector_builder/row_spec.rb +121 -104
- data/spec/unit/selector_builder/text_field_spec.rb +197 -182
- data/spec/unit/selector_builder/textarea_spec.rb +24 -14
- data/spec/unit/unit_helper.rb +2 -0
- data/spec/unit/wait_spec.rb +77 -71
- data/spec/watirspec/adjacent_spec.rb +251 -247
- data/spec/watirspec/after_hooks_spec.rb +160 -162
- data/spec/watirspec/alert_spec.rb +63 -58
- data/spec/watirspec/browser_spec.rb +411 -407
- data/spec/watirspec/capabilities_spec.rb +566 -0
- data/spec/watirspec/cookies_spec.rb +122 -118
- data/spec/watirspec/drag_and_drop_spec.rb +30 -14
- data/spec/watirspec/element_hidden_spec.rb +68 -60
- data/spec/watirspec/elements/area_spec.rb +51 -47
- data/spec/watirspec/elements/areas_spec.rb +29 -25
- data/spec/watirspec/elements/button_spec.rb +255 -251
- data/spec/watirspec/elements/buttons_spec.rb +38 -34
- data/spec/watirspec/elements/checkbox_spec.rb +50 -36
- data/spec/watirspec/elements/checkboxes_spec.rb +31 -27
- data/spec/watirspec/elements/collections_spec.rb +128 -119
- data/spec/watirspec/elements/date_field_spec.rb +187 -183
- data/spec/watirspec/elements/date_fields_spec.rb +31 -27
- data/spec/watirspec/elements/date_time_field_spec.rb +199 -195
- data/spec/watirspec/elements/date_time_fields_spec.rb +32 -28
- data/spec/watirspec/elements/dd_spec.rb +89 -85
- data/spec/watirspec/elements/dds_spec.rb +29 -25
- data/spec/watirspec/elements/del_spec.rb +108 -104
- data/spec/watirspec/elements/dels_spec.rb +28 -24
- data/spec/watirspec/elements/div_spec.rb +227 -211
- data/spec/watirspec/elements/divs_spec.rb +39 -35
- data/spec/watirspec/elements/dl_spec.rb +112 -110
- data/spec/watirspec/elements/dls_spec.rb +30 -26
- data/spec/watirspec/elements/dt_spec.rb +88 -84
- data/spec/watirspec/elements/dts_spec.rb +29 -25
- data/spec/watirspec/elements/element_spec.rb +815 -715
- data/spec/watirspec/elements/elements_spec.rb +42 -38
- data/spec/watirspec/elements/em_spec.rb +64 -60
- data/spec/watirspec/elements/ems_spec.rb +30 -26
- data/spec/watirspec/elements/filefield_spec.rb +100 -96
- data/spec/watirspec/elements/filefields_spec.rb +30 -26
- data/spec/watirspec/elements/font_spec.rb +22 -18
- data/spec/watirspec/elements/form_spec.rb +53 -49
- data/spec/watirspec/elements/forms_spec.rb +31 -27
- data/spec/watirspec/elements/frame_spec.rb +91 -87
- data/spec/watirspec/elements/frames_spec.rb +29 -25
- data/spec/watirspec/elements/hidden_spec.rb +81 -77
- data/spec/watirspec/elements/hiddens_spec.rb +30 -26
- data/spec/watirspec/elements/hn_spec.rb +61 -57
- data/spec/watirspec/elements/hns_spec.rb +28 -24
- data/spec/watirspec/elements/iframe_spec.rb +197 -191
- data/spec/watirspec/elements/iframes_spec.rb +33 -29
- data/spec/watirspec/elements/image_spec.rb +146 -142
- data/spec/watirspec/elements/images_spec.rb +28 -24
- data/spec/watirspec/elements/input_spec.rb +11 -7
- data/spec/watirspec/elements/ins_spec.rb +108 -104
- data/spec/watirspec/elements/inses_spec.rb +28 -24
- data/spec/watirspec/elements/label_spec.rb +58 -54
- data/spec/watirspec/elements/labels_spec.rb +28 -24
- data/spec/watirspec/elements/li_spec.rb +76 -72
- data/spec/watirspec/elements/link_spec.rb +175 -179
- data/spec/watirspec/elements/links_spec.rb +47 -43
- data/spec/watirspec/elements/lis_spec.rb +29 -25
- data/spec/watirspec/elements/list_spec.rb +46 -42
- data/spec/watirspec/elements/map_spec.rb +59 -55
- data/spec/watirspec/elements/maps_spec.rb +29 -25
- data/spec/watirspec/elements/meta_spec.rb +18 -14
- data/spec/watirspec/elements/metas_spec.rb +28 -24
- data/spec/watirspec/elements/ol_spec.rb +58 -65
- data/spec/watirspec/elements/ols_spec.rb +28 -24
- data/spec/watirspec/elements/option_spec.rb +93 -89
- data/spec/watirspec/elements/p_spec.rb +79 -75
- data/spec/watirspec/elements/pre_spec.rb +77 -73
- data/spec/watirspec/elements/pres_spec.rb +28 -24
- data/spec/watirspec/elements/ps_spec.rb +28 -24
- data/spec/watirspec/elements/radio_spec.rb +253 -249
- data/spec/watirspec/elements/radios_spec.rb +30 -26
- data/spec/watirspec/elements/select_list_spec.rb +539 -522
- data/spec/watirspec/elements/select_lists_spec.rb +34 -30
- data/spec/watirspec/elements/span_spec.rb +114 -110
- data/spec/watirspec/elements/spans_spec.rb +28 -24
- data/spec/watirspec/elements/strong_spec.rb +60 -58
- data/spec/watirspec/elements/strongs_spec.rb +30 -26
- data/spec/watirspec/elements/table_spec.rb +194 -139
- data/spec/watirspec/elements/tables_spec.rb +30 -26
- data/spec/watirspec/elements/tbody_spec.rb +71 -67
- data/spec/watirspec/elements/tbodys_spec.rb +42 -38
- data/spec/watirspec/elements/td_spec.rb +68 -64
- data/spec/watirspec/elements/tds_spec.rb +43 -39
- data/spec/watirspec/elements/text_field_spec.rb +208 -204
- data/spec/watirspec/elements/text_fields_spec.rb +32 -28
- data/spec/watirspec/elements/textarea_spec.rb +22 -18
- data/spec/watirspec/elements/textareas_spec.rb +20 -16
- data/spec/watirspec/elements/tfoot_spec.rb +67 -63
- data/spec/watirspec/elements/tfoots_spec.rb +44 -40
- data/spec/watirspec/elements/thead_spec.rb +67 -63
- data/spec/watirspec/elements/theads_spec.rb +44 -40
- data/spec/watirspec/elements/tr_spec.rb +50 -46
- data/spec/watirspec/elements/trs_spec.rb +44 -40
- data/spec/watirspec/elements/ul_spec.rb +58 -54
- data/spec/watirspec/elements/uls_spec.rb +28 -24
- data/spec/watirspec/html/child_frame.html +29 -0
- data/spec/watirspec/html/class_locator.html +2 -0
- data/spec/watirspec/html/scroll.html +8 -25
- data/spec/watirspec/html/scroll_nested.html +17 -0
- data/spec/watirspec/html/scroll_nested_offscreen.html +18 -0
- data/spec/watirspec/html/shadow_dom.html +28 -0
- data/spec/watirspec/html/sticky_elements.html +10 -0
- data/spec/watirspec/radio_set_spec.rb +271 -267
- data/spec/watirspec/screenshot_spec.rb +22 -18
- data/spec/watirspec/scroll_spec.rb +179 -77
- data/spec/watirspec/shadow_root_spec.rb +106 -0
- data/spec/watirspec/support/rspec_matchers.rb +35 -32
- data/spec/watirspec/user_editable_spec.rb +202 -198
- data/spec/watirspec/wait_spec.rb +291 -295
- data/spec/watirspec/window_switching_spec.rb +426 -428
- data/spec/watirspec_helper.rb +25 -42
- data/support/doctest_helper.rb +2 -0
- data/support/version_differ.rb +2 -0
- data/watir.gemspec +14 -10
- metadata +91 -240
- data/.github/actions/enable-safari/action.yml +0 -11
- data/.github/actions/install-chrome/action.yml +0 -12
- data/.github/actions/setup-linux/action.yml +0 -8
- data/lib/watir-webdriver.rb +0 -2
- data/spec/watirspec/attributes_spec.rb +0 -16
- data/spec/watirspec/elements/table_nesting_spec.rb +0 -49
- data/spec/watirspec/html/hover.html +0 -12
- data/spec/watirspec/special_chars_spec.rb +0 -21
@@ -1,64 +1,68 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
before :each do
|
5
|
-
browser.goto(WatirSpec.url_for('tables.html'))
|
6
|
-
end
|
3
|
+
require 'watirspec_helper'
|
7
4
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
expect(browser.tr(index: 0)).to exist
|
13
|
-
browser.tr(xpath: "//tr[@id='outer_first']")
|
5
|
+
module Watir
|
6
|
+
describe TableRow do
|
7
|
+
before do
|
8
|
+
browser.goto(WatirSpec.url_for('tables.html'))
|
14
9
|
end
|
15
10
|
|
16
|
-
|
17
|
-
|
18
|
-
|
11
|
+
describe '#exists?' do
|
12
|
+
it 'returns true if the table row exists' do
|
13
|
+
expect(browser.tr(id: 'outer_first')).to exist
|
14
|
+
expect(browser.tr(id: /outer_first/)).to exist
|
15
|
+
expect(browser.tr(index: 0)).to exist
|
16
|
+
browser.tr(xpath: "//tr[@id='outer_first']")
|
17
|
+
end
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
expect(browser.tr(index: 1337)).to_not exist
|
24
|
-
browser.tr(xpath: "//tr[@id='no_such_id']")
|
25
|
-
end
|
19
|
+
it 'returns the first row if given no args' do
|
20
|
+
expect(browser.tr).to exist
|
21
|
+
end
|
26
22
|
|
27
|
-
|
28
|
-
|
23
|
+
it "returns false if the table row doesn't exist" do
|
24
|
+
expect(browser.tr(id: 'no_such_id')).not_to exist
|
25
|
+
expect(browser.tr(id: /no_such_id/)).not_to exist
|
26
|
+
expect(browser.tr(index: 1337)).not_to exist
|
27
|
+
browser.tr(xpath: "//tr[@id='no_such_id']")
|
28
|
+
end
|
29
|
+
|
30
|
+
it "raises TypeError when 'what' argument is invalid" do
|
31
|
+
expect { browser.tr(id: 3.14).exists? }.to raise_error(TypeError)
|
32
|
+
end
|
29
33
|
end
|
30
|
-
end
|
31
34
|
|
32
|
-
|
33
|
-
|
35
|
+
describe '#[]', except: {browser: :safari, reason: 'Safari does not strip text'} do
|
36
|
+
let(:table) { browser.table(id: 'outer') }
|
34
37
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
+
it 'returns the nth cell of the row' do
|
39
|
+
expect(table[0][0].text).to eq 'Table 1, Row 1, Cell 1'
|
40
|
+
expect(table[2][0].text).to eq 'Table 1, Row 3, Cell 1'
|
41
|
+
end
|
38
42
|
end
|
39
|
-
end
|
40
43
|
|
41
|
-
|
42
|
-
|
44
|
+
describe '#cells' do
|
45
|
+
let(:table) { browser.table(id: 'outer') }
|
43
46
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
47
|
+
it 'returns the correct number of cells' do
|
48
|
+
expect(table[0].cells.length).to eq 2
|
49
|
+
expect(table[1].cells.length).to eq 2
|
50
|
+
expect(table[2].cells.length).to eq 2
|
51
|
+
end
|
49
52
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
+
it 'finds cells in the table' do
|
54
|
+
expect(table[0].cells(text: /Table 1/).size).to eq 2
|
55
|
+
end
|
53
56
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
57
|
+
it 'does not find cells from nested tables' do
|
58
|
+
expect(table[1].cell(id: 't2_r1_c1')).not_to exist
|
59
|
+
expect(table[1].cell(id: /t2_r1_c1/)).not_to exist
|
60
|
+
end
|
58
61
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
+
it 'iterates correctly through the cells of the row' do
|
63
|
+
browser.table(id: 'outer').tr(index: 1).each_with_index do |cell, idx|
|
64
|
+
expect(cell.id).to eq "t1_r2_c#{idx + 1}"
|
65
|
+
end
|
62
66
|
end
|
63
67
|
end
|
64
68
|
end
|
@@ -1,59 +1,63 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe 'TableRows' do
|
4
|
-
before :each do
|
5
|
-
browser.goto(WatirSpec.url_for('tables.html'))
|
6
|
-
end
|
1
|
+
# frozen_string_literal: true
|
7
2
|
|
8
|
-
|
9
|
-
it 'returns the matching elements' do
|
10
|
-
expect(browser.trs(id: 'outer_second').to_a).to eq [browser.tr(id: 'outer_second')]
|
11
|
-
end
|
12
|
-
end
|
3
|
+
require 'watirspec_helper'
|
13
4
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
5
|
+
module Watir
|
6
|
+
describe TableRowCollection do
|
7
|
+
before do
|
8
|
+
browser.goto(WatirSpec.url_for('tables.html'))
|
18
9
|
end
|
19
10
|
|
20
|
-
|
21
|
-
|
11
|
+
describe 'with selectors' do
|
12
|
+
it 'returns the matching elements' do
|
13
|
+
expect(browser.trs(id: 'outer_second').to_a).to eq [browser.tr(id: 'outer_second')]
|
14
|
+
end
|
22
15
|
end
|
23
|
-
end
|
24
16
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
17
|
+
describe '#length' do
|
18
|
+
it 'returns the correct number of cells (table context)' do
|
19
|
+
expect(browser.table(id: 'inner').trs.length).to eq 1
|
20
|
+
expect(browser.table(id: 'outer').trs.length).to eq 4
|
21
|
+
end
|
29
22
|
|
30
|
-
|
31
|
-
|
23
|
+
it 'returns the correct number of cells (page context)' do
|
24
|
+
expect(browser.trs.length).to eq 14
|
25
|
+
end
|
32
26
|
end
|
33
|
-
end
|
34
27
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
28
|
+
describe '#[]' do
|
29
|
+
it 'returns the row at the given index (table context)' do
|
30
|
+
expect(browser.table(id: 'outer').trs[0].id).to eq 'outer_first'
|
31
|
+
end
|
39
32
|
|
40
|
-
|
41
|
-
expect(
|
42
|
-
count += 1
|
33
|
+
it 'returns the row at the given index (page context)' do
|
34
|
+
expect(browser.trs[0].id).to eq 'thead_row_1'
|
43
35
|
end
|
44
|
-
expect(count).to be > 0
|
45
36
|
end
|
46
37
|
|
47
|
-
|
48
|
-
|
49
|
-
|
38
|
+
describe '#each' do
|
39
|
+
it 'iterates through rows correctly' do
|
40
|
+
inner_table = browser.table(id: 'inner')
|
41
|
+
count = 0
|
50
42
|
|
51
|
-
|
52
|
-
|
53
|
-
|
43
|
+
inner_table.trs.each_with_index do |r, index|
|
44
|
+
expect(r.id).to eq inner_table.tr(index: index).id
|
45
|
+
count += 1
|
46
|
+
end
|
47
|
+
expect(count).to be > 0
|
54
48
|
end
|
55
49
|
|
56
|
-
|
50
|
+
it 'iterates through the outer table correctly' do
|
51
|
+
outer_table = browser.table(id: 'outer')
|
52
|
+
count = 0
|
53
|
+
|
54
|
+
outer_table.trs.each_with_index do |r, index|
|
55
|
+
expect(r.id).to eq outer_table.tr(index: index).id
|
56
|
+
count += 1
|
57
|
+
end
|
58
|
+
|
59
|
+
expect(count).to be > 0
|
60
|
+
end
|
57
61
|
end
|
58
62
|
end
|
59
63
|
end
|
@@ -1,59 +1,63 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe 'Ul' do
|
4
|
-
before :each do
|
5
|
-
browser.goto(WatirSpec.url_for('non_control_elements.html'))
|
6
|
-
end
|
7
|
-
|
8
|
-
# Exists method
|
9
|
-
describe '#exist?' do
|
10
|
-
it "returns true if the 'ul' exists" do
|
11
|
-
expect(browser.ul(id: 'navbar')).to exist
|
12
|
-
expect(browser.ul(id: /navbar/)).to exist
|
13
|
-
expect(browser.ul(index: 0)).to exist
|
14
|
-
expect(browser.ul(xpath: "//ul[@id='navbar']")).to exist
|
15
|
-
end
|
1
|
+
# frozen_string_literal: true
|
16
2
|
|
17
|
-
|
18
|
-
expect(browser.ul).to exist
|
19
|
-
end
|
20
|
-
|
21
|
-
it "returns false if the 'ul' doesn't exist" do
|
22
|
-
expect(browser.ul(id: 'no_such_id')).to_not exist
|
23
|
-
expect(browser.ul(id: /no_such_id/)).to_not exist
|
24
|
-
expect(browser.ul(text: 'no_such_text')).to_not exist
|
25
|
-
expect(browser.ul(text: /no_such_text/)).to_not exist
|
26
|
-
expect(browser.ul(class: 'no_such_class')).to_not exist
|
27
|
-
expect(browser.ul(class: /no_such_class/)).to_not exist
|
28
|
-
expect(browser.ul(index: 1337)).to_not exist
|
29
|
-
expect(browser.ul(xpath: "//ul[@id='no_such_id']")).to_not exist
|
30
|
-
end
|
31
|
-
|
32
|
-
it "raises TypeError when 'what' argument is invalid" do
|
33
|
-
expect { browser.ul(id: 3.14).exists? }.to raise_error(TypeError)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
# Attribute methods
|
38
|
-
describe '#id' do
|
39
|
-
it 'returns the id attribute' do
|
40
|
-
expect(browser.ul(class: 'navigation').id).to eq 'navbar'
|
41
|
-
end
|
42
|
-
|
43
|
-
it "returns an empty string if the element exists and the attribute doesn't" do
|
44
|
-
expect(browser.ul(index: 1).id).to eq ''
|
45
|
-
end
|
46
|
-
|
47
|
-
it "raises UnknownObjectException if the ul doesn't exist" do
|
48
|
-
expect { browser.ul(id: 'no_such_id').id }.to raise_unknown_object_exception
|
49
|
-
expect { browser.ul(index: 1337).id }.to raise_unknown_object_exception
|
50
|
-
end
|
51
|
-
end
|
3
|
+
require 'watirspec_helper'
|
52
4
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
5
|
+
module Watir
|
6
|
+
describe UList do
|
7
|
+
before do
|
8
|
+
browser.goto(WatirSpec.url_for('non_control_elements.html'))
|
9
|
+
end
|
10
|
+
|
11
|
+
# Exists method
|
12
|
+
describe '#exist?' do
|
13
|
+
it "returns true if the 'ul' exists" do
|
14
|
+
expect(browser.ul(id: 'navbar')).to exist
|
15
|
+
expect(browser.ul(id: /navbar/)).to exist
|
16
|
+
expect(browser.ul(index: 0)).to exist
|
17
|
+
expect(browser.ul(xpath: "//ul[@id='navbar']")).to exist
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'returns the first ul if given no args' do
|
21
|
+
expect(browser.ul).to exist
|
22
|
+
end
|
23
|
+
|
24
|
+
it "returns false if the 'ul' doesn't exist" do
|
25
|
+
expect(browser.ul(id: 'no_such_id')).not_to exist
|
26
|
+
expect(browser.ul(id: /no_such_id/)).not_to exist
|
27
|
+
expect(browser.ul(text: 'no_such_text')).not_to exist
|
28
|
+
expect(browser.ul(text: /no_such_text/)).not_to exist
|
29
|
+
expect(browser.ul(class: 'no_such_class')).not_to exist
|
30
|
+
expect(browser.ul(class: /no_such_class/)).not_to exist
|
31
|
+
expect(browser.ul(index: 1337)).not_to exist
|
32
|
+
expect(browser.ul(xpath: "//ul[@id='no_such_id']")).not_to exist
|
33
|
+
end
|
34
|
+
|
35
|
+
it "raises TypeError when 'what' argument is invalid" do
|
36
|
+
expect { browser.ul(id: 3.14).exists? }.to raise_error(TypeError)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Attribute methods
|
41
|
+
describe '#id' do
|
42
|
+
it 'returns the id attribute' do
|
43
|
+
expect(browser.ul(class: 'navigation').id).to eq 'navbar'
|
44
|
+
end
|
45
|
+
|
46
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
47
|
+
expect(browser.ul(index: 1).id).to eq ''
|
48
|
+
end
|
49
|
+
|
50
|
+
it "raises UnknownObjectException if the ul doesn't exist" do
|
51
|
+
expect { browser.ul(id: 'no_such_id').id }.to raise_unknown_object_exception
|
52
|
+
expect { browser.ul(index: 1337).id }.to raise_unknown_object_exception
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#respond_to?' do
|
57
|
+
it 'returns true for all attribute methods' do
|
58
|
+
expect(browser.ul(index: 0)).to respond_to(:class_name)
|
59
|
+
expect(browser.ul(index: 0)).to respond_to(:id)
|
60
|
+
end
|
57
61
|
end
|
58
62
|
end
|
59
63
|
end
|
@@ -1,38 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'watirspec_helper'
|
2
4
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
5
|
+
module Watir
|
6
|
+
describe UListCollection do
|
7
|
+
before do
|
8
|
+
browser.goto(WatirSpec.url_for('non_control_elements.html'))
|
9
|
+
end
|
7
10
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
+
describe 'with selectors' do
|
12
|
+
it 'returns the matching elements' do
|
13
|
+
expect(browser.uls(class: 'navigation').to_a).to eq [browser.ul(class: 'navigation')]
|
14
|
+
end
|
11
15
|
end
|
12
|
-
end
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
+
describe '#length' do
|
18
|
+
it 'returns the number of uls' do
|
19
|
+
expect(browser.uls.length).to eq 2
|
20
|
+
end
|
17
21
|
end
|
18
|
-
end
|
19
22
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
+
describe '#[]' do
|
24
|
+
it 'returns the ul at the given index' do
|
25
|
+
expect(browser.uls[0].id).to eq 'navbar'
|
26
|
+
end
|
23
27
|
end
|
24
|
-
end
|
25
28
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
+
describe '#each' do
|
30
|
+
it 'iterates through uls correctly' do
|
31
|
+
count = 0
|
29
32
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
33
|
+
browser.uls.each_with_index do |ul, index|
|
34
|
+
expect(ul.id).to eq browser.ul(index: index).id
|
35
|
+
count += 1
|
36
|
+
end
|
34
37
|
|
35
|
-
|
38
|
+
expect(count).to be > 0
|
39
|
+
end
|
36
40
|
end
|
37
41
|
end
|
38
42
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Child frame</title>
|
5
|
+
<meta name="author" content="Software Freedom Conservancy">
|
6
|
+
<link rel="author" href="https://github.com/SeleniumHQ/selenium/blob/selenium-4.2.0/common/src/web/scrolling_tests/frame_with_height_above_200.html">
|
7
|
+
<link rel="license" href="https://github.com/SeleniumHQ/selenium/blob/trunk/LICENSE">
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<h1>This is a scrolling frame test</h1>
|
11
|
+
<div>
|
12
|
+
<table>
|
13
|
+
<tr height="50px">
|
14
|
+
<td>First row</td>
|
15
|
+
</tr>
|
16
|
+
<tr height="50px">
|
17
|
+
<td>Second row</td>
|
18
|
+
</tr>
|
19
|
+
<tr height="50px">
|
20
|
+
<td>Third row</td>
|
21
|
+
</tr>
|
22
|
+
<tr height="50px">
|
23
|
+
<td>Fourth row</td>
|
24
|
+
</tr>
|
25
|
+
</table>
|
26
|
+
</div>
|
27
|
+
<input type='checkbox' name='scroll_checkbox' />
|
28
|
+
</body>
|
29
|
+
</html>
|
@@ -1,32 +1,15 @@
|
|
1
1
|
<html>
|
2
2
|
<head>
|
3
|
-
<
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
var width = el.offsetWidth;
|
8
|
-
var height = el.offsetHeight;
|
9
|
-
|
10
|
-
while (el.offsetParent) {
|
11
|
-
el = el.offsetParent;
|
12
|
-
top += el.offsetTop;
|
13
|
-
left += el.offsetLeft;
|
14
|
-
}
|
15
|
-
|
16
|
-
return (
|
17
|
-
top < (window.pageYOffset + window.innerHeight) &&
|
18
|
-
left < (window.pageXOffset + window.innerWidth) &&
|
19
|
-
(top + height) > window.pageYOffset &&
|
20
|
-
(left + width) > window.pageXOffset
|
21
|
-
);
|
22
|
-
}
|
23
|
-
</script>
|
3
|
+
<style media="screen">
|
4
|
+
div { color: blue; }
|
5
|
+
div:hover { color: orange; }
|
6
|
+
</style>
|
24
7
|
</head>
|
25
8
|
<body>
|
26
|
-
<div style="height:
|
27
|
-
<
|
28
|
-
<
|
29
|
-
<
|
9
|
+
<div style="height: 300%; position: relative;">
|
10
|
+
<div id="top" style="position: absolute; top: 0;">top</div>
|
11
|
+
<div id="center" style="position: absolute; top: 50%;">Center</div>
|
12
|
+
<div id="bottom" style="position: absolute; top: 100%;">bottom</div>
|
30
13
|
</div>
|
31
14
|
</body>
|
32
15
|
</html>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Welcome Page</title>
|
5
|
+
<meta name="author" content="Software Freedom Conservancy">
|
6
|
+
<link rel="author" href="https://github.com/SeleniumHQ/selenium/blob/selenium-4.2.0/common/src/web/scrolling_tests/frame_with_height_above_200.html">
|
7
|
+
<link rel="license" href="https://github.com/SeleniumHQ/selenium/blob/trunk/LICENSE">
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<div>
|
11
|
+
<iframe name="nested_scrolling_frame" src="child_frame.html" width="800" height="200" ></iframe>
|
12
|
+
</div>
|
13
|
+
<div><a href="https://github.com/SeleniumHQ/selenium/blob/selenium-4.2.0/common/src/web/scrolling_tests/frame_with_nested_scrolling_frame_out_of_view.html">
|
14
|
+
© Software Freedom Conservancy
|
15
|
+
</a></div>
|
16
|
+
</body>
|
17
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Welcome Page</title>
|
5
|
+
<meta name="author" content="Software Freedom Conservancy">
|
6
|
+
<link rel="author" href="https://github.com/SeleniumHQ/selenium/blob/selenium-4.2.0/common/src/web/scrolling_tests/frame_with_height_above_200.html">
|
7
|
+
<link rel="license" href="https://github.com/SeleniumHQ/selenium/blob/trunk/LICENSE">
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<div style="height: 5000px;"><a href="https://github.com/SeleniumHQ/selenium/blob/selenium-4.2.0/common/src/web/scrolling_tests/frame_with_nested_scrolling_frame_out_of_view.html">
|
11
|
+
HTML copyright Software Freedom Conservancy
|
12
|
+
</a></div>
|
13
|
+
<div>
|
14
|
+
<iframe name="nested_scrolling_frame" src="child_frame.html" width="800" height="200" ></iframe>
|
15
|
+
</div>
|
16
|
+
<footer>IFrame Above</footer>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
5
|
+
<title>Shadow DOM</title>
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<div id="non_host"></div>
|
9
|
+
<div id="shadow_host"></div>
|
10
|
+
<a href="scroll.html">scroll.html</a>
|
11
|
+
<script>
|
12
|
+
let shadowRoot = document.getElementById('shadow_host').attachShadow({mode: 'open'});
|
13
|
+
shadowRoot.innerHTML = `
|
14
|
+
<span class="wrapper" id="shadow_content"><span class="info">some text</span></span>
|
15
|
+
<div id="nested_shadow_host"></div>
|
16
|
+
<div id="chrome_workaround"><a href="scroll.html">scroll.html</a></div>
|
17
|
+
<input type="text" />
|
18
|
+
<input type="checkbox" />
|
19
|
+
<input type="file" />
|
20
|
+
`;
|
21
|
+
|
22
|
+
let nestedShadowRoot = shadowRoot.getElementById('nested_shadow_host').attachShadow({mode: 'open'});
|
23
|
+
nestedShadowRoot.innerHTML = `
|
24
|
+
<div id="nested_shadow_content"><div>nested text</div></div>
|
25
|
+
`;
|
26
|
+
</script>
|
27
|
+
</body>
|
28
|
+
</html>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<html>
|
2
|
+
<body>
|
3
|
+
<div style="height: 300%; position: relative;">
|
4
|
+
<header style="position: sticky; z-index: 10; top: 0;"><h1>Sticky Header</h1></header>
|
5
|
+
<div id="top" style="position: absolute; top: 0;">top</div>
|
6
|
+
<div id="center" style="position: absolute; top: 50%;">Center</div>
|
7
|
+
<div id="bottom" style="position: absolute; top: 100%;">bottom</div>
|
8
|
+
</div>
|
9
|
+
</body>
|
10
|
+
</html>
|