diabolo-webrat 0.4.4.2 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +4 -0
- data/.gitignore +15 -0
- data/History.txt +60 -9
- data/Rakefile +90 -75
- data/VERSION +1 -0
- data/lib/webrat.rb +8 -23
- data/lib/webrat/{mechanize.rb → adapters/mechanize.rb} +6 -2
- data/lib/webrat/adapters/merb.rb +11 -0
- data/lib/webrat/adapters/rack.rb +25 -0
- data/lib/webrat/{rails.rb → adapters/rails.rb} +9 -18
- data/lib/webrat/adapters/sinatra.rb +9 -0
- data/lib/webrat/core.rb +0 -1
- data/lib/webrat/core/configuration.rb +7 -17
- data/lib/webrat/core/elements/area.rb +2 -2
- data/lib/webrat/core/elements/element.rb +3 -3
- data/lib/webrat/core/elements/field.rb +33 -30
- data/lib/webrat/core/elements/form.rb +4 -4
- data/lib/webrat/core/elements/label.rb +4 -4
- data/lib/webrat/core/elements/link.rb +7 -6
- data/lib/webrat/core/elements/select_option.rb +2 -2
- data/lib/webrat/core/locators.rb +1 -1
- data/lib/webrat/core/locators/area_locator.rb +3 -3
- data/lib/webrat/core/locators/button_locator.rb +6 -6
- data/lib/webrat/core/locators/field_by_id_locator.rb +3 -3
- data/lib/webrat/core/locators/field_labeled_locator.rb +2 -2
- data/lib/webrat/core/locators/field_named_locator.rb +3 -3
- data/lib/webrat/core/locators/form_locator.rb +1 -1
- data/lib/webrat/core/locators/label_locator.rb +2 -2
- data/lib/webrat/core/locators/link_locator.rb +20 -12
- data/lib/webrat/core/locators/select_option_locator.rb +5 -5
- data/lib/webrat/core/logging.rb +1 -1
- data/lib/webrat/core/matchers/have_content.rb +2 -7
- data/lib/webrat/core/matchers/have_xpath.rb +2 -27
- data/lib/webrat/core/methods.rb +4 -4
- data/lib/webrat/core/mime.rb +11 -22
- data/lib/webrat/core/save_and_open_page.rb +5 -7
- data/lib/webrat/core/scope.rb +2 -2
- data/lib/webrat/core/session.rb +30 -14
- data/lib/webrat/core/xml.rb +41 -84
- data/lib/webrat/integrations/merb.rb +10 -0
- data/lib/webrat/integrations/rails.rb +9 -0
- data/lib/webrat/integrations/rspec-rails.rb +10 -0
- data/lib/webrat/integrations/selenium.rb +11 -0
- data/lib/webrat/rspec-rails.rb +2 -13
- data/lib/webrat/selenium.rb +0 -11
- data/lib/webrat/selenium/application_server_factory.rb +40 -0
- data/lib/webrat/selenium/application_servers.rb +5 -0
- data/lib/webrat/selenium/application_servers/base.rb +46 -0
- data/lib/webrat/selenium/application_servers/external.rb +26 -0
- data/lib/webrat/selenium/application_servers/merb.rb +50 -0
- data/lib/webrat/selenium/application_servers/rails.rb +44 -0
- data/lib/webrat/selenium/application_servers/sinatra.rb +37 -0
- data/lib/webrat/selenium/location_strategy_javascript/label.js +2 -1
- data/lib/webrat/selenium/selenium_rc_server.rb +7 -5
- data/lib/webrat/selenium/selenium_session.rb +20 -7
- data/lib/webrat/selenium/silence_stream.rb +1 -1
- data/spec/fakes/{test_session.rb → test_adapter.rb} +6 -3
- data/spec/integration/mechanize/Rakefile +7 -0
- data/spec/integration/mechanize/config.ru +2 -0
- data/spec/integration/mechanize/sample_app.rb +20 -0
- data/spec/integration/mechanize/spec/mechanize_spec.rb +22 -0
- data/spec/integration/mechanize/spec/spec_helper.rb +27 -0
- data/spec/integration/merb/.gitignore +21 -0
- data/spec/integration/merb/Rakefile +35 -0
- data/spec/integration/merb/app/controllers/testing.rb +9 -0
- data/spec/integration/merb/app/views/exceptions/not_acceptable.html.erb +63 -0
- data/spec/integration/merb/app/views/exceptions/not_found.html.erb +47 -0
- data/spec/integration/merb/app/views/layout/application.html.erb +12 -0
- data/spec/integration/merb/app/views/testing/show_form.html.erb +27 -0
- data/spec/integration/merb/app/views/testing/upload.html.erb +9 -0
- data/spec/integration/merb/config/router.rb +1 -0
- data/spec/integration/merb/spec/spec.opts +1 -0
- data/spec/integration/merb/spec/spec_helper.rb +2 -0
- data/spec/integration/merb/spec/webrat_spec.rb +7 -0
- data/spec/integration/merb/tasks/merb.thor/main.thor +150 -0
- data/spec/integration/rack/Rakefile +5 -0
- data/spec/integration/rack/app.rb +89 -0
- data/spec/integration/rack/test/helper.rb +21 -0
- data/spec/integration/rack/test/webrat_rack_test.rb +57 -51
- data/spec/integration/rails/.gitignore +3 -0
- data/spec/integration/rails/Rakefile +30 -0
- data/spec/integration/rails/app/controllers/webrat_controller.rb +13 -9
- data/spec/integration/rails/app/views/buttons/show.html.erb +11 -0
- data/spec/integration/rails/app/views/fields/show.html.erb +9 -0
- data/spec/integration/rails/app/views/links/show.html.erb +5 -0
- data/spec/integration/rails/app/views/webrat/before_redirect_form.html.erb +4 -0
- data/spec/integration/rails/app/views/webrat/buttons.html.erb +11 -0
- data/spec/integration/rails/app/views/webrat/form.html.erb +28 -0
- data/spec/integration/rails/config/locales/en.yml +5 -0
- data/spec/integration/rails/config/routes.rb +1 -0
- data/spec/integration/rails/public/404.html +30 -0
- data/spec/integration/rails/public/422.html +30 -0
- data/spec/integration/rails/public/500.html +33 -0
- data/spec/integration/rails/script/about +4 -0
- data/spec/integration/rails/script/console +3 -0
- data/spec/integration/rails/script/dbconsole +3 -0
- data/spec/integration/rails/script/destroy +3 -0
- data/spec/integration/rails/script/generate +3 -0
- data/spec/integration/rails/script/performance/benchmarker +3 -0
- data/spec/integration/rails/script/performance/profiler +3 -0
- data/spec/integration/rails/script/performance/request +3 -0
- data/spec/integration/rails/script/plugin +3 -0
- data/spec/integration/rails/script/process/inspector +3 -0
- data/spec/integration/rails/script/process/reaper +3 -0
- data/spec/integration/rails/script/process/spawner +3 -0
- data/spec/integration/rails/script/runner +3 -0
- data/spec/integration/rails/script/server +3 -0
- data/spec/integration/rails/test/integration/button_click_test.rb +2 -2
- data/spec/integration/rails/test/integration/link_click_test.rb +7 -1
- data/spec/integration/rails/test/integration/webrat_test.rb +22 -0
- data/spec/integration/rails/test/test_helper.rb +6 -5
- data/spec/integration/sinatra/Rakefile +5 -0
- data/spec/integration/sinatra/test/test_helper.rb +3 -2
- data/spec/private/core/configuration_spec.rb +8 -27
- data/spec/private/core/field_spec.rb +7 -7
- data/spec/private/core/link_spec.rb +1 -1
- data/spec/private/core/session_spec.rb +23 -21
- data/spec/private/mechanize/{mechanize_session_spec.rb → mechanize_adapter_spec.rb} +4 -12
- data/spec/private/nokogiri_spec.rb +2 -2
- data/spec/private/rails/{rails_session_spec.rb → rails_adapter_spec.rb} +16 -16
- data/spec/private/selenium/application_servers/rails_spec.rb +26 -0
- data/spec/public/matchers/contain_spec.rb +4 -4
- data/spec/public/matchers/have_selector_spec.rb +2 -2
- data/spec/public/matchers/have_xpath_spec.rb +3 -3
- data/spec/public/save_and_open_spec.rb +25 -6
- data/spec/public/selenium/application_server_factory_spec.rb +49 -0
- data/spec/public/selenium/application_servers/external_spec.rb +12 -0
- data/spec/public/selenium/selenium_session_spec.rb +37 -0
- data/spec/rcov.opts +1 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +5 -1
- data/vendor/selenium-server.jar +0 -0
- data/webrat.gemspec +348 -0
- metadata +176 -23
- data/lib/webrat/core/xml/hpricot.rb +0 -19
- data/lib/webrat/core/xml/nokogiri.rb +0 -76
- data/lib/webrat/core/xml/rexml.rb +0 -24
- data/lib/webrat/merb_session.rb +0 -65
- data/lib/webrat/rack.rb +0 -24
- data/lib/webrat/rack_test.rb +0 -32
- data/lib/webrat/selenium/application_server.rb +0 -73
- data/lib/webrat/selenium/merb_application_server.rb +0 -48
- data/lib/webrat/selenium/rails_application_server.rb +0 -42
- data/lib/webrat/selenium/sinatra_application_server.rb +0 -35
- data/lib/webrat/sinatra.rb +0 -44
- data/spec/integration/rack/rack_app.rb +0 -16
- data/spec/integration/rack/test/test_helper.rb +0 -20
- data/spec/private/merb/merb_session_spec.rb +0 -42
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
require "webrat"
|
|
2
|
-
|
|
3
|
-
require "action_controller"
|
|
4
|
-
require "action_controller/integration"
|
|
1
|
+
require "webrat/integrations/rails"
|
|
5
2
|
require "action_controller/record_identifier"
|
|
6
3
|
|
|
7
4
|
module Webrat
|
|
8
|
-
class
|
|
5
|
+
class RailsAdapter #:nodoc:
|
|
9
6
|
include ActionController::RecordIdentifier
|
|
10
7
|
|
|
8
|
+
attr_reader :integration_session
|
|
9
|
+
|
|
10
|
+
def initialize(session)
|
|
11
|
+
@integration_session = session
|
|
12
|
+
end
|
|
13
|
+
|
|
11
14
|
# The Rails version of within supports passing in a model and Webrat
|
|
12
15
|
# will apply a scope based on Rails' dom_id for that model.
|
|
13
16
|
#
|
|
@@ -61,10 +64,6 @@ module Webrat
|
|
|
61
64
|
|
|
62
65
|
protected
|
|
63
66
|
|
|
64
|
-
def integration_session
|
|
65
|
-
@context
|
|
66
|
-
end
|
|
67
|
-
|
|
68
67
|
def do_request(http_method, url, data, headers) #:nodoc:
|
|
69
68
|
update_protocol(url)
|
|
70
69
|
integration_session.send(http_method, normalize_url(url), data, headers)
|
|
@@ -93,13 +92,5 @@ module Webrat
|
|
|
93
92
|
def response #:nodoc:
|
|
94
93
|
integration_session.response
|
|
95
94
|
end
|
|
96
|
-
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
module ActionController #:nodoc:
|
|
101
|
-
IntegrationTest.class_eval do
|
|
102
|
-
include Webrat::Methods
|
|
103
|
-
include Webrat::Matchers
|
|
104
95
|
end
|
|
105
|
-
end
|
|
96
|
+
end
|
data/lib/webrat/core.rb
CHANGED
|
@@ -16,13 +16,10 @@ module Webrat
|
|
|
16
16
|
# Webrat can be configured using the Webrat.configure method. For example:
|
|
17
17
|
#
|
|
18
18
|
# Webrat.configure do |config|
|
|
19
|
-
# config.
|
|
19
|
+
# config.mode = :sinatra
|
|
20
20
|
# end
|
|
21
21
|
class Configuration
|
|
22
22
|
|
|
23
|
-
# Should XHTML be parsed with Nokogiri? Defaults to true, except on JRuby. When false, Hpricot and REXML are used
|
|
24
|
-
attr_writer :parse_with_nokogiri
|
|
25
|
-
|
|
26
23
|
# Webrat's mode, set automatically when requiring webrat/rails, webrat/merb, etc.
|
|
27
24
|
attr_reader :mode # :nodoc:
|
|
28
25
|
|
|
@@ -53,7 +50,7 @@ module Webrat
|
|
|
53
50
|
|
|
54
51
|
# Set the key that Selenium uses to determine the browser running. Default *firefox
|
|
55
52
|
attr_accessor :selenium_browser_key
|
|
56
|
-
|
|
53
|
+
|
|
57
54
|
# Set the timeout for waiting for the browser process to start
|
|
58
55
|
attr_accessor :selenium_browser_startup_timeout
|
|
59
56
|
|
|
@@ -63,7 +60,6 @@ module Webrat
|
|
|
63
60
|
|
|
64
61
|
def initialize # :nodoc:
|
|
65
62
|
self.open_error_files = true
|
|
66
|
-
self.parse_with_nokogiri = true
|
|
67
63
|
self.application_environment = :test
|
|
68
64
|
self.application_port = 3001
|
|
69
65
|
self.application_address = 'localhost'
|
|
@@ -74,10 +70,6 @@ module Webrat
|
|
|
74
70
|
self.selenium_browser_startup_timeout = 5
|
|
75
71
|
end
|
|
76
72
|
|
|
77
|
-
def parse_with_nokogiri? #:nodoc:
|
|
78
|
-
@parse_with_nokogiri ? true : false
|
|
79
|
-
end
|
|
80
|
-
|
|
81
73
|
def open_error_files? #:nodoc:
|
|
82
74
|
@open_error_files ? true : false
|
|
83
75
|
end
|
|
@@ -87,13 +79,11 @@ module Webrat
|
|
|
87
79
|
def mode=(mode)
|
|
88
80
|
@mode = mode.to_sym
|
|
89
81
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
else
|
|
96
|
-
require("webrat/#{mode}")
|
|
82
|
+
begin
|
|
83
|
+
require("webrat/integrations/#{mode}")
|
|
84
|
+
rescue LoadError
|
|
85
|
+
# Only some modes have integration code that needs to
|
|
86
|
+
# be loaded, so this is OK
|
|
97
87
|
end
|
|
98
88
|
end
|
|
99
89
|
|
|
@@ -4,7 +4,7 @@ module Webrat
|
|
|
4
4
|
class Area < Element #:nodoc:
|
|
5
5
|
|
|
6
6
|
def self.xpath_search
|
|
7
|
-
".//area"
|
|
7
|
+
[".//area"]
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
def click(method = nil, options = {})
|
|
@@ -14,7 +14,7 @@ module Webrat
|
|
|
14
14
|
protected
|
|
15
15
|
|
|
16
16
|
def href
|
|
17
|
-
|
|
17
|
+
@element["href"]
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def absolute_href
|
|
@@ -3,14 +3,14 @@ module Webrat
|
|
|
3
3
|
class Element # :nodoc:
|
|
4
4
|
|
|
5
5
|
def self.load_all(session, dom)
|
|
6
|
-
|
|
6
|
+
dom.xpath(*xpath_search).map do |element|
|
|
7
7
|
load(session, element)
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def self.load(session, element)
|
|
12
12
|
return nil if element.nil?
|
|
13
|
-
session.elements[
|
|
13
|
+
session.elements[element.path] ||= self.new(session, element)
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
attr_reader :element
|
|
@@ -21,7 +21,7 @@ module Webrat
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def path
|
|
24
|
-
|
|
24
|
+
@element.path
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def inspect
|
|
@@ -32,7 +32,7 @@ module Webrat
|
|
|
32
32
|
|
|
33
33
|
def self.load(session, element)
|
|
34
34
|
return nil if element.nil?
|
|
35
|
-
session.elements[
|
|
35
|
+
session.elements[element.path] ||= field_class(element).new(session, element)
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
def self.field_class(element)
|
|
@@ -41,7 +41,7 @@ module Webrat
|
|
|
41
41
|
when "select" then SelectField
|
|
42
42
|
when "textarea" then TextareaField
|
|
43
43
|
else
|
|
44
|
-
case
|
|
44
|
+
case element["type"]
|
|
45
45
|
when "checkbox" then CheckboxField
|
|
46
46
|
when "hidden" then HiddenField
|
|
47
47
|
when "radio" then RadioField
|
|
@@ -67,11 +67,11 @@ module Webrat
|
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
def id
|
|
70
|
-
|
|
70
|
+
@element["id"]
|
|
71
71
|
end
|
|
72
72
|
|
|
73
73
|
def disabled?
|
|
74
|
-
@element.attributes.has_key?("disabled") &&
|
|
74
|
+
@element.attributes.has_key?("disabled") && @element["disabled"] != 'false'
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
def raise_error_if_disabled
|
|
@@ -87,10 +87,8 @@ module Webrat
|
|
|
87
87
|
parse_rails_request_params("#{name}=#{escaped_value}")
|
|
88
88
|
when :merb
|
|
89
89
|
::Merb::Parse.query("#{name}=#{escaped_value}")
|
|
90
|
-
when :mechanize
|
|
91
|
-
{ name => value }
|
|
92
90
|
else
|
|
93
|
-
{ name =>
|
|
91
|
+
{ name => value }
|
|
94
92
|
end
|
|
95
93
|
end
|
|
96
94
|
|
|
@@ -130,11 +128,11 @@ module Webrat
|
|
|
130
128
|
end
|
|
131
129
|
|
|
132
130
|
def name
|
|
133
|
-
|
|
131
|
+
@element["name"]
|
|
134
132
|
end
|
|
135
133
|
|
|
136
134
|
def escaped_value
|
|
137
|
-
CGI.escape(
|
|
135
|
+
CGI.escape([*@value].first.to_s)
|
|
138
136
|
end
|
|
139
137
|
|
|
140
138
|
def labels
|
|
@@ -157,14 +155,14 @@ module Webrat
|
|
|
157
155
|
end
|
|
158
156
|
|
|
159
157
|
unless id.blank?
|
|
160
|
-
@label_elements +=
|
|
158
|
+
@label_elements += form.element.xpath(".//label[@for = '#{id}']")
|
|
161
159
|
end
|
|
162
160
|
|
|
163
161
|
@label_elements
|
|
164
162
|
end
|
|
165
163
|
|
|
166
164
|
def default_value
|
|
167
|
-
|
|
165
|
+
@element["value"]
|
|
168
166
|
end
|
|
169
167
|
|
|
170
168
|
def replace_param_value(params, oval, nval)
|
|
@@ -201,7 +199,7 @@ module Webrat
|
|
|
201
199
|
|
|
202
200
|
def click
|
|
203
201
|
raise_error_if_disabled
|
|
204
|
-
set(
|
|
202
|
+
set(@element["value"]) unless @element["name"].blank?
|
|
205
203
|
form.submit
|
|
206
204
|
end
|
|
207
205
|
|
|
@@ -248,11 +246,11 @@ module Webrat
|
|
|
248
246
|
|
|
249
247
|
def check
|
|
250
248
|
raise_error_if_disabled
|
|
251
|
-
set(
|
|
249
|
+
set(@element["value"] || "on")
|
|
252
250
|
end
|
|
253
251
|
|
|
254
252
|
def checked?
|
|
255
|
-
|
|
253
|
+
@element["checked"] == "checked"
|
|
256
254
|
end
|
|
257
255
|
|
|
258
256
|
def uncheck
|
|
@@ -263,8 +261,8 @@ module Webrat
|
|
|
263
261
|
protected
|
|
264
262
|
|
|
265
263
|
def default_value
|
|
266
|
-
if
|
|
267
|
-
|
|
264
|
+
if @element["checked"] == "checked"
|
|
265
|
+
@element["value"] || "on"
|
|
268
266
|
else
|
|
269
267
|
nil
|
|
270
268
|
end
|
|
@@ -297,11 +295,11 @@ module Webrat
|
|
|
297
295
|
option.set(nil)
|
|
298
296
|
end
|
|
299
297
|
|
|
300
|
-
set(
|
|
298
|
+
set(@element["value"] || "on")
|
|
301
299
|
end
|
|
302
300
|
|
|
303
301
|
def checked?
|
|
304
|
-
|
|
302
|
+
@element["checked"] == "checked"
|
|
305
303
|
end
|
|
306
304
|
|
|
307
305
|
protected
|
|
@@ -311,8 +309,8 @@ module Webrat
|
|
|
311
309
|
end
|
|
312
310
|
|
|
313
311
|
def default_value
|
|
314
|
-
if
|
|
315
|
-
|
|
312
|
+
if @element["checked"] == "checked"
|
|
313
|
+
@element["value"] || "on"
|
|
316
314
|
else
|
|
317
315
|
nil
|
|
318
316
|
end
|
|
@@ -329,7 +327,7 @@ module Webrat
|
|
|
329
327
|
protected
|
|
330
328
|
|
|
331
329
|
def default_value
|
|
332
|
-
|
|
330
|
+
@element.inner_html
|
|
333
331
|
end
|
|
334
332
|
|
|
335
333
|
end
|
|
@@ -358,10 +356,15 @@ module Webrat
|
|
|
358
356
|
protected
|
|
359
357
|
|
|
360
358
|
def test_uploaded_file
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
359
|
+
case Webrat.configuration.mode
|
|
360
|
+
when :rails
|
|
361
|
+
if content_type
|
|
362
|
+
ActionController::TestUploadedFile.new(@value, content_type)
|
|
363
|
+
else
|
|
364
|
+
ActionController::TestUploadedFile.new(@value)
|
|
365
|
+
end
|
|
366
|
+
when :rack, :merb
|
|
367
|
+
Rack::Test::UploadedFile.new(@value, content_type)
|
|
365
368
|
end
|
|
366
369
|
end
|
|
367
370
|
|
|
@@ -375,14 +378,14 @@ module Webrat
|
|
|
375
378
|
|
|
376
379
|
class ResetField < Field #:nodoc:
|
|
377
380
|
def self.xpath_search
|
|
378
|
-
".//input[@type = 'reset']"
|
|
381
|
+
[".//input[@type = 'reset']"]
|
|
379
382
|
end
|
|
380
383
|
end
|
|
381
384
|
|
|
382
385
|
class SelectField < Field #:nodoc:
|
|
383
386
|
|
|
384
387
|
def self.xpath_search
|
|
385
|
-
".//select"
|
|
388
|
+
[".//select"]
|
|
386
389
|
end
|
|
387
390
|
|
|
388
391
|
def options
|
|
@@ -392,12 +395,12 @@ module Webrat
|
|
|
392
395
|
protected
|
|
393
396
|
|
|
394
397
|
def default_value
|
|
395
|
-
selected_options =
|
|
396
|
-
selected_options =
|
|
398
|
+
selected_options = @element.xpath(".//option[@selected = 'selected']")
|
|
399
|
+
selected_options = @element.xpath(".//option[position() = 1]") if selected_options.empty?
|
|
397
400
|
|
|
398
401
|
selected_options.map do |option|
|
|
399
402
|
return "" if option.nil?
|
|
400
|
-
|
|
403
|
+
option["value"] || option.inner_html
|
|
401
404
|
end.uniq
|
|
402
405
|
end
|
|
403
406
|
|
|
@@ -9,7 +9,7 @@ module Webrat
|
|
|
9
9
|
attr_reader :element
|
|
10
10
|
|
|
11
11
|
def self.xpath_search
|
|
12
|
-
".//form"
|
|
12
|
+
[".//form"]
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def fields
|
|
@@ -27,7 +27,7 @@ module Webrat
|
|
|
27
27
|
protected
|
|
28
28
|
|
|
29
29
|
def dom
|
|
30
|
-
|
|
30
|
+
@session.dom.xpath(path).first
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def fields_by_type(field_types)
|
|
@@ -50,11 +50,11 @@ module Webrat
|
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
def form_method
|
|
53
|
-
|
|
53
|
+
@element["method"].blank? ? :get : @element["method"].downcase
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
def form_action
|
|
57
|
-
|
|
57
|
+
@element["action"].blank? ? @session.current_url : @element["action"]
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
def merge(all_params, new_param)
|
|
@@ -6,11 +6,11 @@ module Webrat
|
|
|
6
6
|
attr_reader :element
|
|
7
7
|
|
|
8
8
|
def self.xpath_search
|
|
9
|
-
".//label"
|
|
9
|
+
[".//label"]
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def for_id
|
|
13
|
-
|
|
13
|
+
@element["for"]
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def field
|
|
@@ -21,9 +21,9 @@ module Webrat
|
|
|
21
21
|
|
|
22
22
|
def field_element
|
|
23
23
|
if for_id.blank?
|
|
24
|
-
|
|
24
|
+
@element.xpath(*Field.xpath_search_excluding_hidden).first
|
|
25
25
|
else
|
|
26
|
-
|
|
26
|
+
@session.current_dom.css("#" + for_id).first
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
require "
|
|
1
|
+
require "English"
|
|
2
2
|
|
|
3
|
+
require "webrat/core_extensions/blank"
|
|
3
4
|
require "webrat/core/elements/element"
|
|
4
5
|
|
|
5
6
|
module Webrat
|
|
6
7
|
class Link < Element #:nodoc:
|
|
7
8
|
|
|
8
9
|
def self.xpath_search
|
|
9
|
-
".//a[@href]"
|
|
10
|
+
[".//a[@href]"]
|
|
10
11
|
end
|
|
11
12
|
|
|
12
13
|
def click(options = {})
|
|
@@ -25,7 +26,7 @@ module Webrat
|
|
|
25
26
|
protected
|
|
26
27
|
|
|
27
28
|
def id
|
|
28
|
-
|
|
29
|
+
@element["id"]
|
|
29
30
|
end
|
|
30
31
|
|
|
31
32
|
def data
|
|
@@ -33,11 +34,11 @@ module Webrat
|
|
|
33
34
|
end
|
|
34
35
|
|
|
35
36
|
def title
|
|
36
|
-
|
|
37
|
+
@element["title"]
|
|
37
38
|
end
|
|
38
39
|
|
|
39
40
|
def href
|
|
40
|
-
|
|
41
|
+
@element["href"]
|
|
41
42
|
end
|
|
42
43
|
|
|
43
44
|
def absolute_href
|
|
@@ -57,7 +58,7 @@ module Webrat
|
|
|
57
58
|
end
|
|
58
59
|
|
|
59
60
|
def onclick
|
|
60
|
-
|
|
61
|
+
@element["onclick"]
|
|
61
62
|
end
|
|
62
63
|
|
|
63
64
|
def http_method
|