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 "Hiddens" do
|
1
|
+
require 'watirspec_helper'
|
4
2
|
|
3
|
+
describe 'Hiddens' 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
|
10
|
-
it
|
11
|
-
expect(browser.hiddens(value:
|
8
|
+
describe 'with selectors' do
|
9
|
+
it 'returns the matching elements' do
|
10
|
+
expect(browser.hiddens(value: 'dolls').to_a).to eq [browser.hidden(value: 'dolls')]
|
12
11
|
end
|
13
12
|
end
|
14
13
|
|
15
|
-
describe
|
16
|
-
it
|
14
|
+
describe '#length' do
|
15
|
+
it 'returns the number of hiddens' do
|
17
16
|
expect(browser.hiddens.length).to eq 2
|
18
17
|
end
|
19
18
|
end
|
20
19
|
|
21
|
-
describe
|
22
|
-
it
|
23
|
-
expect(browser.hiddens[1].id).to eq
|
20
|
+
describe '#[]' do
|
21
|
+
it 'returns the Hidden at the given index' do
|
22
|
+
expect(browser.hiddens[1].id).to eq 'new_user_interests_dolls'
|
24
23
|
end
|
25
24
|
end
|
26
25
|
|
27
|
-
describe
|
28
|
-
it
|
26
|
+
describe '#each' do
|
27
|
+
it 'iterates through hiddens correctly' do
|
29
28
|
count = 0
|
30
29
|
|
31
30
|
browser.hiddens.each_with_index do |h, index|
|
@@ -39,5 +38,4 @@ describe "Hiddens" do
|
|
39
38
|
expect(count).to be > 0
|
40
39
|
end
|
41
40
|
end
|
42
|
-
|
43
41
|
end
|
@@ -1,31 +1,30 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
describe ["H1", "H2", "H3", "H4", "H5", "H6"] do
|
1
|
+
require 'watirspec_helper'
|
4
2
|
|
3
|
+
describe ['H1', 'H2', 'H3', 'H4', 'H5', 'H6'] do
|
5
4
|
before :each do
|
6
|
-
browser.goto(WatirSpec.url_for(
|
5
|
+
browser.goto(WatirSpec.url_for('non_control_elements.html'))
|
7
6
|
end
|
8
7
|
|
9
8
|
# Exists method
|
10
|
-
describe
|
11
|
-
it
|
12
|
-
expect(browser.h1(id:
|
9
|
+
describe '#exist?' do
|
10
|
+
it 'returns true if the element exists' do
|
11
|
+
expect(browser.h1(id: 'header1')).to exist
|
13
12
|
expect(browser.h2(id: /header2/)).to exist
|
14
|
-
expect(browser.h3(text:
|
13
|
+
expect(browser.h3(text: 'Header 3')).to exist
|
15
14
|
expect(browser.h4(text: /Header 4/)).to exist
|
16
15
|
expect(browser.h5(index: 0)).to exist
|
17
16
|
expect(browser.h6(index: 0)).to exist
|
18
17
|
expect(browser.h1(xpath: "//h1[@id='first_header']")).to exist
|
19
18
|
end
|
20
19
|
|
21
|
-
it
|
20
|
+
it 'returns the first h1 if given no args' do
|
22
21
|
expect(browser.h1).to exist
|
23
22
|
end
|
24
23
|
|
25
|
-
it
|
26
|
-
expect(browser.h1(id:
|
24
|
+
it 'returns true if the element exists' do
|
25
|
+
expect(browser.h1(id: 'no_such_id')).to_not exist
|
27
26
|
expect(browser.h1(id: /no_such_id/)).to_not exist
|
28
|
-
expect(browser.h1(text:
|
27
|
+
expect(browser.h1(text: 'no_such_text')).to_not exist
|
29
28
|
expect(browser.h1(text: /no_such_text 1/)).to_not exist
|
30
29
|
expect(browser.h1(index: 1337)).to_not exist
|
31
30
|
expect(browser.h1(xpath: "//p[@id='no_such_id']")).to_not exist
|
@@ -37,8 +36,8 @@ describe ["H1", "H2", "H3", "H4", "H5", "H6"] do
|
|
37
36
|
end
|
38
37
|
|
39
38
|
# Attribute methods
|
40
|
-
describe
|
41
|
-
it
|
39
|
+
describe '#class_name' do
|
40
|
+
it 'returns the class attribute' do
|
42
41
|
expect(browser.h1(index: 0).class_name).to eq 'primary'
|
43
42
|
end
|
44
43
|
|
@@ -51,9 +50,9 @@ describe ["H1", "H2", "H3", "H4", "H5", "H6"] do
|
|
51
50
|
end
|
52
51
|
end
|
53
52
|
|
54
|
-
describe
|
55
|
-
it
|
56
|
-
expect(browser.h1(index: 0).id).to eq
|
53
|
+
describe '#id' do
|
54
|
+
it 'returns the id attribute' do
|
55
|
+
expect(browser.h1(index: 0).id).to eq 'first_header'
|
57
56
|
end
|
58
57
|
|
59
58
|
it "returns an empty string if the element exists and the attribute doesn't" do
|
@@ -61,18 +60,18 @@ describe ["H1", "H2", "H3", "H4", "H5", "H6"] do
|
|
61
60
|
end
|
62
61
|
|
63
62
|
it "raises UnknownObjectException if the p doesn't exist" do
|
64
|
-
expect { browser.h1(id:
|
63
|
+
expect { browser.h1(id: 'no_such_id').id }.to raise_unknown_object_exception
|
65
64
|
expect { browser.h1(index: 1337).id }.to raise_unknown_object_exception
|
66
65
|
end
|
67
66
|
end
|
68
67
|
|
69
|
-
describe
|
70
|
-
it
|
68
|
+
describe '#text' do
|
69
|
+
it 'returns the text of the element' do
|
71
70
|
expect(browser.h1(index: 0).text).to eq 'Header 1'
|
72
71
|
end
|
73
72
|
|
74
73
|
it "returns an empty string if the element doesn't contain any text" do
|
75
|
-
expect(browser.h6(id:
|
74
|
+
expect(browser.h6(id: 'empty_header').text).to eq ''
|
76
75
|
end
|
77
76
|
|
78
77
|
it "raises UnknownObjectException if the p doesn't exist" do
|
@@ -81,12 +80,11 @@ describe ["H1", "H2", "H3", "H4", "H5", "H6"] do
|
|
81
80
|
end
|
82
81
|
end
|
83
82
|
|
84
|
-
describe
|
85
|
-
it
|
83
|
+
describe '#respond_to?' do
|
84
|
+
it 'returns true for all attribute methods' do
|
86
85
|
expect(browser.h1(index: 0)).to respond_to(:class_name)
|
87
86
|
expect(browser.h1(index: 0)).to respond_to(:id)
|
88
87
|
expect(browser.h1(index: 0)).to respond_to(:text)
|
89
88
|
end
|
90
89
|
end
|
91
|
-
|
92
90
|
end
|
@@ -1,30 +1,30 @@
|
|
1
|
-
require
|
1
|
+
require 'watirspec_helper'
|
2
2
|
|
3
|
-
describe [
|
3
|
+
describe ['H1s', 'H2s', 'H3s', 'H4s', 'H5s', 'H6s'] do
|
4
4
|
before :each do
|
5
|
-
browser.goto(WatirSpec.url_for(
|
5
|
+
browser.goto(WatirSpec.url_for('non_control_elements.html'))
|
6
6
|
end
|
7
7
|
|
8
|
-
describe
|
9
|
-
it
|
10
|
-
expect(browser.h1s(class:
|
8
|
+
describe 'with selectors' do
|
9
|
+
it 'returns the matching elements' do
|
10
|
+
expect(browser.h1s(class: 'primary').to_a).to eq [browser.h1(class: 'primary')]
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
describe
|
15
|
-
it
|
14
|
+
describe '#length' do
|
15
|
+
it 'returns the number of h1s' do
|
16
16
|
expect(browser.h2s.length).to eq 9
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
describe
|
21
|
-
it
|
22
|
-
expect(browser.h1s[0].id).to eq
|
20
|
+
describe '#[]' do
|
21
|
+
it 'returns the h1 at the given index' do
|
22
|
+
expect(browser.h1s[0].id).to eq 'first_header'
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
describe
|
27
|
-
it
|
26
|
+
describe '#each' do
|
27
|
+
it 'iterates through header collections correctly' do
|
28
28
|
lengths = (1..6).collect do |i|
|
29
29
|
collection = browser.send(:"h#{i}s")
|
30
30
|
collection.each_with_index do |h, index|
|
@@ -1,52 +1,75 @@
|
|
1
|
-
require
|
1
|
+
require 'watirspec_helper'
|
2
2
|
|
3
3
|
#
|
4
4
|
# TODO: fix duplication with frame_spec
|
5
5
|
#
|
6
6
|
|
7
|
-
describe
|
8
|
-
|
7
|
+
describe 'IFrame' do
|
9
8
|
before :each do
|
10
|
-
browser.goto(WatirSpec.url_for(
|
9
|
+
browser.goto(WatirSpec.url_for('iframes.html'))
|
11
10
|
end
|
12
11
|
|
13
12
|
not_compliant_on :safari do
|
14
|
-
bug
|
15
|
-
it
|
16
|
-
browser.goto WatirSpec.url_for(
|
17
|
-
|
18
|
-
expect(browser.iframe(id:
|
19
|
-
expect(browser.iframe(id:
|
20
|
-
browser.iframe(id:
|
21
|
-
expect(browser.iframe(id:
|
13
|
+
bug 'Firefox 58 broke this, apperas to be working in Nightly', %i[firefox linux] do
|
14
|
+
it 'handles crossframe javascript' do
|
15
|
+
browser.goto WatirSpec.url_for('iframes.html')
|
16
|
+
|
17
|
+
expect(browser.iframe(id: 'iframe_1').text_field(name: 'senderElement').value).to eq 'send_this_value'
|
18
|
+
expect(browser.iframe(id: 'iframe_2').text_field(name: 'recieverElement').value).to eq 'old_value'
|
19
|
+
browser.iframe(id: 'iframe_1').button(id: 'send').click
|
20
|
+
expect(browser.iframe(id: 'iframe_2').text_field(name: 'recieverElement').value).to eq 'send_this_value'
|
22
21
|
end
|
23
22
|
end
|
24
23
|
end
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
it 'locates an element defined by Selenium Element' do
|
26
|
+
iframe = browser.iframe(id: 'iframe_1').tap(&:exists?)
|
27
|
+
se_element = iframe.instance_variable_get('@element')
|
28
|
+
iframe2 = browser.element(element: se_element).to_subtype
|
29
|
+
expect(iframe2).to eq iframe
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#wd' do
|
33
|
+
it 'returns a Watir::FramedDriver instance' do
|
34
|
+
iframe = browser.iframe(id: 'iframe_1')
|
35
|
+
expect(iframe.wd).to be_a(Watir::FramedDriver)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'properly delegates driver commands' do
|
39
|
+
iframe = browser.iframe(id: 'iframe_1')
|
40
|
+
expect(iframe.wd.title).to eq 'Iframes'
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'properly delegates element commands' do
|
44
|
+
iframe = browser.iframe(id: 'iframe_1')
|
45
|
+
expect(iframe.wd.attribute('id')).to eq 'iframe_1'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#exist?' do
|
50
|
+
it 'returns true if the iframe exists' do
|
51
|
+
expect(browser.iframe(id: 'iframe_1')).to exist
|
52
|
+
expect(browser.iframe(name: 'iframe1')).to exist
|
30
53
|
expect(browser.iframe(index: 0)).to exist
|
31
|
-
expect(browser.iframe(class:
|
54
|
+
expect(browser.iframe(class: 'half')).to exist
|
32
55
|
expect(browser.iframe(xpath: "//iframe[@id='iframe_1']")).to exist
|
33
|
-
expect(browser.iframe(src:
|
56
|
+
expect(browser.iframe(src: 'iframe_1.html')).to exist
|
34
57
|
expect(browser.iframe(id: /iframe/)).to exist
|
35
58
|
expect(browser.iframe(name: /iframe/)).to exist
|
36
59
|
expect(browser.iframe(src: /iframe_1/)).to exist
|
37
60
|
expect(browser.iframe(class: /half/)).to exist
|
38
61
|
end
|
39
62
|
|
40
|
-
it
|
63
|
+
it 'returns the first iframe if given no args' do
|
41
64
|
expect(browser.iframe).to exist
|
42
65
|
end
|
43
66
|
|
44
67
|
it "returns false if the iframe doesn't exist" do
|
45
|
-
expect(browser.iframe(id:
|
46
|
-
expect(browser.iframe(name:
|
68
|
+
expect(browser.iframe(id: 'no_such_id')).to_not exist
|
69
|
+
expect(browser.iframe(name: 'no_such_text')).to_not exist
|
47
70
|
expect(browser.iframe(index: 1337)).to_not exist
|
48
|
-
expect(browser.iframe(src:
|
49
|
-
expect(browser.iframe(class:
|
71
|
+
expect(browser.iframe(src: 'no_such_src')).to_not exist
|
72
|
+
expect(browser.iframe(class: 'no_such_class')).to_not exist
|
50
73
|
expect(browser.iframe(id: /no_such_id/)).to_not exist
|
51
74
|
expect(browser.iframe(name: /no_such_text/)).to_not exist
|
52
75
|
expect(browser.iframe(src: /no_such_src/)).to_not exist
|
@@ -54,47 +77,47 @@ describe "IFrame" do
|
|
54
77
|
expect(browser.iframe(xpath: "//iframe[@id='no_such_id']")).to_not exist
|
55
78
|
end
|
56
79
|
|
57
|
-
it
|
58
|
-
expect(browser.iframe.element(css:
|
59
|
-
expect(browser.iframe.element(id:
|
80
|
+
it 'returns false if an element in an iframe does exist' do
|
81
|
+
expect(browser.iframe.element(css: '#senderElement')).to exist
|
82
|
+
expect(browser.iframe.element(id: 'senderElement')).to exist
|
60
83
|
end
|
61
84
|
|
62
|
-
it
|
63
|
-
expect(browser.iframe.element(css:
|
64
|
-
expect(browser.iframe.element(id:
|
85
|
+
it 'returns true if an element in an iframe does not exist' do
|
86
|
+
expect(browser.iframe.element(css: '#no_such_id')).to_not exist
|
87
|
+
expect(browser.iframe.element(id: 'no_such_id')).to_not exist
|
65
88
|
end
|
66
89
|
|
67
|
-
it
|
68
|
-
existing_element = browser.element(css:
|
90
|
+
it 'returns true if an element outside an iframe exists after checking for one inside that does exist' do
|
91
|
+
existing_element = browser.element(css: '#iframe_1')
|
69
92
|
expect(existing_element).to exist
|
70
|
-
expect(browser.iframe.element(css:
|
93
|
+
expect(browser.iframe.element(css: '#senderElement')).to exist
|
71
94
|
expect(existing_element).to exist
|
72
95
|
end
|
73
96
|
|
74
|
-
it
|
75
|
-
existing_element = browser.element(css:
|
97
|
+
it 'returns true if an element outside an iframe exists after checking for one inside that does not exist' do
|
98
|
+
existing_element = browser.element(css: '#iframe_1')
|
76
99
|
expect(existing_element).to exist
|
77
|
-
expect(browser.iframe.element(css:
|
100
|
+
expect(browser.iframe.element(css: '#no_such_id')).to_not exist
|
78
101
|
expect(existing_element).to exist
|
79
102
|
end
|
80
103
|
|
81
|
-
it
|
104
|
+
it 'returns true if an element exists in a frame generated in a collection' do
|
82
105
|
nested_element = browser.body.iframes.first.div
|
83
106
|
expect(nested_element).to exist
|
84
107
|
end
|
85
108
|
|
86
|
-
it
|
109
|
+
it 'returns false for sub-element of a non-existing iframe' do
|
87
110
|
expect(browser.iframe(id: 'no_such_id').element).to_not exist
|
88
111
|
end
|
89
112
|
|
90
|
-
bug
|
113
|
+
bug 'https://bugzilla.mozilla.org/show_bug.cgi?id=1255946', :firefox do
|
91
114
|
not_compliant_on :safari do
|
92
|
-
it
|
93
|
-
browser.goto(WatirSpec.url_for(
|
115
|
+
it 'handles nested iframes' do
|
116
|
+
browser.goto(WatirSpec.url_for('nested_iframes.html'))
|
94
117
|
|
95
|
-
browser.iframe(id:
|
118
|
+
browser.iframe(id: 'two').iframe(id: 'three').link(id: 'four').click
|
96
119
|
|
97
|
-
Watir::Wait.until { browser.title ==
|
120
|
+
Watir::Wait.until { browser.title == 'definition_lists' }
|
98
121
|
end
|
99
122
|
end
|
100
123
|
end
|
@@ -108,18 +131,18 @@ describe "IFrame" do
|
|
108
131
|
expect(browser.iframe(index: 0).div(id: 'invalid')).to_not exist
|
109
132
|
end
|
110
133
|
|
111
|
-
describe
|
112
|
-
it
|
113
|
-
expect(browser.iframe(id:
|
134
|
+
describe '#present?' do
|
135
|
+
it 'returns true if the iframe present' do
|
136
|
+
expect(browser.iframe(id: 'iframe_1')).to be_present
|
114
137
|
end
|
115
138
|
|
116
|
-
it
|
117
|
-
expect(browser.iframe(id:
|
139
|
+
it 'returns false if the iframe is not present' do
|
140
|
+
expect(browser.iframe(id: 'no_such_id')).not_to be_present
|
118
141
|
end
|
119
142
|
end
|
120
143
|
|
121
144
|
it 'switches between iframe and parent when needed' do
|
122
|
-
browser.iframe(id:
|
145
|
+
browser.iframe(id: 'iframe_1').elements.each do |element|
|
123
146
|
element.text
|
124
147
|
browser.h1.text
|
125
148
|
end
|
@@ -137,19 +160,19 @@ describe "IFrame" do
|
|
137
160
|
expect(browser.h1s.first.text).to be == 'Iframes'
|
138
161
|
end
|
139
162
|
|
140
|
-
it
|
141
|
-
expect { browser.iframe(name:
|
163
|
+
it 'raises UnknownFrameException when accessing elements inside non-existing iframe' do
|
164
|
+
expect { browser.iframe(name: 'no_such_name').p(index: 0).id }.to raise_unknown_frame_exception
|
142
165
|
end
|
143
166
|
|
144
|
-
it
|
145
|
-
expect { browser.iframe(name:
|
167
|
+
it 'raises UnknownFrameException when accessing a non-existing iframe' do
|
168
|
+
expect { browser.iframe(name: 'no_such_name').id }.to raise_unknown_frame_exception
|
146
169
|
end
|
147
170
|
|
148
|
-
it
|
149
|
-
expect { browser.iframe(name:
|
171
|
+
it 'raises UnknownFrameException when accessing a non-existing subframe' do
|
172
|
+
expect { browser.iframe(name: 'iframe1').iframe(name: 'no_such_name').id }.to raise_unknown_frame_exception
|
150
173
|
end
|
151
174
|
|
152
|
-
it
|
175
|
+
it 'raises UnknownObjectException when accessing a non-existing element inside an existing iframe' do
|
153
176
|
expect { browser.iframe(index: 0).p(index: 1337).id }.to raise_unknown_object_exception
|
154
177
|
end
|
155
178
|
|
@@ -157,38 +180,47 @@ describe "IFrame" do
|
|
157
180
|
expect { browser.iframe(index: 0).foo }.to raise_error(NoMethodError)
|
158
181
|
end
|
159
182
|
|
160
|
-
it
|
161
|
-
browser.iframe(index: 0).text_field(name: 'senderElement').set(
|
162
|
-
expect(browser.iframe(index: 0).text_field(name: 'senderElement').value).to eq
|
183
|
+
it 'is able to set a field' do
|
184
|
+
browser.iframe(index: 0).text_field(name: 'senderElement').set('new value')
|
185
|
+
expect(browser.iframe(index: 0).text_field(name: 'senderElement').value).to eq 'new value'
|
163
186
|
end
|
164
187
|
|
165
188
|
it 'will suggest looking in an iframe when iframes exist' do
|
166
|
-
|
189
|
+
msg = 'Maybe look in an iframe?'
|
190
|
+
expect { browser.text_field(name: 'senderElement').set('no') }.to raise_unknown_object_exception(msg)
|
167
191
|
end
|
168
192
|
|
169
|
-
|
170
|
-
|
171
|
-
|
193
|
+
it 'will suggest looking in a nested iframe when iframes exist' do
|
194
|
+
browser.goto(WatirSpec.url_for('nested_iframes.html'))
|
195
|
+
top = browser.iframe(id: 'two')
|
196
|
+
expect { top.link(id: 'four').click }.to raise_unknown_object_exception('Maybe look in an iframe?')
|
197
|
+
end
|
198
|
+
|
199
|
+
describe '#execute_script' do
|
200
|
+
bug 'Safari does not strip text', :safari do
|
201
|
+
it 'executes the given javascript in the specified frame' do
|
172
202
|
frame = browser.iframe(index: 0)
|
173
|
-
expect(frame.div(id: 'set_by_js').text).to eq
|
174
|
-
|
175
|
-
|
203
|
+
expect(frame.div(id: 'set_by_js').text).to eq ''
|
204
|
+
inner_html = 'Art consists of limitation. The most beautiful part of every picture is the frame.'
|
205
|
+
script = "document.getElementById('set_by_js').innerHTML = '#{inner_html}'"
|
206
|
+
frame.execute_script script
|
207
|
+
text = 'Art consists of limitation. The most beautiful part of every picture is the frame.'
|
208
|
+
expect(frame.div(id: 'set_by_js').text).to eq text
|
176
209
|
end
|
177
210
|
end
|
178
211
|
end
|
179
212
|
|
180
|
-
describe
|
181
|
-
it
|
182
|
-
browser.goto WatirSpec.url_for(
|
183
|
-
expect(browser.iframe.html.downcase).to include(
|
213
|
+
describe '#html' do
|
214
|
+
it 'returns the full HTML source of the iframe' do
|
215
|
+
browser.goto WatirSpec.url_for('iframes.html')
|
216
|
+
expect(browser.iframe.html.downcase).to include('<title>iframe 1</title>')
|
184
217
|
end
|
185
218
|
end
|
186
219
|
|
187
|
-
describe
|
188
|
-
it
|
189
|
-
browser.goto WatirSpec.url_for(
|
190
|
-
expect(browser.iframe.text).to include(
|
220
|
+
describe '#text' do
|
221
|
+
it 'returns the text inside the iframe' do
|
222
|
+
browser.goto WatirSpec.url_for('iframes.html')
|
223
|
+
expect(browser.iframe.text).to include('Frame 1')
|
191
224
|
end
|
192
225
|
end
|
193
|
-
|
194
226
|
end
|