watir 7.0.0.beta1 → 7.0.0.beta5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/tests.yml +7 -3
  3. data/.rubocop.yml +2 -7
  4. data/CHANGES.md +32 -0
  5. data/lib/watir/browser.rb +21 -7
  6. data/lib/watir/capabilities.rb +52 -7
  7. data/lib/watir/elements/date_field.rb +4 -1
  8. data/lib/watir/elements/date_time_field.rb +4 -1
  9. data/lib/watir/elements/element.rb +32 -3
  10. data/lib/watir/elements/font.rb +1 -0
  11. data/lib/watir/elements/iframe.rb +0 -1
  12. data/lib/watir/elements/radio.rb +2 -2
  13. data/lib/watir/elements/select.rb +63 -40
  14. data/lib/watir/has_window.rb +2 -0
  15. data/lib/watir/locators.rb +4 -0
  16. data/lib/watir/locators/element/matcher.rb +1 -1
  17. data/lib/watir/locators/element/selector_builder.rb +0 -3
  18. data/lib/watir/locators/element/selector_builder/xpath.rb +2 -1
  19. data/lib/watir/locators/option/matcher.rb +24 -0
  20. data/lib/watir/locators/option/selector_builder.rb +8 -0
  21. data/lib/watir/locators/option/selector_builder/xpath.rb +37 -0
  22. data/lib/watir/logger.rb +3 -74
  23. data/lib/watir/radio_set.rb +1 -0
  24. data/lib/watir/screenshot.rb +2 -8
  25. data/lib/watir/user_editable.rb +10 -3
  26. data/lib/watir/version.rb +1 -1
  27. data/lib/watir/window.rb +15 -4
  28. data/lib/watir/window_collection.rb +9 -0
  29. data/lib/watirspec.rb +4 -2
  30. data/lib/watirspec/guards.rb +1 -1
  31. data/lib/watirspec/remote_server.rb +2 -6
  32. data/lib/watirspec/server.rb +1 -1
  33. data/spec/spec_helper.rb +0 -10
  34. data/spec/unit/capabilities_spec.rb +198 -48
  35. data/spec/unit/match_elements/element_spec.rb +11 -0
  36. data/spec/watirspec/after_hooks_spec.rb +22 -45
  37. data/spec/watirspec/browser_spec.rb +185 -206
  38. data/spec/watirspec/cookies_spec.rb +47 -52
  39. data/spec/watirspec/drag_and_drop_spec.rb +5 -7
  40. data/spec/watirspec/elements/area_spec.rb +1 -5
  41. data/spec/watirspec/elements/button_spec.rb +4 -8
  42. data/spec/watirspec/elements/checkbox_spec.rb +2 -4
  43. data/spec/watirspec/elements/date_field_spec.rb +13 -16
  44. data/spec/watirspec/elements/date_time_field_spec.rb +14 -13
  45. data/spec/watirspec/elements/dd_spec.rb +3 -4
  46. data/spec/watirspec/elements/del_spec.rb +10 -12
  47. data/spec/watirspec/elements/div_spec.rb +41 -50
  48. data/spec/watirspec/elements/dl_spec.rb +4 -12
  49. data/spec/watirspec/elements/element_spec.rb +155 -89
  50. data/spec/watirspec/elements/elements_spec.rb +8 -9
  51. data/spec/watirspec/elements/filefield_spec.rb +5 -7
  52. data/spec/watirspec/elements/form_spec.rb +1 -1
  53. data/spec/watirspec/elements/forms_spec.rb +3 -5
  54. data/spec/watirspec/elements/frame_spec.rb +17 -22
  55. data/spec/watirspec/elements/iframe_spec.rb +21 -27
  56. data/spec/watirspec/elements/ins_spec.rb +10 -12
  57. data/spec/watirspec/elements/link_spec.rb +24 -26
  58. data/spec/watirspec/elements/links_spec.rb +8 -9
  59. data/spec/watirspec/elements/radio_spec.rb +11 -14
  60. data/spec/watirspec/elements/select_list_spec.rb +248 -117
  61. data/spec/watirspec/elements/span_spec.rb +10 -12
  62. data/spec/watirspec/elements/table_nesting_spec.rb +31 -34
  63. data/spec/watirspec/elements/table_spec.rb +11 -13
  64. data/spec/watirspec/elements/tbody_spec.rb +10 -12
  65. data/spec/watirspec/elements/td_spec.rb +4 -6
  66. data/spec/watirspec/elements/text_field_spec.rb +10 -12
  67. data/spec/watirspec/elements/tr_spec.rb +5 -7
  68. data/spec/watirspec/support/rspec_matchers.rb +1 -1
  69. data/spec/watirspec/user_editable_spec.rb +26 -28
  70. data/spec/watirspec/wait_spec.rb +255 -258
  71. data/spec/watirspec/window_switching_spec.rb +199 -200
  72. data/spec/watirspec_helper.rb +34 -31
  73. data/watir.gemspec +1 -1
  74. metadata +7 -8
  75. data/spec/implementation_spec.rb +0 -24
  76. data/spec/unit/logger_spec.rb +0 -81
@@ -100,18 +100,16 @@ describe 'Span' do
100
100
  end
101
101
 
102
102
  # Other
103
- not_compliant_on :headless do
104
- describe '#click' do
105
- it 'fires events' do
106
- expect(browser.span(class: 'footer').text).to_not include('Javascript')
107
- browser.span(class: 'footer').click
108
- expect(browser.span(class: 'footer').text).to include('Javascript')
109
- end
110
-
111
- it "raises UnknownObjectException if the span doesn't exist" do
112
- expect { browser.span(id: 'no_such_id').click }.to raise_unknown_object_exception
113
- expect { browser.span(title: 'no_such_title').click }.to raise_unknown_object_exception
114
- end
103
+ describe '#click', except: {headless: true} do
104
+ it 'fires events' do
105
+ expect(browser.span(class: 'footer').text).to_not include('Javascript')
106
+ browser.span(class: 'footer').click
107
+ expect(browser.span(class: 'footer').text).to include('Javascript')
108
+ end
109
+
110
+ it "raises UnknownObjectException if the span doesn't exist" do
111
+ expect { browser.span(id: 'no_such_id').click }.to raise_unknown_object_exception
112
+ expect { browser.span(title: 'no_such_title').click }.to raise_unknown_object_exception
115
113
  end
116
114
  end
117
115
  end
@@ -5,48 +5,45 @@ describe 'Table' do
5
5
  browser.goto(WatirSpec.url_for('nested_tables.html'))
6
6
  end
7
7
 
8
- # not a selenium bug - IE seems unable to deal with the invalid nesting
9
- not_compliant_on :internet_explorer do
10
- it 'returns the correct number of rows under a table element' do
11
- tables = browser.div(id: 'table-rows-test').tables(id: /^tbl/)
12
- expect(tables.length).to be > 0
13
-
14
- tables.each do |table|
15
- expected = Integer(table.data_row_count)
16
- actual = table.rows.length
17
- browser_count = Integer(table.data_browser_count)
18
-
19
- msg = "expected #{expected} rows, got #{actual} for table id=#{table.id}, browser reported: #{browser_count}"
20
- expect(actual).to eql(expected), msg
21
- end
8
+ it 'returns the correct number of rows under a table element' do
9
+ tables = browser.div(id: 'table-rows-test').tables(id: /^tbl/)
10
+ expect(tables.length).to be > 0
11
+
12
+ tables.each do |table|
13
+ expected = Integer(table.data_row_count)
14
+ actual = table.rows.length
15
+ browser_count = Integer(table.data_browser_count)
16
+
17
+ msg = "expected #{expected} rows, got #{actual} for table id=#{table.id}, browser reported: #{browser_count}"
18
+ expect(actual).to eql(expected), msg
22
19
  end
20
+ end
23
21
 
24
- it 'returns the correct number of cells under a row' do
25
- rows = browser.div(id: 'row-cells-test').trs(id: /^row/)
26
- expect(rows.length).to be > 0
22
+ it 'returns the correct number of cells under a row' do
23
+ rows = browser.div(id: 'row-cells-test').trs(id: /^row/)
24
+ expect(rows.length).to be > 0
27
25
 
28
- rows.each do |row|
29
- expected = Integer(row.data_cell_count)
30
- actual = row.cells.length
31
- browser_count = Integer(row.data_browser_count)
26
+ rows.each do |row|
27
+ expected = Integer(row.data_cell_count)
28
+ actual = row.cells.length
29
+ browser_count = Integer(row.data_browser_count)
32
30
 
33
- msg = "expected #{expected} cells, got #{actual} for row id=#{row.id}, browser reported: #{browser_count}"
34
- expect(actual).to eql(expected), msg
35
- end
31
+ msg = "expected #{expected} cells, got #{actual} for row id=#{row.id}, browser reported: #{browser_count}"
32
+ expect(actual).to eql(expected), msg
36
33
  end
34
+ end
37
35
 
38
- it 'returns the correct number of rows under a table section' do
39
- tbodies = browser.table(id: 'tbody-rows-test').tbodys(id: /^body/)
40
- expect(tbodies.length).to be > 0
36
+ it 'returns the correct number of rows under a table section' do
37
+ tbodies = browser.table(id: 'tbody-rows-test').tbodys(id: /^body/)
38
+ expect(tbodies.length).to be > 0
41
39
 
42
- tbodies.each do |tbody|
43
- expected = Integer(tbody.data_rows_count)
44
- actual = tbody.rows.count
45
- browser_count = Integer(tbody.data_browser_count)
40
+ tbodies.each do |tbody|
41
+ expected = Integer(tbody.data_rows_count)
42
+ actual = tbody.rows.count
43
+ browser_count = Integer(tbody.data_browser_count)
46
44
 
47
- msg = "expected #{expected} rows, got #{actual} for tbody id=#{tbody.id}, browser reported: #{browser_count}"
48
- expect(actual).to eql(expected), msg
49
- end
45
+ msg = "expected #{expected} rows, got #{actual} for tbody id=#{tbody.id}, browser reported: #{browser_count}"
46
+ expect(actual).to eql(expected), msg
50
47
  end
51
48
  end
52
49
  end
@@ -36,19 +36,17 @@ describe 'Table' do
36
36
  end
37
37
 
38
38
  # Other
39
- bug 'Safari does not strip text', :safari do
40
- describe '#strings' do
41
- it 'returns a two-dimensional array representation of the table' do
42
- expect(browser.table(id: 'inner').strings).to eq [
43
- ['Table 2, Row 1, Cell 1',
44
- 'Table 2, Row 1, Cell 2']
45
- ]
46
- expect(browser.table(id: 'outer').strings).to eq [
47
- ['Table 1, Row 1, Cell 1', 'Table 1, Row 1, Cell 2'],
48
- ['Table 1, Row 2, Cell 1', "Table 1, Row 2, Cell 2\nTable 2, Row 1, Cell 1 Table 2, Row 1, Cell 2"],
49
- ['Table 1, Row 3, Cell 1', 'Table 1, Row 3, Cell 2']
50
- ]
51
- end
39
+ describe '#strings', except: {browser: :safari, reason: 'Safari does not strip text'} do
40
+ it 'returns a two-dimensional array representation of the table' do
41
+ expect(browser.table(id: 'inner').strings).to eq [
42
+ ['Table 2, Row 1, Cell 1',
43
+ 'Table 2, Row 1, Cell 2']
44
+ ]
45
+ expect(browser.table(id: 'outer').strings).to eq [
46
+ ['Table 1, Row 1, Cell 1', 'Table 1, Row 1, Cell 2'],
47
+ ['Table 1, Row 2, Cell 1', "Table 1, Row 2, Cell 2\nTable 2, Row 1, Cell 1 Table 2, Row 1, Cell 2"],
48
+ ['Table 1, Row 3, Cell 1', 'Table 1, Row 3, Cell 2']
49
+ ]
52
50
  end
53
51
  end
54
52
 
@@ -44,19 +44,17 @@ describe 'TableBody' do
44
44
  end
45
45
  end
46
46
 
47
- bug 'Safari does not strip text', :safari do
48
- describe '#[]' do
49
- it 'returns the row at the given index (page context)' do
50
- expect(browser.tbody(id: 'first')[0].text).to eq 'March 2008'
51
- expect(browser.tbody(id: 'first')[1][0].text).to eq 'Gregory House'
52
- expect(browser.tbody(id: 'first')[2][0].text).to eq 'Hugh Laurie'
53
- end
47
+ describe '#[]', except: {browser: :safari, reason: 'Safari does not strip text'} do
48
+ it 'returns the row at the given index (page context)' do
49
+ expect(browser.tbody(id: 'first')[0].text).to eq 'March 2008'
50
+ expect(browser.tbody(id: 'first')[1][0].text).to eq 'Gregory House'
51
+ expect(browser.tbody(id: 'first')[2][0].text).to eq 'Hugh Laurie'
52
+ end
54
53
 
55
- it 'returns the row at the given index (table context)' do
56
- expect(browser.table(index: 0).tbody(id: 'first')[0].text).to eq 'March 2008'
57
- expect(browser.table(index: 0).tbody(id: 'first')[1][0].text).to eq 'Gregory House'
58
- expect(browser.table(index: 0).tbody(id: 'first')[2][0].text).to eq 'Hugh Laurie'
59
- end
54
+ it 'returns the row at the given index (table context)' do
55
+ expect(browser.table(index: 0).tbody(id: 'first')[0].text).to eq 'March 2008'
56
+ expect(browser.table(index: 0).tbody(id: 'first')[1][0].text).to eq 'Gregory House'
57
+ expect(browser.table(index: 0).tbody(id: 'first')[2][0].text).to eq 'Hugh Laurie'
60
58
  end
61
59
  end
62
60
 
@@ -42,12 +42,10 @@ describe 'TableCell' do
42
42
  end
43
43
 
44
44
  # Attribute methods
45
- bug 'Safari does not strip text', :safari do
46
- describe '#text' do
47
- it 'returns the text inside the table cell' do
48
- expect(browser.td(id: 't1_r2_c1').text).to eq 'Table 1, Row 2, Cell 1'
49
- expect(browser.td(id: 't2_r1_c1').text).to eq 'Table 2, Row 1, Cell 1'
50
- end
45
+ describe '#text', except: {browser: :safari, reason: 'Safari does not strip text'} do
46
+ it 'returns the text inside the table cell' do
47
+ expect(browser.td(id: 't1_r2_c1').text).to eq 'Table 1, Row 2, Cell 1'
48
+ expect(browser.td(id: 't2_r1_c1').text).to eq 'Table 2, Row 1, Cell 1'
51
49
  end
52
50
  end
53
51
 
@@ -26,18 +26,16 @@ describe 'TextField' do
26
26
  expect(browser.text_field(label: 'With hidden text')).to exist
27
27
  expect(browser.text_field(label: 'With text')).not_to exist
28
28
 
29
- # These will work after text is deprecated for visible_text
30
- # expect(browser.text_field(label: /With hidden text/)).to exist
31
- # expect(browser.text_field(label: /With text/)).not_to exist
32
- end
33
-
34
- bug 'Safari is not filtering out hidden text', :safari do
35
- it 'returns true in spite of hidden text' do
36
- expect(browser.text_field(visible_label: 'With hidden text')).not_to exist
37
- expect(browser.text_field(visible_label: 'With text')).to exist
38
- expect(browser.text_field(visible_label: /With text/)).to exist
39
- expect(browser.text_field(visible_label: /With hidden text/)).not_to exist
40
- end
29
+ expect(browser.text_field(label: /With hidden text/)).to exist
30
+ expect(browser.text_field(label: /With text/)).not_to exist
31
+ end
32
+
33
+ it 'returns true in spite of hidden text',
34
+ except: {browser: :safari, reason: 'Safari is not filtering out hidden text'} do
35
+ expect(browser.text_field(visible_label: 'With hidden text')).not_to exist
36
+ expect(browser.text_field(visible_label: 'With text')).to exist
37
+ expect(browser.text_field(visible_label: /With text/)).to exist
38
+ expect(browser.text_field(visible_label: /With hidden text/)).not_to exist
41
39
  end
42
40
 
43
41
  it 'locates value of text_field using text locators' do
@@ -29,14 +29,12 @@ describe 'TableRow' do
29
29
  end
30
30
  end
31
31
 
32
- bug 'Safari does not strip text', :safari do
33
- describe '#[]' do
34
- let(:table) { browser.table(id: 'outer') }
32
+ describe '#[]', except: {browser: :safari, reason: 'Safari does not strip text'} do
33
+ let(:table) { browser.table(id: 'outer') }
35
34
 
36
- it 'returns the nth cell of the row' do
37
- expect(table[0][0].text).to eq 'Table 1, Row 1, Cell 1'
38
- expect(table[2][0].text).to eq 'Table 1, Row 3, Cell 1'
39
- end
35
+ it 'returns the nth cell of the row' do
36
+ expect(table[0][0].text).to eq 'Table 1, Row 1, Cell 1'
37
+ expect(table[2][0].text).to eq 'Table 1, Row 3, Cell 1'
40
38
  end
41
39
  end
42
40
 
@@ -1,5 +1,5 @@
1
1
  if defined?(RSpec)
2
- DEPRECATION_WARNINGS = %i[use_capabilities].freeze
2
+ DEPRECATION_WARNINGS = %i[timeouts].freeze
3
3
 
4
4
  DEPRECATION_WARNINGS.each do |deprecation|
5
5
  RSpec::Matchers.define "have_deprecated_#{deprecation}" do
@@ -5,34 +5,32 @@ describe Watir::UserEditable do
5
5
  browser.goto(WatirSpec.url_for('forms_with_input_elements.html'))
6
6
  end
7
7
 
8
- bug 'incorrectly clears first', :safari do
9
- describe '#append' do
10
- it 'appends the text to the text field' do
11
- browser.text_field(name: 'new_user_occupation').append(' Append This')
12
- expect(browser.text_field(name: 'new_user_occupation').value).to eq 'Developer Append This'
13
- end
14
-
15
- it 'appends multi-byte characters' do
16
- browser.text_field(name: 'new_user_occupation').append(' ijij')
17
- expect(browser.text_field(name: 'new_user_occupation').value).to eq 'Developer ijij'
18
- end
19
-
20
- it 'raises NotImplementedError if the object is content editable element' do
21
- msg = '#append method is not supported with contenteditable element'
22
- expect { browser.div(id: 'contenteditable').append('bar') }.to raise_exception(NotImplementedError, msg)
23
- end
24
-
25
- it 'raises ObjectReadOnlyException if the object is read only' do
26
- expect { browser.text_field(id: 'new_user_code').append('Append This') }.to raise_object_read_only_exception
27
- end
28
-
29
- it 'raises ObjectDisabledException if the object is disabled' do
30
- expect { browser.text_field(name: 'new_user_species').append('Append This') }.to raise_object_disabled_exception
31
- end
32
-
33
- it "raises UnknownObjectException if the object doesn't exist" do
34
- expect { browser.text_field(name: 'no_such_name').append('Append This') }.to raise_unknown_object_exception
35
- end
8
+ describe '#append' do
9
+ it 'appends the text to the text field', except: {browser: :safari, reason: 'incorrectly clears first'} do
10
+ browser.text_field(name: 'new_user_occupation').append(' Append This')
11
+ expect(browser.text_field(name: 'new_user_occupation').value).to eq 'Developer Append This'
12
+ end
13
+
14
+ it 'appends multi-byte characters', except: {browser: :safari, reason: 'incorrectly clears first'} do
15
+ browser.text_field(name: 'new_user_occupation').append(' ijij')
16
+ expect(browser.text_field(name: 'new_user_occupation').value).to eq 'Developer ijij'
17
+ end
18
+
19
+ it 'raises NotImplementedError if the object is content editable element' do
20
+ msg = '#append method is not supported with contenteditable element'
21
+ expect { browser.div(id: 'contenteditable').append('bar') }.to raise_exception(NotImplementedError, msg)
22
+ end
23
+
24
+ it 'raises ObjectReadOnlyException if the object is read only' do
25
+ expect { browser.text_field(id: 'new_user_code').append('Append This') }.to raise_object_read_only_exception
26
+ end
27
+
28
+ it 'raises ObjectDisabledException if the object is disabled' do
29
+ expect { browser.text_field(name: 'new_user_species').append('Append This') }.to raise_object_disabled_exception
30
+ end
31
+
32
+ it "raises UnknownObjectException if the object doesn't exist" do
33
+ expect { browser.text_field(name: 'no_such_name').append('Append This') }.to raise_unknown_object_exception
36
34
  end
37
35
  end
38
36
 
@@ -1,352 +1,349 @@
1
1
  require 'watirspec_helper'
2
2
 
3
- compliant_on :relaxed_locate do
4
- describe Watir do
5
- before do
6
- browser.goto WatirSpec.url_for('wait.html')
7
- end
3
+ describe Watir do
4
+ before do
5
+ browser.goto WatirSpec.url_for('wait.html')
6
+ end
8
7
 
9
- describe '#default_timeout' do
10
- context 'when no timeout is specified' do
11
- it 'is used by Wait#until' do
12
- expect { Watir::Wait.until { false } }.to wait_and_raise_timeout_exception(timeout: 1)
13
- end
8
+ describe '#default_timeout' do
9
+ context 'when no timeout is specified' do
10
+ it 'is used by Wait#until' do
11
+ expect { Watir::Wait.until { false } }.to wait_and_raise_timeout_exception(timeout: 1)
12
+ end
14
13
 
15
- it 'is used by Wait#while' do
16
- expect { Watir::Wait.while { true } }.to wait_and_raise_timeout_exception(timeout: 1)
17
- end
14
+ it 'is used by Wait#while' do
15
+ expect { Watir::Wait.while { true } }.to wait_and_raise_timeout_exception(timeout: 1)
16
+ end
18
17
 
19
- it 'ensures all checks happen once even if time has expired' do
20
- Watir.default_timeout = -1
21
- expect { browser.link.click }.to_not raise_exception
22
- ensure
23
- Watir.default_timeout = 30
24
- end
18
+ it 'ensures all checks happen once even if time has expired' do
19
+ Watir.default_timeout = -1
20
+ expect { browser.link.click }.to_not raise_exception
21
+ ensure
22
+ Watir.default_timeout = 5
25
23
  end
26
24
  end
27
25
  end
26
+ end
27
+
28
+ describe Watir::Element do
29
+ before do
30
+ browser.goto WatirSpec.url_for('wait.html')
31
+ end
28
32
 
29
- describe Watir::Element do
30
- before do
31
- browser.goto WatirSpec.url_for('wait.html')
33
+ describe '#wait_until' do
34
+ it 'returns element for additional actions' do
35
+ element = browser.div(id: 'foo')
36
+ expect(element.wait_until(&:exist?)).to eq element
32
37
  end
33
38
 
34
- describe '#wait_until' do
35
- it 'returns element for additional actions' do
36
- element = browser.div(id: 'foo')
37
- expect(element.wait_until(&:exist?)).to eq element
38
- end
39
+ it 'accepts self in block' do
40
+ element = browser.div(id: 'bar')
41
+ browser.a(id: 'show_bar').click
42
+ expect { element.wait_until { |el| el.text == 'bar' } }.to_not raise_exception
43
+ end
44
+
45
+ it 'accepts any values in block' do
46
+ element = browser.div(id: 'bar')
47
+ expect { element.wait_until { true } }.to_not raise_exception
48
+ end
49
+
50
+ it 'accepts just a timeout parameter' do
51
+ element = browser.div(id: 'bar')
52
+ expect { element.wait_until(timeout: 0) { true } }.to_not raise_exception
53
+ end
54
+
55
+ it 'accepts just a message parameter' do
56
+ element = browser.div(id: 'bar')
57
+ expect { element.wait_until(message: 'no') { true } }.to_not raise_exception
58
+ end
59
+
60
+ it 'accepts just an interval parameter' do
61
+ element = browser.div(id: 'bar')
62
+ expect { element.wait_until(interval: 0.1) { true } }.to_not raise_exception
63
+ end
64
+
65
+ context 'accepts keywords instead of block' do
66
+ before { browser.refresh }
39
67
 
40
- it 'accepts self in block' do
68
+ it 'accepts text keyword' do
41
69
  element = browser.div(id: 'bar')
42
70
  browser.a(id: 'show_bar').click
43
- expect { element.wait_until { |el| el.text == 'bar' } }.to_not raise_exception
71
+ expect { element.wait_until(text: 'bar') }.to_not raise_exception
44
72
  end
45
73
 
46
- it 'accepts any values in block' do
74
+ it 'accepts regular expression value' do
47
75
  element = browser.div(id: 'bar')
48
- expect { element.wait_until { true } }.to_not raise_exception
76
+ browser.a(id: 'show_bar').click
77
+ expect { element.wait_until(style: /block/) }.to_not raise_exception
49
78
  end
50
79
 
51
- it 'accepts just a timeout parameter' do
80
+ it 'accepts multiple keywords' do
52
81
  element = browser.div(id: 'bar')
53
- expect { element.wait_until(timeout: 0) { true } }.to_not raise_exception
82
+ browser.a(id: 'show_bar').click
83
+ expect { element.wait_until(text: 'bar', style: /block/) }.to_not raise_exception
54
84
  end
55
85
 
56
- it 'accepts just a message parameter' do
86
+ it 'accepts custom keyword' do
57
87
  element = browser.div(id: 'bar')
58
- expect { element.wait_until(message: 'no') { true } }.to_not raise_exception
88
+ browser.a(id: 'show_bar').click
89
+ expect { element.wait_until(custom: 'bar') }.to_not raise_exception
59
90
  end
60
91
 
61
- it 'accepts just an interval parameter' do
92
+ it 'times out when single keyword not met' do
62
93
  element = browser.div(id: 'bar')
63
- expect { element.wait_until(interval: 0.1) { true } }.to_not raise_exception
94
+ expect { element.wait_until(id: 'foo') }.to raise_timeout_exception
64
95
  end
65
96
 
66
- context 'accepts keywords instead of block' do
67
- before { browser.refresh }
68
-
69
- it 'accepts text keyword' do
70
- element = browser.div(id: 'bar')
71
- browser.a(id: 'show_bar').click
72
- expect { element.wait_until(text: 'bar') }.to_not raise_exception
73
- end
97
+ it 'times out when one of multiple keywords not met' do
98
+ element = browser.div(id: 'bar')
99
+ expect { element.wait_until(id: 'bar', text: 'foo') }.to raise_timeout_exception
100
+ end
74
101
 
75
- it 'accepts regular expression value' do
76
- element = browser.div(id: 'bar')
77
- browser.a(id: 'show_bar').click
78
- expect { element.wait_until(style: /block/) }.to_not raise_exception
79
- end
102
+ it 'times out when a custom keywords not met' do
103
+ element = browser.div(id: 'bar')
104
+ expect { element.wait_until(custom: 'foo') }.to raise_timeout_exception
105
+ end
106
+ end
107
+ end
80
108
 
81
- it 'accepts multiple keywords' do
82
- element = browser.div(id: 'bar')
83
- browser.a(id: 'show_bar').click
84
- expect { element.wait_until(text: 'bar', style: /block/) }.to_not raise_exception
85
- end
109
+ describe '#wait_while' do
110
+ it 'returns element for additional actions' do
111
+ element = browser.div(id: 'foo')
112
+ browser.a(id: 'hide_foo').click
113
+ expect(element.wait_while(&:present?)).to eq element
114
+ end
86
115
 
87
- it 'accepts custom keyword' do
88
- element = browser.div(id: 'bar')
89
- browser.a(id: 'show_bar').click
90
- expect { element.wait_until(custom: 'bar') }.to_not raise_exception
91
- end
116
+ it 'accepts any values in block' do
117
+ element = browser.div(id: 'foo')
118
+ expect { element.wait_while { false } }.to_not raise_exception
119
+ end
92
120
 
93
- it 'times out when single keyword not met' do
94
- element = browser.div(id: 'bar')
95
- expect { element.wait_until(id: 'foo') }.to raise_timeout_exception
96
- end
121
+ it 'accepts just a timeout parameter' do
122
+ element = browser.div(id: 'foo')
123
+ expect { element.wait_while(timeout: 0) { false } }.to_not raise_exception
124
+ end
97
125
 
98
- it 'times out when one of multiple keywords not met' do
99
- element = browser.div(id: 'bar')
100
- expect { element.wait_until(id: 'bar', text: 'foo') }.to raise_timeout_exception
101
- end
126
+ it 'accepts just a message parameter' do
127
+ element = browser.div(id: 'foo')
128
+ expect { element.wait_while(message: 'no') { false } }.to_not raise_exception
129
+ end
102
130
 
103
- it 'times out when a custom keywords not met' do
104
- element = browser.div(id: 'bar')
105
- expect { element.wait_until(custom: 'foo') }.to raise_timeout_exception
106
- end
107
- end
131
+ it 'accepts just an interval parameter' do
132
+ element = browser.div(id: 'foo')
133
+ expect { element.wait_while(interval: 0.1) { false } }.to_not raise_exception
108
134
  end
109
135
 
110
- describe '#wait_while' do
111
- it 'returns element for additional actions' do
136
+ context 'accepts keywords instead of block' do
137
+ it 'accepts text keyword', except: {browser: :safari,
138
+ reason: 'Safari does not recognize date type'} do
112
139
  element = browser.div(id: 'foo')
113
140
  browser.a(id: 'hide_foo').click
114
- expect(element.wait_while(&:present?)).to eq element
141
+ expect { element.wait_while(text: 'foo') }.to_not raise_exception
115
142
  end
116
143
 
117
- it 'accepts any values in block' do
144
+ it 'accepts regular expression value' do
118
145
  element = browser.div(id: 'foo')
119
- expect { element.wait_while { false } }.to_not raise_exception
146
+ browser.a(id: 'hide_foo').click
147
+ expect { element.wait_while(style: /block/) }.to_not raise_exception
120
148
  end
121
149
 
122
- it 'accepts just a timeout parameter' do
150
+ it 'accepts multiple keywords' do
123
151
  element = browser.div(id: 'foo')
124
- expect { element.wait_while(timeout: 0) { false } }.to_not raise_exception
152
+ browser.a(id: 'hide_foo').click
153
+ expect { element.wait_while(text: 'foo', style: /block/) }.to_not raise_exception
125
154
  end
126
155
 
127
- it 'accepts just a message parameter' do
156
+ it 'accepts custom attributes' do
128
157
  element = browser.div(id: 'foo')
129
- expect { element.wait_while(message: 'no') { false } }.to_not raise_exception
158
+ browser.a(id: 'hide_foo').click
159
+ expect { element.wait_while(custom: '') }.to_not raise_exception
130
160
  end
131
161
 
132
- it 'accepts just an interval parameter' do
162
+ it 'accepts keywords and block' do
133
163
  element = browser.div(id: 'foo')
134
- expect { element.wait_while(interval: 0.1) { false } }.to_not raise_exception
164
+ browser.a(id: 'hide_foo').click
165
+ expect { element.wait_while(custom: '', &:present?) }.to_not raise_exception
135
166
  end
136
167
 
137
- context 'accepts keywords instead of block' do
138
- bug 'Safari does not recognize date type', :safari do
139
- it 'accepts text keyword' do
140
- element = browser.div(id: 'foo')
141
- browser.a(id: 'hide_foo').click
142
- expect { element.wait_while(text: 'foo') }.to_not raise_exception
143
- end
144
- end
145
-
146
- it 'accepts regular expression value' do
147
- element = browser.div(id: 'foo')
148
- browser.a(id: 'hide_foo').click
149
- expect { element.wait_while(style: /block/) }.to_not raise_exception
150
- end
151
-
152
- it 'accepts multiple keywords' do
153
- element = browser.div(id: 'foo')
154
- browser.a(id: 'hide_foo').click
155
- expect { element.wait_while(text: 'foo', style: /block/) }.to_not raise_exception
156
- end
157
-
158
- it 'accepts custom attributes' do
159
- element = browser.div(id: 'foo')
160
- browser.a(id: 'hide_foo').click
161
- expect { element.wait_while(custom: '') }.to_not raise_exception
162
- end
163
-
164
- it 'accepts keywords and block' do
165
- element = browser.div(id: 'foo')
166
- browser.a(id: 'hide_foo').click
167
- expect { element.wait_while(custom: '', &:present?) }.to_not raise_exception
168
- end
169
-
170
- it 'browser accepts keywords' do
171
- expect { browser.wait_until(title: 'wait test') }.to_not raise_exception
172
- expect { browser.wait_until(title: 'wrong') }.to raise_timeout_exception
173
- end
174
-
175
- it 'alert accepts keywords' do
176
- browser.goto WatirSpec.url_for('alerts.html')
168
+ it 'browser accepts keywords' do
169
+ expect { browser.wait_until(title: 'wait test') }.to_not raise_exception
170
+ expect { browser.wait_until(title: 'wrong') }.to raise_timeout_exception
171
+ end
177
172
 
178
- begin
179
- browser.button(id: 'alert').click
180
- expect { browser.alert.wait_until(text: 'ok') }.to_not raise_exception
181
- expect { browser.alert.wait_until(text: 'not ok') }.to raise_timeout_exception
182
- ensure
183
- browser.alert.ok
184
- end
185
- end
173
+ it 'alert accepts keywords' do
174
+ browser.goto WatirSpec.url_for('alerts.html')
186
175
 
187
- it 'window accepts keywords' do
188
- expect { browser.window.wait_until(title: 'wait test') }.to_not raise_exception
189
- expect { browser.window.wait_until(title: 'wrong') }.to raise_timeout_exception
176
+ begin
177
+ browser.button(id: 'alert').click
178
+ expect { browser.alert.wait_until(text: 'ok') }.to_not raise_exception
179
+ expect { browser.alert.wait_until(text: 'not ok') }.to raise_timeout_exception
180
+ ensure
181
+ browser.alert.ok
190
182
  end
183
+ end
191
184
 
192
- it 'times out when single keyword not met' do
193
- element = browser.div(id: 'foo')
194
- expect { element.wait_while(id: 'foo') }.to raise_timeout_exception
195
- end
185
+ it 'window accepts keywords' do
186
+ expect { browser.window.wait_until(title: 'wait test') }.to_not raise_exception
187
+ expect { browser.window.wait_until(title: 'wrong') }.to raise_timeout_exception
188
+ end
196
189
 
197
- it 'times out when one of multiple keywords not met' do
198
- element = browser.div(id: 'foo')
199
- browser.a(id: 'hide_foo').click
200
- expect { element.wait_while(id: 'foo', style: /block/) }.to raise_timeout_exception
201
- end
190
+ it 'times out when single keyword not met' do
191
+ element = browser.div(id: 'foo')
192
+ expect { element.wait_while(id: 'foo') }.to raise_timeout_exception
193
+ end
202
194
 
203
- it 'times out when one of custom keywords not met' do
204
- element = browser.div(id: 'foo')
205
- expect { element.wait_while(custom: '') }.to raise_timeout_exception
206
- end
195
+ it 'times out when one of multiple keywords not met' do
196
+ element = browser.div(id: 'foo')
197
+ browser.a(id: 'hide_foo').click
198
+ expect { element.wait_while(id: 'foo', style: /block/) }.to raise_timeout_exception
207
199
  end
208
- end
209
200
 
210
- context 'when acting on an element that is never present' do
211
- it 'raises exception after timing out' do
212
- element = browser.link(id: 'not_there')
213
- expect { element.click }.to wait_and_raise_unknown_object_exception
201
+ it 'times out when one of custom keywords not met' do
202
+ element = browser.div(id: 'foo')
203
+ expect { element.wait_while(custom: '') }.to raise_timeout_exception
214
204
  end
215
205
  end
206
+ end
216
207
 
217
- context 'when acting on an element that is already present' do
218
- it 'does not wait' do
219
- expect { browser.link.click }.to execute_when_satisfied(max: 1)
220
- end
208
+ context 'when acting on an element that is never present' do
209
+ it 'raises exception after timing out' do
210
+ element = browser.link(id: 'not_there')
211
+ expect { element.click }.to wait_and_raise_unknown_object_exception
221
212
  end
213
+ end
222
214
 
223
- context 'when acting on an element that eventually becomes present' do
224
- it 'waits until element is present and then takes action' do
225
- expect {
226
- browser.a(id: 'show_bar').click
227
- browser.div(id: 'bar').click
228
- }.to execute_when_satisfied(min: 1)
229
- expect(browser.div(id: 'bar').text).to eq 'changed'
230
- end
215
+ context 'when acting on an element that is already present' do
216
+ it 'does not wait' do
217
+ expect { browser.link.click }.to execute_when_satisfied(max: 1)
218
+ end
219
+ end
231
220
 
232
- it 'waits until text field present and then takes action' do
233
- expect {
234
- browser.a(id: 'show_textfield').click
235
- browser.text_field(id: 'textfield').set 'Foo'
236
- }.to execute_when_satisfied(min: 1)
237
- end
221
+ context 'when acting on an element that eventually becomes present' do
222
+ it 'waits until element is present and then takes action' do
223
+ expect {
224
+ browser.a(id: 'show_bar').click
225
+ browser.div(id: 'bar').click
226
+ }.to execute_when_satisfied(min: 1)
227
+ expect(browser.div(id: 'bar').text).to eq 'changed'
238
228
  end
239
229
 
240
- context 'when acting on a read only text field' do
241
- it 'waits and raises read only exception if never becomes writable' do
242
- expect { browser.text_field(id: 'writable').set 'foo' }.to wait_and_raise_object_read_only_exception
243
- end
230
+ it 'waits until text field present and then takes action' do
231
+ expect {
232
+ browser.a(id: 'show_textfield').click
233
+ browser.text_field(id: 'textfield').set 'Foo'
234
+ }.to execute_when_satisfied(min: 1)
235
+ end
236
+ end
244
237
 
245
- it 'waits until writable' do
246
- expect {
247
- browser.a(id: 'make-writable').click
248
- browser.text_field(id: 'writable').set 'foo'
249
- }.to execute_when_satisfied(min: 1)
250
- end
238
+ context 'when acting on a read only text field' do
239
+ it 'waits and raises read only exception if never becomes writable' do
240
+ expect { browser.text_field(id: 'writable').set 'foo' }.to wait_and_raise_object_read_only_exception
251
241
  end
252
242
 
253
- context 'when acting on a disabled button' do
254
- it 'waits and raises exception if it never becomes enabled' do
255
- expect { browser.button(id: 'btn').click }.to wait_and_raise_object_disabled_exception
256
- end
243
+ it 'waits until writable' do
244
+ expect {
245
+ browser.a(id: 'make-writable').click
246
+ browser.text_field(id: 'writable').set 'foo'
247
+ }.to execute_when_satisfied(min: 1)
248
+ end
249
+ end
257
250
 
258
- it 'waits until enabled' do
259
- expect {
260
- browser.a(id: 'enable_btn').click
261
- browser.button(id: 'btn').click
262
- }.to execute_when_satisfied(min: 1)
263
- end
251
+ context 'when acting on a disabled button' do
252
+ it 'waits and raises exception if it never becomes enabled' do
253
+ expect { browser.button(id: 'btn').click }.to wait_and_raise_object_disabled_exception
264
254
  end
265
255
 
266
- context 'when acting on an element with a parent' do
267
- it 'raises exception after timing out if parent never present' do
268
- element = browser.link(id: 'not_there')
269
- expect { element.element.click }.to wait_and_raise_unknown_object_exception
270
- end
256
+ it 'waits until enabled' do
257
+ expect {
258
+ browser.a(id: 'enable_btn').click
259
+ browser.button(id: 'btn').click
260
+ }.to execute_when_satisfied(min: 1)
261
+ end
262
+ end
271
263
 
272
- it 'raises exception after timing out when element from a collection whose parent is never present' do
273
- element = browser.link(id: 'not_there')
274
- expect { element.elements[2].click }.to wait_and_raise_unknown_object_exception
275
- end
264
+ context 'when acting on an element with a parent' do
265
+ it 'raises exception after timing out if parent never present' do
266
+ element = browser.link(id: 'not_there')
267
+ expect { element.element.click }.to wait_and_raise_unknown_object_exception
268
+ end
276
269
 
277
- it 'does not wait for parent element to be present when querying child element' do
278
- el = browser.element(id: 'not_there').element(id: 'doesnt_matter')
279
- expect { el.present? }.to execute_when_satisfied(max: 1)
280
- end
270
+ it 'raises exception after timing out when element from a collection whose parent is never present' do
271
+ element = browser.link(id: 'not_there')
272
+ expect { element.elements[2].click }.to wait_and_raise_unknown_object_exception
281
273
  end
282
- end
283
274
 
284
- describe Watir::ElementCollection do
285
- before do
286
- browser.goto WatirSpec.url_for('wait.html')
275
+ it 'does not wait for parent element to be present when querying child element' do
276
+ el = browser.element(id: 'not_there').element(id: 'doesnt_matter')
277
+ expect { el.present? }.to execute_when_satisfied(max: 1)
287
278
  end
279
+ end
280
+ end
288
281
 
289
- describe '#wait_until' do
290
- it 'returns collection' do
291
- elements = browser.divs
292
- expect(elements.wait_until(&:exist?)).to eq elements
293
- end
282
+ describe Watir::ElementCollection do
283
+ before do
284
+ browser.goto WatirSpec.url_for('wait.html')
285
+ end
294
286
 
295
- it 'times out when waiting for non-empty collection' do
296
- expect { browser.divs.wait_until(&:empty?) }.to raise_timeout_exception
297
- end
287
+ describe '#wait_until' do
288
+ it 'returns collection' do
289
+ elements = browser.divs
290
+ expect(elements.wait_until(&:exist?)).to eq elements
291
+ end
298
292
 
299
- it 'provides matching collection when exists' do
300
- expect {
301
- browser.a(id: 'add_foobar').click
302
- browser.divs(id: 'foobar').wait_until(&:exists?)
303
- }.to execute_when_satisfied(min: 1)
304
- end
293
+ it 'times out when waiting for non-empty collection' do
294
+ expect { browser.divs.wait_until(&:empty?) }.to raise_timeout_exception
295
+ end
305
296
 
306
- it 'accepts self in block' do
307
- expect {
308
- browser.a(id: 'add_foobar').click
309
- browser.divs.wait_until { |els| els.size == 7 }
310
- }.to execute_when_satisfied(min: 1)
311
- end
297
+ it 'provides matching collection when exists' do
298
+ expect {
299
+ browser.a(id: 'add_foobar').click
300
+ browser.divs(id: 'foobar').wait_until(&:exists?)
301
+ }.to execute_when_satisfied(min: 1)
302
+ end
312
303
 
313
- it 'accepts attributes to evaluate' do
314
- expect {
315
- browser.a(id: 'add_foobar').click
316
- browser.divs.wait_until(size: 7)
317
- }.to execute_when_satisfied(min: 1)
318
- end
304
+ it 'accepts self in block' do
305
+ expect {
306
+ browser.a(id: 'add_foobar').click
307
+ browser.divs.wait_until { |els| els.size == 7 }
308
+ }.to execute_when_satisfied(min: 1)
319
309
  end
320
310
 
321
- describe '#wait_while' do
322
- it 'returns collection' do
323
- elements = browser.divs
324
- expect(elements.wait_while(&:empty?)).to eq elements
325
- end
311
+ it 'accepts attributes to evaluate' do
312
+ expect {
313
+ browser.a(id: 'add_foobar').click
314
+ browser.divs.wait_until(size: 7)
315
+ }.to execute_when_satisfied(min: 1)
316
+ end
317
+ end
326
318
 
327
- it 'times out when waiting for non-empty collection' do
328
- elements = browser.divs
329
- expect { elements.wait_while(&:exists?) }.to raise_timeout_exception
330
- end
319
+ describe '#wait_while' do
320
+ it 'returns collection' do
321
+ elements = browser.divs
322
+ expect(elements.wait_while(&:empty?)).to eq elements
323
+ end
331
324
 
332
- it 'provides matching collection when exists' do
333
- expect {
334
- browser.a(id: 'remove_foo').click
335
- browser.divs(id: 'foo').wait_while(&:exists?)
336
- }.to execute_when_satisfied(min: 1)
337
- end
325
+ it 'times out when waiting for non-empty collection' do
326
+ elements = browser.divs
327
+ expect { elements.wait_while(&:exists?) }.to raise_timeout_exception
328
+ end
338
329
 
339
- it 'accepts self in block' do
340
- expect {
341
- browser.a(id: 'add_foobar').click
342
- browser.divs.wait_while { |els| els.size == 6 }
343
- }.to execute_when_satisfied(min: 1)
344
- end
330
+ it 'provides matching collection when exists' do
331
+ expect {
332
+ browser.a(id: 'remove_foo').click
333
+ browser.divs(id: 'foo').wait_while(&:exists?)
334
+ }.to execute_when_satisfied(min: 1)
345
335
  end
346
336
 
347
- it 'waits for parent element to be present before locating' do
348
- els = browser.element(id: /not|there/).elements(id: 'doesnt_matter')
349
- expect { els.to_a }.to wait_and_raise_unknown_object_exception
337
+ it 'accepts self in block' do
338
+ expect {
339
+ browser.a(id: 'add_foobar').click
340
+ browser.divs.wait_while { |els| els.size == 6 }
341
+ }.to execute_when_satisfied(min: 1)
350
342
  end
351
343
  end
344
+
345
+ it 'waits for parent element to be present before locating' do
346
+ els = browser.element(id: /not|there/).elements(id: 'doesnt_matter')
347
+ expect { els.to_a }.to wait_and_raise_unknown_object_exception
348
+ end
352
349
  end