webrat 0.2.0 → 0.3.0
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/History.txt +76 -14
- data/README.txt +40 -36
- data/Rakefile +80 -18
- data/TODO.txt +9 -3
- data/init.rb +1 -1
- data/lib/webrat.rb +30 -5
- data/lib/webrat/core.rb +12 -0
- data/lib/webrat/core/area.rb +44 -0
- data/lib/webrat/core/field.rb +332 -0
- data/lib/webrat/core/flunk.rb +7 -0
- data/lib/webrat/core/form.rb +130 -0
- data/lib/webrat/core/label.rb +18 -0
- data/lib/webrat/core/link.rb +101 -0
- data/lib/webrat/core/locators.rb +92 -0
- data/lib/webrat/core/logging.rb +25 -0
- data/lib/webrat/core/matchers.rb +4 -0
- data/lib/webrat/core/matchers/have_content.rb +94 -0
- data/lib/webrat/core/matchers/have_selector.rb +39 -0
- data/lib/webrat/core/matchers/have_tag.rb +58 -0
- data/lib/webrat/core/matchers/have_xpath.rb +85 -0
- data/lib/webrat/core/methods.rb +44 -0
- data/lib/webrat/core/mime.rb +29 -0
- data/lib/webrat/core/nokogiri.rb +42 -0
- data/lib/webrat/core/scope.rb +208 -0
- data/lib/webrat/core/select_option.rb +29 -0
- data/lib/webrat/core/session.rb +188 -0
- data/lib/webrat/core_extensions/blank.rb +58 -0
- data/lib/webrat/core_extensions/deprecate.rb +8 -0
- data/lib/webrat/core_extensions/detect_mapped.rb +12 -0
- data/lib/webrat/core_extensions/hash_with_indifferent_access.rb +131 -0
- data/lib/webrat/core_extensions/meta_class.rb +6 -0
- data/lib/webrat/core_extensions/nil_to_param.rb +5 -0
- data/lib/webrat/mechanize.rb +28 -0
- data/lib/webrat/merb.rb +75 -0
- data/lib/webrat/rack.rb +24 -0
- data/lib/webrat/rails.rb +102 -0
- data/lib/webrat/rails/redirect_actions.rb +18 -0
- data/lib/webrat/selenium.rb +3 -0
- data/lib/webrat/selenium/location_strategy_javascript/button.js +12 -0
- data/lib/webrat/selenium/location_strategy_javascript/label.js +16 -0
- data/lib/webrat/selenium/location_strategy_javascript/webrat.js +5 -0
- data/lib/webrat/selenium/location_strategy_javascript/webratlink.js +9 -0
- data/lib/webrat/selenium/location_strategy_javascript/webratlinkwithin.js +15 -0
- data/lib/webrat/selenium/location_strategy_javascript/webratselectwithoption.js +5 -0
- data/lib/webrat/selenium/selenium_extensions.js +6 -0
- data/lib/webrat/selenium/selenium_session.rb +137 -0
- data/lib/webrat/sinatra.rb +19 -0
- metadata +66 -52
- data/Manifest.txt +0 -20
- data/lib/webrat/rails_extensions.rb +0 -27
- data/lib/webrat/session.rb +0 -523
- data/test/checks_test.rb +0 -121
- data/test/chooses_test.rb +0 -74
- data/test/clicks_button_test.rb +0 -308
- data/test/clicks_link_test.rb +0 -193
- data/test/fills_in_test.rb +0 -139
- data/test/helper.rb +0 -21
- data/test/reloads_test.rb +0 -26
- data/test/selects_test.rb +0 -93
- data/test/visits_test.rb +0 -31
data/History.txt
CHANGED
@@ -1,3 +1,65 @@
|
|
1
|
+
== 0.3.0 / 2008-11-07
|
2
|
+
|
3
|
+
* Major enhancements
|
4
|
+
|
5
|
+
* Added Merb support (Gwyn Morfey, Jeremy Burks, Rob Kaufman, Yehuda Katz)
|
6
|
+
* Added experimental Selenium support (Luke Melia)
|
7
|
+
* Add have_selector, have_xpath, have_tag and contain matchers from Merb
|
8
|
+
* Switch from Hpricot to Nokogiri for XML parsing (thanks, Aaron Patterson)
|
9
|
+
|
10
|
+
* Minor enhancements
|
11
|
+
|
12
|
+
* Added #within for manipulating the current page within a selector scope
|
13
|
+
* Add support for file fields via #attaches_file method (Rails only at the moment) (Kyle Hargraves)
|
14
|
+
* Add support for simulating SSL requests (Luke Melia)
|
15
|
+
* Added #basic_auth(user, pass) to support HTTP Basic Auth (Aslak Hellesøy)
|
16
|
+
* Added support for Sinatra and Rack (Aslak Hellesøy)
|
17
|
+
* Rename visits to visit, fills_in to fill_in, etc.
|
18
|
+
* Add #field_labeled for looking up form fields by label (David Chelimsky)
|
19
|
+
* Add #field_named and #field_with_id locators
|
20
|
+
* Don't depend on hoe anymore
|
21
|
+
* Return responses after sending requests
|
22
|
+
* Allow clicking links and buttons by a regular expression in Selenium (Luke Melia)
|
23
|
+
* Allow clicking links by a regular expression
|
24
|
+
* Add #http_accept for including MIME type HTTP "Accept" headers (Ryan Briones)
|
25
|
+
* Add #header to support inclusion of custom HTTP headers (Ryan Briones)
|
26
|
+
* Consider response codes 200-499 as successful enough to not raise a Webrat error (David Leal)
|
27
|
+
* Add Webrat.root method for cross-framework support (Krzysztof Zylawy)
|
28
|
+
* Add support for clicking areas of an image map (Alex Lang)
|
29
|
+
* Support relative links, including href="?foo=bar" (Kyle Hargraves)
|
30
|
+
* Separated Rails-specific code from the Webrat core to make it easier to use Webrat with other environments
|
31
|
+
* Alias visits as visit, clicks_link as click_link, etc. for better readability
|
32
|
+
* Raise error when trying to interact with a disabled form element (Luke Melia)
|
33
|
+
* Don't send disabled form elements to the server (Nicholas A. Evans)
|
34
|
+
* Display response body when the page load is not successful (David Leal)
|
35
|
+
* CGI escape form field values (Miha Filej)
|
36
|
+
* Add support for redirect_to :back by sending HTTP_REFERER headers (Hendrik Volkmer)
|
37
|
+
* Expose current DOM (as an Hpricot object) as #current_dom
|
38
|
+
* Add support for disabling JavaScript when clicking a link to enable testing of both JS
|
39
|
+
and non-JS implementations (Luke Melia and Bryan Helmkamp)
|
40
|
+
* Support  's as spaces in matching link text (Luke Melia)
|
41
|
+
* Support button elements (Nick Sieger)
|
42
|
+
* Support matching select options by regexp (Kyle Hargraves)
|
43
|
+
* save_and_open_page rewrites css and image references to provide a friendlier debugging experience (Luke Melia)
|
44
|
+
* Added support for matching alt attributes in fields (primarly for clicks_button) (Aaron Quint)
|
45
|
+
* Support '&' in submitted values (Kyle Hargraves)
|
46
|
+
* Support clicking links by title (Dan Barry)
|
47
|
+
* Added missing spec for clicking image buttons (Tim Harper)
|
48
|
+
* Switched tests to specs, and from Mocha to RSpec's mocking library
|
49
|
+
* Add support to click_button for IDs (Gwyn Morfey)
|
50
|
+
* Miscellaneous core refactorings (Jan Suchal)
|
51
|
+
|
52
|
+
* Bug fixes
|
53
|
+
|
54
|
+
* Fix initialization of WWW::Mechanize (Derek Kastner)
|
55
|
+
* Don't open blank pages in the browser (Kyle Hargraves)
|
56
|
+
* Support radio buttons with multiple labels (Dan Barry)
|
57
|
+
* Fix load order bug on some platforms (Ismael Celis)
|
58
|
+
* Fix bug with empty select list option (Kyle Hargraves)
|
59
|
+
* Fix regression of not sending default values in password fields
|
60
|
+
* Don't explode if encountering inputs with no type attribute (assume text)
|
61
|
+
* Fix bug where choosing a radio button in a series with a default submitted the incorrect field value (Luke Melia)
|
62
|
+
|
1
63
|
== 0.2.0 / 2008-04-04
|
2
64
|
|
3
65
|
* 4 Major enhancements
|
@@ -6,29 +68,29 @@
|
|
6
68
|
* Add radio button support via #chooses method
|
7
69
|
* Add basic support for Rails-generated JavaScript link tags
|
8
70
|
* Add support for checkboxes (Patches from Kyle Hargraves and Jarkko Laine)
|
9
|
-
* Add support for textarea fields (
|
71
|
+
* Add support for textarea fields (Sacha Schlegel)
|
10
72
|
|
11
73
|
* 8 Minor enhancements
|
12
74
|
|
13
|
-
* Added reloads method to reload the page (
|
14
|
-
* Prevent making a request if clicking on local anchor link (
|
75
|
+
* Added reloads method to reload the page (Kamal Fariz Mahyuddi)
|
76
|
+
* Prevent making a request if clicking on local anchor link (Kamal Fariz Mahyuddi)
|
15
77
|
* Added clicks_link_within(selector, link_text), allowing restricting link search
|
16
|
-
to within a given css selector (
|
17
|
-
* Allow specifying the input name/label when doing a select (
|
18
|
-
* Raise a specific exception if the developer tries to manipulate form elements before loading a page (
|
19
|
-
* Add support for alternate POST, PUT and DELETE link clicking (
|
20
|
-
* Change clicks_link to find the shortest matching link (
|
78
|
+
to within a given css selector (Luke Melia)
|
79
|
+
* Allow specifying the input name/label when doing a select (David Chelimsky)
|
80
|
+
* Raise a specific exception if the developer tries to manipulate form elements before loading a page (James Deville)
|
81
|
+
* Add support for alternate POST, PUT and DELETE link clicking (Kyle Hargraves)
|
82
|
+
* Change clicks_link to find the shortest matching link (Luke Melia)
|
21
83
|
* Improve matching for labels in potentially ambiguous cases
|
22
84
|
|
23
85
|
* 7 Bug fixes
|
24
86
|
|
25
|
-
* Fix incorrect serializing of collection inputs, i.e. name contains [] (
|
26
|
-
* Serialize empty text field values just like browsers (
|
27
|
-
* Quick fix to avoid @dom not initialized warnings (
|
28
|
-
* Docfix: bad reference to #select method in README (
|
87
|
+
* Fix incorrect serializing of collection inputs, i.e. name contains [] (Kamal Fariz Mahyuddi)
|
88
|
+
* Serialize empty text field values just like browsers (Kamal Fariz Mahyuddi)
|
89
|
+
* Quick fix to avoid @dom not initialized warnings (Kamal Fariz Mahyuddi)
|
90
|
+
* Docfix: bad reference to #select method in README (Luke Melia)
|
29
91
|
* Ensure Rails-style checkboxes work properly (checkboxes followed by a hidden input with the same name)
|
30
|
-
* Fix Edge Rails (a.k.a. 2.0 RC) compatibility (
|
31
|
-
* Support param hashes nested more than one level (
|
92
|
+
* Fix Edge Rails (a.k.a. 2.0 RC) compatibility (David Chelimsky)
|
93
|
+
* Support param hashes nested more than one level (David Chelimsky)
|
32
94
|
|
33
95
|
== 0.1.0 / 2007-11-28
|
34
96
|
|
data/README.txt
CHANGED
@@ -1,14 +1,12 @@
|
|
1
|
-
|
1
|
+
=== Webrat
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
- [Code on GitHub](http://github.com/brynary/webrat)
|
4
|
+
- [Tickets on Lighthouse](http://webrat.lighthouseapp.com/)
|
5
5
|
|
6
|
-
|
7
|
-
* mailto:seth@mojodna.net
|
6
|
+
=== Description
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
Webrat lets you quickly write robust and thorough acceptance tests for a Ruby
|
8
|
+
Webrat (_Ruby Acceptance Testing for Web applications_)
|
9
|
+
lets you quickly write robust and thorough acceptance tests for a Ruby
|
12
10
|
web application. By leveraging the DOM, it can run tests similarly to an
|
13
11
|
in-browser testing solution without the associated performance hit (and
|
14
12
|
browser dependency). The result is tests that are less fragile and more
|
@@ -19,20 +17,20 @@ Selenium, the primary consideration should be how much JavaScript the
|
|
19
17
|
application uses. In-browser testing is currently the only way to test JS, and
|
20
18
|
that may make it a requirement for your project. If JavaScript is not central
|
21
19
|
to your application, Webrat is a simpler, effective solution that will let you
|
22
|
-
run your tests much faster and more frequently.
|
20
|
+
run your tests much faster and more frequently.
|
23
21
|
|
24
|
-
Initial development was sponsored by EastMedia
|
22
|
+
Initial development was sponsored by [EastMedia](http://www.eastmedia.com).
|
25
23
|
|
26
|
-
|
24
|
+
=== Synopsis
|
27
25
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
26
|
+
def test_sign_up
|
27
|
+
visit "/"
|
28
|
+
click_link "Sign up"
|
29
|
+
fill_in "Email", :with => "good@example.com"
|
30
|
+
select "Free account"
|
31
|
+
click_button "Register"
|
32
|
+
...
|
33
|
+
end
|
36
34
|
|
37
35
|
Behind the scenes, this will perform the following work:
|
38
36
|
|
@@ -50,37 +48,43 @@ Behind the scenes, this will perform the following work:
|
|
50
48
|
Take special note of the things _not_ specified in that test, that might cause
|
51
49
|
tests to break unnecessarily as your application evolves:
|
52
50
|
|
53
|
-
|
51
|
+
- The input field IDs or names (e.g. "user_email" or "user[email]"), which
|
54
52
|
could change if you rename a model
|
55
|
-
|
53
|
+
- The ID of the form element (Webrat can do a good job of guessing, even if
|
56
54
|
there are multiple forms on the page.)
|
57
|
-
|
58
|
-
|
55
|
+
- The URLs of links followed
|
56
|
+
- The URL the form submission should be sent to, which could change if you
|
59
57
|
adjust your routes or controllers
|
60
|
-
|
58
|
+
- The HTTP method for the login request
|
59
|
+
|
60
|
+
A test written with Webrat can handle these changes to these without any modifications.
|
61
|
+
|
62
|
+
=== Merb
|
63
|
+
To avoid losing sessions, you need this in environments/test.rb:
|
61
64
|
|
62
|
-
|
65
|
+
Merb::Config.use do |c|
|
66
|
+
c[:session_store] = 'memory'
|
67
|
+
end
|
63
68
|
|
64
|
-
|
69
|
+
=== Install
|
65
70
|
|
66
|
-
|
67
|
-
* Hpricot >= 0.6
|
68
|
-
* Rails integration tests in Test::Unit _or_
|
69
|
-
* RSpec stories (using an RSpec version >= revision 2997)
|
71
|
+
To install the latest release:
|
70
72
|
|
71
|
-
|
73
|
+
sudo gem install webrat
|
72
74
|
|
73
75
|
In your stories/helper.rb:
|
74
76
|
|
75
|
-
|
77
|
+
require "webrat"
|
76
78
|
|
77
79
|
You could also unpack the gem into vendor/plugins.
|
78
80
|
|
79
|
-
|
81
|
+
=== Authors
|
80
82
|
|
81
|
-
|
83
|
+
- Maintained by [Bryan Helmkamp](mailto:bryan@brynary.com)
|
84
|
+
- Original code written by [Seth Fitzsimmons](mailto:seth@mojodna.net)
|
85
|
+
- Many other contributors. See attributions in History.txt
|
82
86
|
|
83
|
-
|
87
|
+
=== License
|
84
88
|
|
85
89
|
Copyright (c) 2007 Bryan Helmkamp, Seth Fitzsimmons.
|
86
|
-
See MIT-LICENSE in this directory.
|
90
|
+
See MIT-LICENSE.txt in this directory.
|
data/Rakefile
CHANGED
@@ -1,27 +1,89 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require
|
2
|
+
require "rake/gempackagetask"
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
require "rake/clean"
|
5
|
+
require 'spec'
|
6
|
+
require 'spec/rake/spectask'
|
7
|
+
require 'spec/rake/verify_rcov'
|
3
8
|
require './lib/webrat.rb'
|
4
9
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
10
|
+
##############################################################################
|
11
|
+
# Package && release
|
12
|
+
##############################################################################
|
13
|
+
spec = Gem::Specification.new do |s|
|
14
|
+
s.name = "webrat"
|
15
|
+
s.version = Webrat::VERSION
|
16
|
+
s.platform = Gem::Platform::RUBY
|
17
|
+
s.author = "Bryan Helmkamp"
|
18
|
+
s.email = "bryan" + "@" + "brynary.com"
|
19
|
+
s.homepage = "http://github.com/brynary/webrat"
|
20
|
+
s.summary = "Webrat. Ruby Acceptance Testing for Web applications"
|
21
|
+
s.bindir = "bin"
|
22
|
+
s.description = s.summary
|
23
|
+
s.require_path = "lib"
|
24
|
+
s.files = %w(History.txt init.rb install.rb MIT-LICENSE.txt README.txt Rakefile TODO.txt) + Dir["lib/**/*"]
|
25
|
+
|
26
|
+
# rdoc
|
27
|
+
s.has_rdoc = true
|
28
|
+
s.extra_rdoc_files = %w(README.txt MIT-LICENSE.txt)
|
29
|
+
|
30
|
+
# Dependencies
|
31
|
+
s.add_dependency "nokogiri", ">= 1.0.3"
|
32
|
+
end
|
33
|
+
|
34
|
+
Rake::GemPackageTask.new(spec) do |package|
|
35
|
+
package.gem_spec = spec
|
36
|
+
end
|
37
|
+
|
38
|
+
desc 'Show information about the gem.'
|
39
|
+
task :debug_gem do
|
40
|
+
puts spec.to_ruby
|
22
41
|
end
|
23
42
|
|
43
|
+
CLEAN.include ["pkg", "*.gem", "doc", "ri", "coverage"]
|
44
|
+
|
24
45
|
desc "Upload rdoc to brynary.com"
|
25
46
|
task :publish_rdoc => :docs do
|
26
47
|
sh "scp -r doc/ brynary.com:/apps/uploads/webrat"
|
48
|
+
end
|
49
|
+
|
50
|
+
desc "Run API and Core specs"
|
51
|
+
Spec::Rake::SpecTask.new do |t|
|
52
|
+
t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
|
53
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
54
|
+
end
|
55
|
+
|
56
|
+
desc "Run all specs in spec directory with RCov"
|
57
|
+
Spec::Rake::SpecTask.new(:rcov) do |t|
|
58
|
+
t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
|
59
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
60
|
+
t.rcov = true
|
61
|
+
t.rcov_opts = lambda do
|
62
|
+
IO.readlines(File.dirname(__FILE__) + "/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
RCov::VerifyTask.new(:verify_rcov => :rcov) do |t|
|
67
|
+
t.threshold = 96.2 # Make sure you have rcov 0.7 or higher!
|
68
|
+
end
|
69
|
+
|
70
|
+
task :default do
|
71
|
+
Rake::Task["verify_rcov"].invoke
|
72
|
+
end
|
73
|
+
|
74
|
+
desc 'Install the package as a gem.'
|
75
|
+
task :install_gem => [:clean, :package] do
|
76
|
+
gem = Dir['pkg/*.gem'].first
|
77
|
+
sh "sudo gem install --local #{gem}"
|
78
|
+
end
|
79
|
+
|
80
|
+
Rake::RDocTask.new(:docs) do |rd|
|
81
|
+
rd.main = "README.txt"
|
82
|
+
rd.rdoc_dir = 'doc'
|
83
|
+
files = spec.files.grep(/^(lib|bin|ext)|txt$/)
|
84
|
+
files -= ["TODO.txt"]
|
85
|
+
files -= files.grep(/\.js$/)
|
86
|
+
rd.rdoc_files = files.uniq
|
87
|
+
title = "webrat-#{Webrat::VERSION} Documentation"
|
88
|
+
rd.options << "-t #{title}"
|
27
89
|
end
|
data/TODO.txt
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
Run tests in separate processes to eliminate constant-level dependencies
|
2
|
+
Add rake tasks for selenium runs
|
3
|
+
Add tests for selenium
|
4
|
+
Add tests for locator strategies
|
5
|
+
Use Webrat::Methods for Rails integration
|
6
|
+
Get file uploads workign with merb
|
7
|
+
Fix #within scoping for forms that exist outside the scope
|
3
8
|
Make current_url work with redirections
|
4
|
-
|
9
|
+
Track the current form based on the location of the last manipulated input, use this as a default for click_button
|
10
|
+
Verify SSL support in Rails and Merb
|
data/init.rb
CHANGED
data/lib/webrat.rb
CHANGED
@@ -1,6 +1,31 @@
|
|
1
|
-
require
|
2
|
-
require File.join(File.dirname(__FILE__), "webrat", "session")
|
1
|
+
require "rubygems"
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__))) unless $LOAD_PATH.include?(File.expand_path(File.dirname(__FILE__)))
|
4
|
+
|
5
|
+
module Webrat
|
6
|
+
VERSION = '0.3.0'
|
7
|
+
|
8
|
+
def self.root #:nodoc:
|
9
|
+
defined?(RAILS_ROOT) ? RAILS_ROOT : Merb.root
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# We need Nokogiri's CSS to XPath support, even if using REXML
|
14
|
+
require "nokogiri/css"
|
15
|
+
|
16
|
+
# Require nokogiri and fall back on rexml
|
17
|
+
begin
|
18
|
+
require "nokogiri"
|
19
|
+
require "webrat/core/nokogiri"
|
20
|
+
rescue LoadError => e
|
21
|
+
require "rexml/document"
|
22
|
+
warn("Standard REXML library is slow. Please consider installing nokogiri.\nUse \"sudo gem install nokogiri\"")
|
23
|
+
end
|
24
|
+
|
25
|
+
require "webrat/core"
|
26
|
+
|
27
|
+
# TODO: This is probably not a good idea.
|
28
|
+
# Probably better for webrat users to require "webrat/rails" etc. directly
|
29
|
+
if defined?(RAILS_ENV)
|
30
|
+
require "webrat/rails"
|
31
|
+
end
|
data/lib/webrat/core.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require "webrat/core/nokogiri"
|
2
|
+
require "webrat/core/logging"
|
3
|
+
require "webrat/core/flunk"
|
4
|
+
require "webrat/core/form"
|
5
|
+
require "webrat/core/scope"
|
6
|
+
require "webrat/core/link"
|
7
|
+
require "webrat/core/area"
|
8
|
+
require "webrat/core/label"
|
9
|
+
require "webrat/core/select_option"
|
10
|
+
require "webrat/core/session"
|
11
|
+
require "webrat/core/methods"
|
12
|
+
require "webrat/core/matchers"
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Webrat
|
2
|
+
class Area #:nodoc:
|
3
|
+
|
4
|
+
def initialize(session, element)
|
5
|
+
@session = session
|
6
|
+
@element = element
|
7
|
+
end
|
8
|
+
|
9
|
+
def click(method = nil, options = {})
|
10
|
+
@session.request_page(absolute_href, :get, {})
|
11
|
+
end
|
12
|
+
|
13
|
+
def matches_text?(id_or_title)
|
14
|
+
matcher = /#{Regexp.escape(id_or_title.to_s)}/i
|
15
|
+
title =~ matcher || id =~ matcher
|
16
|
+
end
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
def href
|
21
|
+
@element["href"]
|
22
|
+
end
|
23
|
+
|
24
|
+
def title
|
25
|
+
@element["title"]
|
26
|
+
end
|
27
|
+
|
28
|
+
def id
|
29
|
+
@element["id"]
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
def absolute_href
|
34
|
+
if href =~ /^\?/
|
35
|
+
"#{@session.current_url}#{href}"
|
36
|
+
elsif href !~ %r{^https?://[\w|.]+(/.*)} && (href !~ /^\//)
|
37
|
+
"#{@session.current_url}/#{href}"
|
38
|
+
else
|
39
|
+
href
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|