watir 6.0.0.beta5 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -2
- data/CHANGES.md +10 -1
- data/Gemfile +4 -0
- data/README.md +37 -23
- data/Rakefile +6 -10
- data/appveyor.yml +13 -0
- data/lib/watir.rb +20 -21
- data/lib/watir/alert.rb +21 -5
- data/lib/watir/browser.rb +9 -3
- data/lib/watir/elements/checkbox.rb +0 -1
- data/lib/watir/elements/element.rb +92 -50
- data/lib/watir/elements/form.rb +1 -2
- data/lib/watir/elements/iframe.rb +6 -2
- data/lib/watir/elements/image.rb +1 -1
- data/lib/watir/elements/option.rb +0 -1
- data/lib/watir/elements/radio.rb +0 -1
- data/lib/watir/elements/select.rb +1 -10
- data/lib/watir/extensions/select_text.rb +1 -1
- data/lib/watir/legacy_wait.rb +126 -0
- data/lib/watir/locators/text_field/locator.rb +0 -3
- data/lib/watir/locators/text_field/selector_builder.rb +1 -4
- data/lib/watir/locators/text_field/selector_builder/xpath.rb +0 -2
- data/lib/watir/locators/text_field/validator.rb +1 -9
- data/lib/watir/row_container.rb +1 -1
- data/lib/watir/user_editable.rb +7 -5
- data/lib/watir/wait.rb +56 -135
- data/lib/watir/wait/timer.rb +29 -2
- data/lib/watir/window.rb +11 -1
- data/lib/watirspec.rb +81 -0
- data/lib/watirspec/guards.rb +58 -0
- data/lib/watirspec/implementation.rb +33 -0
- data/lib/watirspec/rake_tasks.rb +115 -0
- data/lib/watirspec/runner.rb +53 -0
- data/lib/watirspec/server.rb +99 -0
- data/lib/watirspec/server/app.rb +62 -0
- data/spec/browser_spec.rb +5 -5
- data/spec/click_spec.rb +1 -1
- data/spec/container_spec.rb +1 -1
- data/spec/element_locator_spec.rb +1 -1
- data/spec/element_spec.rb +20 -34
- data/spec/implementation_spec.rb +24 -0
- data/spec/input_spec.rb +1 -1
- data/spec/spec_helper.rb +35 -3
- data/spec/special_chars_spec.rb +1 -1
- data/spec/watirspec/.gitignore +2 -0
- data/spec/watirspec/after_hooks_spec.rb +179 -0
- data/spec/watirspec/alert_spec.rb +101 -0
- data/spec/watirspec/browser_spec.rb +291 -0
- data/spec/watirspec/cookies_spec.rb +147 -0
- data/spec/watirspec/drag_and_drop_spec.rb +49 -0
- data/spec/watirspec/element_hidden_spec.rb +65 -0
- data/spec/watirspec/elements/area_spec.rb +76 -0
- data/spec/watirspec/elements/areas_spec.rb +42 -0
- data/spec/watirspec/elements/button_spec.rb +270 -0
- data/spec/watirspec/elements/buttons_spec.rb +55 -0
- data/spec/watirspec/elements/checkbox_spec.rb +279 -0
- data/spec/watirspec/elements/checkboxes_spec.rb +44 -0
- data/spec/watirspec/elements/collections_spec.rb +16 -0
- data/spec/watirspec/elements/dd_spec.rb +126 -0
- data/spec/watirspec/elements/dds_spec.rb +42 -0
- data/spec/watirspec/elements/del_spec.rb +128 -0
- data/spec/watirspec/elements/dels_spec.rb +40 -0
- data/spec/watirspec/elements/div_spec.rb +199 -0
- data/spec/watirspec/elements/divs_spec.rb +42 -0
- data/spec/watirspec/elements/dl_spec.rb +144 -0
- data/spec/watirspec/elements/dls_spec.rb +43 -0
- data/spec/watirspec/elements/dt_spec.rb +126 -0
- data/spec/watirspec/elements/dts_spec.rb +42 -0
- data/spec/watirspec/elements/element_spec.rb +361 -0
- data/spec/watirspec/elements/elements_spec.rb +15 -0
- data/spec/watirspec/elements/em_spec.rb +100 -0
- data/spec/watirspec/elements/ems_spec.rb +43 -0
- data/spec/watirspec/elements/filefield_spec.rb +181 -0
- data/spec/watirspec/elements/filefields_spec.rb +43 -0
- data/spec/watirspec/elements/font_spec.rb +29 -0
- data/spec/watirspec/elements/form_spec.rb +70 -0
- data/spec/watirspec/elements/forms_spec.rb +44 -0
- data/spec/watirspec/elements/frame_spec.rb +121 -0
- data/spec/watirspec/elements/frames_spec.rb +41 -0
- data/spec/watirspec/elements/hidden_spec.rb +102 -0
- data/spec/watirspec/elements/hiddens_spec.rb +43 -0
- data/spec/watirspec/elements/hn_spec.rb +96 -0
- data/spec/watirspec/elements/hns_spec.rb +38 -0
- data/spec/watirspec/elements/iframe_spec.rb +174 -0
- data/spec/watirspec/elements/iframes_spec.rb +47 -0
- data/spec/watirspec/elements/image_spec.rb +164 -0
- data/spec/watirspec/elements/images_spec.rb +40 -0
- data/spec/watirspec/elements/ins_spec.rb +129 -0
- data/spec/watirspec/elements/inses_spec.rb +40 -0
- data/spec/watirspec/elements/label_spec.rb +79 -0
- data/spec/watirspec/elements/labels_spec.rb +40 -0
- data/spec/watirspec/elements/li_spec.rb +115 -0
- data/spec/watirspec/elements/link_spec.rb +174 -0
- data/spec/watirspec/elements/links_spec.rb +44 -0
- data/spec/watirspec/elements/lis_spec.rb +42 -0
- data/spec/watirspec/elements/map_spec.rb +79 -0
- data/spec/watirspec/elements/maps_spec.rb +41 -0
- data/spec/watirspec/elements/meta_spec.rb +23 -0
- data/spec/watirspec/elements/metas_spec.rb +40 -0
- data/spec/watirspec/elements/ol_spec.rb +89 -0
- data/spec/watirspec/elements/ols_spec.rb +40 -0
- data/spec/watirspec/elements/option_spec.rb +152 -0
- data/spec/watirspec/elements/p_spec.rb +115 -0
- data/spec/watirspec/elements/pre_spec.rb +115 -0
- data/spec/watirspec/elements/pres_spec.rb +40 -0
- data/spec/watirspec/elements/ps_spec.rb +40 -0
- data/spec/watirspec/elements/radio_spec.rb +263 -0
- data/spec/watirspec/elements/radios_spec.rb +43 -0
- data/spec/watirspec/elements/select_list_spec.rb +379 -0
- data/spec/watirspec/elements/select_lists_spec.rb +46 -0
- data/spec/watirspec/elements/span_spec.rb +129 -0
- data/spec/watirspec/elements/spans_spec.rb +40 -0
- data/spec/watirspec/elements/strong_spec.rb +92 -0
- data/spec/watirspec/elements/strongs_spec.rb +43 -0
- data/spec/watirspec/elements/table_nesting_spec.rb +51 -0
- data/spec/watirspec/elements/table_spec.rb +146 -0
- data/spec/watirspec/elements/tables_spec.rb +42 -0
- data/spec/watirspec/elements/tbody_spec.rb +96 -0
- data/spec/watirspec/elements/tbodys_spec.rb +62 -0
- data/spec/watirspec/elements/td_spec.rb +71 -0
- data/spec/watirspec/elements/tds_spec.rb +53 -0
- data/spec/watirspec/elements/text_field_spec.rb +302 -0
- data/spec/watirspec/elements/text_fields_spec.rb +44 -0
- data/spec/watirspec/elements/textarea_spec.rb +26 -0
- data/spec/watirspec/elements/textareas_spec.rb +24 -0
- data/spec/watirspec/elements/tfoot_spec.rb +91 -0
- data/spec/watirspec/elements/tfoots_spec.rb +68 -0
- data/spec/watirspec/elements/thead_spec.rb +91 -0
- data/spec/watirspec/elements/theads_spec.rb +68 -0
- data/spec/watirspec/elements/tr_spec.rb +80 -0
- data/spec/watirspec/elements/trs_spec.rb +61 -0
- data/spec/watirspec/elements/ul_spec.rb +79 -0
- data/spec/watirspec/elements/uls_spec.rb +39 -0
- data/spec/watirspec/html/alerts.html +12 -0
- data/spec/watirspec/html/aria_attributes.html +9 -0
- data/spec/watirspec/html/class_locator.html +8 -0
- data/spec/watirspec/html/clicks.html +19 -0
- data/spec/watirspec/html/closeable.html +13 -0
- data/spec/watirspec/html/collections.html +15 -0
- data/spec/watirspec/html/css/jquery-ui-1.8.17.custom.css +287 -0
- data/spec/watirspec/html/data_attributes.html +9 -0
- data/spec/watirspec/html/definition_lists.html +48 -0
- data/spec/watirspec/html/drag_and_drop.html +106 -0
- data/spec/watirspec/html/font.html +10 -0
- data/spec/watirspec/html/forms_with_input_elements.html +170 -0
- data/spec/watirspec/html/frame_1.html +22 -0
- data/spec/watirspec/html/frame_2.html +16 -0
- data/spec/watirspec/html/frames.html +11 -0
- data/spec/watirspec/html/hover.html +12 -0
- data/spec/watirspec/html/iframe_1.html +22 -0
- data/spec/watirspec/html/iframes.html +12 -0
- data/spec/watirspec/html/images.html +28 -0
- data/spec/watirspec/html/images/1.gif +0 -0
- data/spec/watirspec/html/images/2.gif +0 -0
- data/spec/watirspec/html/images/3.gif +0 -0
- data/spec/watirspec/html/images/button.png +0 -0
- data/spec/watirspec/html/images/circle.png +0 -0
- data/spec/watirspec/html/images/map.gif +0 -0
- data/spec/watirspec/html/images/map2.gif +0 -0
- data/spec/watirspec/html/images/minus.gif +0 -0
- data/spec/watirspec/html/images/originaltriangle.png +0 -0
- data/spec/watirspec/html/images/plus.gif +0 -0
- data/spec/watirspec/html/images/square.png +0 -0
- data/spec/watirspec/html/images/triangle.png +0 -0
- data/spec/watirspec/html/inner_outer.html +5 -0
- data/spec/watirspec/html/javascript/helpers.js +16 -0
- data/spec/watirspec/html/javascript/jquery-1.7.1.min.js +4 -0
- data/spec/watirspec/html/javascript/jquery-ui-1.8.17.custom.min.js +68 -0
- data/spec/watirspec/html/keylogger.html +15 -0
- data/spec/watirspec/html/modal_dialog.html +9 -0
- data/spec/watirspec/html/multiple_ids.html +14 -0
- data/spec/watirspec/html/nested_frame_1.html +1 -0
- data/spec/watirspec/html/nested_frame_2.html +9 -0
- data/spec/watirspec/html/nested_frame_3.html +14 -0
- data/spec/watirspec/html/nested_frames.html +10 -0
- data/spec/watirspec/html/nested_iframe_2.html +12 -0
- data/spec/watirspec/html/nested_iframes.html +9 -0
- data/spec/watirspec/html/nested_tables.html +203 -0
- data/spec/watirspec/html/non_control_elements.html +135 -0
- data/spec/watirspec/html/removed_element.html +24 -0
- data/spec/watirspec/html/right_click.html +11 -0
- data/spec/watirspec/html/special_chars.html +12 -0
- data/spec/watirspec/html/tables.html +121 -0
- data/spec/watirspec/html/timeout_window_location.html +19 -0
- data/spec/watirspec/html/uneven_table.html +20 -0
- data/spec/watirspec/html/wait.html +65 -0
- data/spec/watirspec/html/watirspec.css +0 -0
- data/spec/watirspec/html/window_switching.html +12 -0
- data/spec/watirspec/relaxed_locate_spec.rb +214 -0
- data/spec/watirspec/screenshot_spec.rb +29 -0
- data/spec/watirspec/wait_spec.rb +304 -0
- data/spec/watirspec/window_switching_spec.rb +411 -0
- data/spec/{implementation.rb → watirspec_helper.rb} +13 -13
- data/support/appveyor.cmd +9 -0
- data/support/doctest_helper.rb +5 -1
- data/support/travis.sh +0 -1
- data/watir.gemspec +3 -4
- metadata +323 -30
- data/.gitmodules +0 -3
@@ -0,0 +1,62 @@
|
|
1
|
+
module WatirSpec
|
2
|
+
class Server
|
3
|
+
class App
|
4
|
+
def response(path, data = nil)
|
5
|
+
case path
|
6
|
+
when '/'
|
7
|
+
respond(self.class.name)
|
8
|
+
when '/post_to_me'
|
9
|
+
respond("You posted the following content:\n#{data}")
|
10
|
+
when '/plain_text'
|
11
|
+
respond('This is text/plain', 'Content-Type' => 'text/plain')
|
12
|
+
when %r{/set_cookie}
|
13
|
+
respond("<html>C is for cookie, it's good enough for me</html>", 'Content-Type' => 'text/html', 'Set-Cookie' => 'monster=1')
|
14
|
+
when css_file?
|
15
|
+
respond(File.read("#{WatirSpec.html}/#{path}"), 'Content-Type' => 'text/css')
|
16
|
+
when js_file?
|
17
|
+
respond(File.read("#{WatirSpec.html}/#{path}"), 'Content-Type' => 'application/javascript')
|
18
|
+
when png_file?
|
19
|
+
respond(File.binread("#{WatirSpec.html}/#{path}"), 'Content-Type' => 'image/png')
|
20
|
+
when gif_file?
|
21
|
+
respond(File.read("#{WatirSpec.html}/#{path}"), 'Content-Type' => 'image/gif')
|
22
|
+
when static_file?
|
23
|
+
respond(File.read("#{WatirSpec.html}/#{path}"))
|
24
|
+
else
|
25
|
+
respond('')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def respond(body, headers = {}, status = '200 OK')
|
32
|
+
[status, headers, body]
|
33
|
+
end
|
34
|
+
|
35
|
+
def css_file?
|
36
|
+
proc { |path| static_files.include?(path) && path.end_with?('.css') }
|
37
|
+
end
|
38
|
+
|
39
|
+
def js_file?
|
40
|
+
proc { |path| static_files.include?(path) && path.end_with?('.js') }
|
41
|
+
end
|
42
|
+
|
43
|
+
def png_file?
|
44
|
+
proc { |path| static_files.include?(path) && path.end_with?('.png') }
|
45
|
+
end
|
46
|
+
|
47
|
+
def gif_file?
|
48
|
+
proc { |path| static_files.include?(path) && path.end_with?('.gif') }
|
49
|
+
end
|
50
|
+
|
51
|
+
def static_file?
|
52
|
+
proc { |path| static_files.include?(path) }
|
53
|
+
end
|
54
|
+
|
55
|
+
def static_files
|
56
|
+
Dir["#{WatirSpec.html}/**/*"].map do |file|
|
57
|
+
file.sub(WatirSpec.html, '')
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/spec/browser_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'watirspec_helper'
|
2
2
|
|
3
3
|
describe Watir::Browser do
|
4
4
|
|
@@ -77,10 +77,10 @@ describe Watir::Browser do
|
|
77
77
|
|
78
78
|
describe "#wait_while" do
|
79
79
|
it "delegates to the Wait module" do
|
80
|
-
expect(Wait).to receive(:while).with(3, "foo").and_yield
|
80
|
+
expect(Watir::Wait).to receive(:while).with(timeout: 3, message: "foo", object: browser).and_yield
|
81
81
|
|
82
82
|
called = false
|
83
|
-
browser.wait_while(3, "foo") { called = true }
|
83
|
+
browser.wait_while(timeout: 3, message: "foo") { called = true }
|
84
84
|
|
85
85
|
expect(called).to be true
|
86
86
|
end
|
@@ -88,10 +88,10 @@ describe Watir::Browser do
|
|
88
88
|
|
89
89
|
describe "#wait_until" do
|
90
90
|
it "delegates to the Wait module" do
|
91
|
-
expect(Wait).to receive(:until).with(3, "foo").and_yield
|
91
|
+
expect(Watir::Wait).to receive(:until).with(timeout: 3, message: "foo", object: browser).and_yield
|
92
92
|
|
93
93
|
called = false
|
94
|
-
browser.wait_until(3, "foo") { called = true }
|
94
|
+
browser.wait_until(timeout: 3, message: "foo") { called = true }
|
95
95
|
|
96
96
|
expect(called).to be true
|
97
97
|
end
|
data/spec/click_spec.rb
CHANGED
data/spec/container_spec.rb
CHANGED
data/spec/element_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'watirspec_helper'
|
2
2
|
|
3
3
|
describe Watir::Element do
|
4
4
|
|
@@ -76,11 +76,14 @@ describe Watir::Element do
|
|
76
76
|
|
77
77
|
watir_element = browser.div(id: "text")
|
78
78
|
|
79
|
-
# simulate element going stale after assert_exists and before action taken
|
79
|
+
# simulate element going stale after assert_exists and before action taken, but not when block retried
|
80
80
|
allow(watir_element).to receive(:text) do
|
81
|
-
watir_element.send
|
82
|
-
|
83
|
-
|
81
|
+
watir_element.send(:element_call) do
|
82
|
+
@already_stale ||= false
|
83
|
+
browser.refresh unless @already_stale
|
84
|
+
@already_stale = true
|
85
|
+
watir_element.instance_variable_get('@element').text
|
86
|
+
end
|
84
87
|
end
|
85
88
|
|
86
89
|
expect { watir_element.text }.to_not raise_error
|
@@ -103,50 +106,33 @@ describe Watir::Element do
|
|
103
106
|
end
|
104
107
|
end
|
105
108
|
|
106
|
-
# TODO - Can remove when decide issue #295
|
107
|
-
describe "warnings" do
|
108
|
-
it "does not return a warning if using text_field for an unspecified text input" do
|
109
|
-
browser.goto(WatirSpec.url_for("forms_with_input_elements.html"))
|
110
|
-
expect do
|
111
|
-
browser.text_field(id: "new_user_first_name").exists?
|
112
|
-
end.to_not output.to_stderr
|
113
|
-
end
|
114
|
-
|
115
|
-
it "returns a warning if using text_field for textarea" do
|
116
|
-
browser.goto(WatirSpec.url_for("forms_with_input_elements.html"))
|
117
|
-
expect do
|
118
|
-
browser.text_field(id: "create_user_comment").exists?
|
119
|
-
end.to output.to_stderr
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
109
|
describe "#selector_string" do
|
124
110
|
it "displays selector string for regular element" do
|
125
111
|
browser.goto(WatirSpec.url_for("wait.html"))
|
126
|
-
|
127
|
-
|
128
|
-
expect
|
112
|
+
element = browser.div(:id, 'not_present')
|
113
|
+
error = 'timed out after 0 seconds, waiting for true condition on {:id=>"not_present", :tag_name=>"div"}'
|
114
|
+
expect { element.wait_until_present(timeout: 0) }.to raise_exception(Watir::Wait::TimeoutError, error)
|
129
115
|
end
|
130
116
|
|
131
117
|
it "displays selector string for element from colection" do
|
132
118
|
browser.goto(WatirSpec.url_for("wait.html"))
|
133
|
-
|
134
|
-
|
135
|
-
expect
|
119
|
+
element = browser.divs.last
|
120
|
+
error = 'timed out after 0 seconds, waiting for true condition on {:tag_name=>"div", :index=>4}'
|
121
|
+
expect { element.wait_until_present(timeout: 0) }.to raise_exception(Watir::Wait::TimeoutError, error)
|
136
122
|
end
|
137
123
|
|
138
124
|
it "displays selector string for nested element" do
|
139
125
|
browser.goto(WatirSpec.url_for("wait.html"))
|
140
|
-
|
141
|
-
|
142
|
-
expect
|
126
|
+
element = browser.div(index: -1).div(:id, 'foo')
|
127
|
+
error = 'timed out after 0 seconds, waiting for true condition on {:index=>-1, :tag_name=>"div"} --> {:id=>"foo", :tag_name=>"div"}'
|
128
|
+
expect { element.wait_until_present(timeout: 0) }.to raise_exception(Watir::Wait::TimeoutError, error)
|
143
129
|
end
|
144
130
|
|
145
131
|
it "displays selector string for nested element under frame" do
|
146
132
|
browser.goto(WatirSpec.url_for("nested_iframes.html"))
|
147
|
-
|
148
|
-
|
149
|
-
expect
|
133
|
+
element = browser.iframe(id: 'one').iframe(:id, 'three')
|
134
|
+
error = 'unable to locate iframe using {:id=>"one", :tag_name=>"iframe"} --> {:id=>"three", :tag_name=>"iframe"}'
|
135
|
+
expect { element.wait_until_present(timeout: 0) }.to raise_exception(Watir::Exception::UnknownFrameException, error)
|
150
136
|
end
|
151
137
|
end
|
152
138
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'watirspec_helper'
|
2
|
+
|
3
|
+
describe WatirSpec::Implementation do
|
4
|
+
before { @impl = WatirSpec::Implementation.new }
|
5
|
+
|
6
|
+
it "finds matching guards" do
|
7
|
+
guards = {
|
8
|
+
[:firefox] => [
|
9
|
+
{name: :not_compliant, data: {file: "./spec/watirspec/div_spec.rb:108"}},
|
10
|
+
{name: :deviates, data: {file: "./spec/watirspec/div_spec.rb:114"}},
|
11
|
+
{name: :not_compliant, data: {file: "./spec/watirspec/div_spec.rb:200"}},
|
12
|
+
{name: :bug, data: {file: "./spec/watirspec/div_spec.rb:228", key: "WTR-350"}}
|
13
|
+
],
|
14
|
+
[:chrome] => [
|
15
|
+
{name: :not_compliant, data: {file: "./spec/watirspec/div_spec.rb:109"}},
|
16
|
+
{name: :deviates, data: {file: "./spec/watirspec/div_spec.rb:115"}},
|
17
|
+
{name: :not_compliant, data: {file: "./spec/watirspec/div_spec.rb:201"}},
|
18
|
+
{name: :bug, data: {file: "./spec/watirspec/div_spec.rb:229", key: "WTR-349"}}
|
19
|
+
]
|
20
|
+
}
|
21
|
+
@impl.name = :firefox
|
22
|
+
expect(@impl.matching_guards_in(guards)).to eq(guards.first[1])
|
23
|
+
end
|
24
|
+
end
|
data/spec/input_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -6,13 +6,14 @@ Coveralls.wear!
|
|
6
6
|
|
7
7
|
require 'watir'
|
8
8
|
require 'locator_spec_helper'
|
9
|
-
require 'rubygems'
|
10
9
|
require 'rspec'
|
11
10
|
|
12
|
-
include Watir
|
13
|
-
|
14
11
|
SELENIUM_SELECTORS = %i(class class_name css id tag_name xpath)
|
15
12
|
|
13
|
+
if ENV['RELAXED_LOCATE'] == "false"
|
14
|
+
Watir.relaxed_locate = false
|
15
|
+
end
|
16
|
+
|
16
17
|
if ENV['TRAVIS']
|
17
18
|
ENV['DISPLAY'] = ":99.0"
|
18
19
|
|
@@ -25,3 +26,34 @@ end
|
|
25
26
|
if Selenium::WebDriver::Platform.linux? && ENV['DISPLAY'].nil?
|
26
27
|
raise "DISPLAY not set"
|
27
28
|
end
|
29
|
+
|
30
|
+
TIMING_EXCEPTIONS = { raise_unknown_object_exception: Watir::Exception::UnknownObjectException,
|
31
|
+
raise_no_matching_window_exception: Watir::Exception::NoMatchingWindowFoundException,
|
32
|
+
raise_unknown_frame_exception: Watir::Exception::UnknownFrameException,
|
33
|
+
raise_object_disabled_exception: Watir::Exception::ObjectDisabledException,
|
34
|
+
raise_object_read_only_exception: Watir::Exception::ObjectReadOnlyException}
|
35
|
+
|
36
|
+
TIMING_EXCEPTIONS.each do |matcher, exception|
|
37
|
+
RSpec::Matchers.define matcher do |_expected|
|
38
|
+
match do |actual|
|
39
|
+
original_timeout = Watir.default_timeout
|
40
|
+
Watir.default_timeout = 0
|
41
|
+
begin
|
42
|
+
actual.call
|
43
|
+
false
|
44
|
+
rescue exception
|
45
|
+
true
|
46
|
+
ensure
|
47
|
+
Watir.default_timeout = original_timeout
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
failure_message do |actual|
|
52
|
+
"expected #{exception} but nothing was raised"
|
53
|
+
end
|
54
|
+
|
55
|
+
def supports_block_expectations?
|
56
|
+
true
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/spec/special_chars_spec.rb
CHANGED
@@ -0,0 +1,179 @@
|
|
1
|
+
require "watirspec_helper"
|
2
|
+
|
3
|
+
describe "Browser::AfterHooks" do
|
4
|
+
describe "#add" do
|
5
|
+
it "raises ArgumentError when not given any arguments" do
|
6
|
+
expect { browser.after_hooks.add }.to raise_error(ArgumentError)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "runs the given proc on each page load" do
|
10
|
+
output = ''
|
11
|
+
proc = Proc.new { |browser| output << browser.text }
|
12
|
+
|
13
|
+
begin
|
14
|
+
browser.after_hooks.add(proc)
|
15
|
+
browser.goto(WatirSpec.url_for("non_control_elements.html"))
|
16
|
+
|
17
|
+
expect(output).to include('Dubito, ergo cogito, ergo sum')
|
18
|
+
ensure
|
19
|
+
browser.after_hooks.delete(proc)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#delete" do
|
25
|
+
it "removes a previously added after_hook" do
|
26
|
+
output = ''
|
27
|
+
after_hook = lambda{ |browser| output << browser.text }
|
28
|
+
|
29
|
+
browser.after_hooks.add(after_hook)
|
30
|
+
browser.goto(WatirSpec.url_for("non_control_elements.html"))
|
31
|
+
expect(output).to include('Dubito, ergo cogito, ergo sum')
|
32
|
+
|
33
|
+
browser.after_hooks.delete(after_hook)
|
34
|
+
browser.goto(WatirSpec.url_for("definition_lists.html"))
|
35
|
+
expect(output).to_not include('definition_lists')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "#run" do
|
40
|
+
after(:each) do
|
41
|
+
browser.window(index: 0).use
|
42
|
+
browser.after_hooks.delete @page_after_hook
|
43
|
+
end
|
44
|
+
|
45
|
+
it "runs after_hooks after Browser#goto" do
|
46
|
+
@page_after_hook = Proc.new { @yield = browser.title == "The font element" }
|
47
|
+
browser.after_hooks.add @page_after_hook
|
48
|
+
browser.goto WatirSpec.url_for("font.html")
|
49
|
+
expect(@yield).to be true
|
50
|
+
end
|
51
|
+
|
52
|
+
it "runs after_hooks after Browser#refresh" do
|
53
|
+
browser.goto WatirSpec.url_for("font.html")
|
54
|
+
@page_after_hook = Proc.new do
|
55
|
+
@yield = browser.title == "The font element"
|
56
|
+
end
|
57
|
+
browser.after_hooks.add @page_after_hook
|
58
|
+
browser.refresh
|
59
|
+
expect(@yield).to be true
|
60
|
+
end
|
61
|
+
|
62
|
+
it "runs after_hooks after Element#click" do
|
63
|
+
browser.goto(WatirSpec.url_for("non_control_elements.html"))
|
64
|
+
@page_after_hook = Proc.new do
|
65
|
+
browser.wait_until { |b| b.title == "Forms with input elements" }
|
66
|
+
@yield = true
|
67
|
+
end
|
68
|
+
browser.after_hooks.add @page_after_hook
|
69
|
+
browser.link(index: 2).click
|
70
|
+
expect(@yield).to be true
|
71
|
+
end
|
72
|
+
|
73
|
+
bug "AutomatedTester: 'known bug with execute script'", :firefox do
|
74
|
+
it "runs after_hooks after Element#submit" do
|
75
|
+
browser.goto(WatirSpec.url_for("forms_with_input_elements.html"))
|
76
|
+
@page_after_hook = Proc.new { @yield = browser.div(id: 'messages').text == 'submit' }
|
77
|
+
browser.after_hooks.add @page_after_hook
|
78
|
+
browser.form(id: "new_user").submit
|
79
|
+
expect(@yield).to be true
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
not_compliant_on :safari do
|
84
|
+
bug "Actions Endpoint Not Yet Implemented", :firefox do
|
85
|
+
it "runs after_hooks after Element#double_click" do
|
86
|
+
browser.goto(WatirSpec.url_for("non_control_elements.html"))
|
87
|
+
@page_after_hook = Proc.new { @yield = browser.title == "Non-control elements" }
|
88
|
+
browser.after_hooks.add @page_after_hook
|
89
|
+
browser.div(id: 'html_test').double_click
|
90
|
+
expect(@yield).to be true
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
not_compliant_on :safari do
|
96
|
+
bug "Actions Endpoint Not Yet Implemented", :firefox do
|
97
|
+
it "runs after_hooks after Element#right_click" do
|
98
|
+
browser.goto(WatirSpec.url_for("right_click.html"))
|
99
|
+
@page_after_hook = Proc.new { @yield = browser.title == "Right Click Test" }
|
100
|
+
browser.after_hooks.add @page_after_hook
|
101
|
+
browser.div(id: "click").right_click
|
102
|
+
expect(@yield).to be true
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
bug "https://github.com/detro/ghostdriver/issues/20", :phantomjs do
|
108
|
+
not_compliant_on :safari do
|
109
|
+
it "runs after_hooks after Alert#ok" do
|
110
|
+
browser.goto(WatirSpec.url_for("alerts.html"))
|
111
|
+
@page_after_hook = Proc.new { @yield = browser.title == "Alerts" }
|
112
|
+
browser.after_hooks.add @page_after_hook
|
113
|
+
browser.after_hooks.without { browser.button(id: 'alert').click }
|
114
|
+
browser.alert.ok
|
115
|
+
expect(@yield).to be true
|
116
|
+
end
|
117
|
+
|
118
|
+
bug "https://code.google.com/p/chromedriver/issues/detail?id=26", [:chrome, :macosx] do
|
119
|
+
it "runs after_hooks after Alert#close" do
|
120
|
+
browser.goto(WatirSpec.url_for("alerts.html"))
|
121
|
+
@page_after_hook = Proc.new { @yield = browser.title == "Alerts" }
|
122
|
+
browser.after_hooks.add @page_after_hook
|
123
|
+
browser.after_hooks.without { browser.button(id: 'alert').click }
|
124
|
+
browser.alert.close
|
125
|
+
expect(@yield).to be true
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
bug "https://bugzilla.mozilla.org/show_bug.cgi?id=1279211", :firefox do
|
130
|
+
it "raises UnhandledAlertError error when running error checks with alert present" do
|
131
|
+
url = WatirSpec.url_for("alerts.html")
|
132
|
+
@page_after_hook = Proc.new { browser.url }
|
133
|
+
browser.after_hooks.add @page_after_hook
|
134
|
+
browser.goto url
|
135
|
+
expect { browser.button(id: "alert").click }.to raise_error(Selenium::WebDriver::Error::UnhandledAlertError)
|
136
|
+
|
137
|
+
not_compliant_on :ff_legacy do
|
138
|
+
browser.alert.ok
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
it "does not raise error when running error checks using #after_hooks#without with alert present" do
|
144
|
+
url = WatirSpec.url_for("alerts.html")
|
145
|
+
@page_after_hook = Proc.new { browser.url }
|
146
|
+
browser.after_hooks.add @page_after_hook
|
147
|
+
browser.goto url
|
148
|
+
expect { browser.after_hooks.without {browser.button(id: "alert").click} }.to_not raise_error
|
149
|
+
browser.alert.ok
|
150
|
+
end
|
151
|
+
|
152
|
+
it "does not raise error if no error checks are defined with alert present" do
|
153
|
+
url = WatirSpec.url_for("alerts.html")
|
154
|
+
@page_after_hook = Proc.new { browser.url }
|
155
|
+
browser.after_hooks.add @page_after_hook
|
156
|
+
browser.goto url
|
157
|
+
browser.after_hooks.delete @page_after_hook
|
158
|
+
expect { browser.button(id: "alert").click }.to_not raise_error
|
159
|
+
browser.alert.ok
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
bug "https://bugzilla.mozilla.org/show_bug.cgi?id=1223277", :firefox do
|
165
|
+
it "does not raise error when running error checks on closed window" do
|
166
|
+
url = WatirSpec.url_for("window_switching.html")
|
167
|
+
@page_after_hook = Proc.new { browser.url }
|
168
|
+
browser.after_hooks.add @page_after_hook
|
169
|
+
browser.goto url
|
170
|
+
browser.a(id: "open").click
|
171
|
+
|
172
|
+
window = browser.window(title: "closeable window")
|
173
|
+
window.use
|
174
|
+
expect { browser.a(id: "close").click }.to_not raise_error
|
175
|
+
browser.window(index: 0).use
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|