jwilger-webrat 0.4.4.2 → 0.4.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -1
- data/lib/webrat.rb +1 -1
- data/lib/webrat/core/configuration.rb +5 -1
- data/lib/webrat/core/elements/field.rb +2 -0
- data/lib/webrat/core/methods.rb +2 -4
- data/lib/webrat/core/session.rb +2 -1
- data/lib/webrat/selenium.rb +0 -1
- data/lib/webrat/selenium/location_strategy_javascript/button.js +14 -7
- data/lib/webrat/selenium/location_strategy_javascript/webratlink.js +3 -1
- data/lib/webrat/selenium/selenium_session.rb +9 -8
- data/lib/webrat/selenium/silence_stream.rb +12 -8
- metadata +2 -2
data/History.txt
CHANGED
@@ -11,7 +11,11 @@
|
|
11
11
|
* Filled in tests on click link lh 195 (diabolo)
|
12
12
|
* Added current_url to selenium session lh 215 (Luke Amdor)
|
13
13
|
* Added silence spec to selenium lh 238 (Martin Gamsjaeger aka snusnu)
|
14
|
-
* Added ability to configure the browser startup timeout for selenium lh 242 (Mike Gaffney)
|
14
|
+
* Added ability to configure the browser startup timeout for selenium lh 242 (Mike Gaffney, Mark Dodwell)
|
15
|
+
* Added delegation for field_named lh194 (pivotal labs)
|
16
|
+
* Added fix to keep from escaping field values in mechanize mode lh256 (jish)
|
17
|
+
* Adding fixes for click button/link and made the integration specs pass for the same in selenium lh254 (Ldiehl, Matthias Marschall)
|
18
|
+
* Adding clicking link by id in selenium mode lh221 (larrytheliquid)
|
15
19
|
|
16
20
|
== 0.4.4 / 2009-04-06
|
17
21
|
|
data/lib/webrat.rb
CHANGED
@@ -29,7 +29,7 @@ module Webrat
|
|
29
29
|
# Save and open pages with error status codes (500-599) in a browser? Defualts to true.
|
30
30
|
attr_writer :open_error_files
|
31
31
|
|
32
|
-
# Which rails environment should the selenium tests be run in? Defaults to
|
32
|
+
# Which rails environment should the selenium tests be run in? Defaults to test.
|
33
33
|
attr_accessor :application_environment
|
34
34
|
webrat_deprecate :selenium_environment, :application_environment
|
35
35
|
webrat_deprecate :selenium_environment=, :application_environment=
|
@@ -57,6 +57,9 @@ module Webrat
|
|
57
57
|
# Set the timeout for waiting for the browser process to start
|
58
58
|
attr_accessor :selenium_browser_startup_timeout
|
59
59
|
|
60
|
+
# Set the timeout for waiting for actions within the browser
|
61
|
+
attr_accessor :browser_action_timeout
|
62
|
+
|
60
63
|
# How many redirects to the same URL should be halted as an infinite redirect
|
61
64
|
# loop? Defaults to 10
|
62
65
|
attr_accessor :infinite_redirect_limit
|
@@ -72,6 +75,7 @@ module Webrat
|
|
72
75
|
self.infinite_redirect_limit = 10
|
73
76
|
self.selenium_browser_key = '*firefox'
|
74
77
|
self.selenium_browser_startup_timeout = 5
|
78
|
+
self.browser_action_timeout = 5
|
75
79
|
end
|
76
80
|
|
77
81
|
def parse_with_nokogiri? #:nodoc:
|
data/lib/webrat/core/methods.rb
CHANGED
data/lib/webrat/core/session.rb
CHANGED
@@ -255,6 +255,7 @@ For example:
|
|
255
255
|
def_delegators :current_scope, :field_by_xpath
|
256
256
|
def_delegators :current_scope, :field_with_id
|
257
257
|
def_delegators :current_scope, :select_option
|
258
|
+
def_delegators :current_scope, :field_named
|
258
259
|
|
259
260
|
private
|
260
261
|
|
@@ -271,7 +272,7 @@ For example:
|
|
271
272
|
end
|
272
273
|
|
273
274
|
def current_host
|
274
|
-
URI.parse(current_url).host || "www.example.com"
|
275
|
+
URI.parse(current_url).host || @custom_headers["Host"] || "www.example.com"
|
275
276
|
end
|
276
277
|
|
277
278
|
def response_location_host
|
data/lib/webrat/selenium.rb
CHANGED
@@ -1,12 +1,19 @@
|
|
1
1
|
if (locator == '*') {
|
2
2
|
return selenium.browserbot.locationStrategies['xpath'].call(this, "//input[@type='submit']", inDocument, inWindow)
|
3
3
|
}
|
4
|
+
var buttons = inDocument.getElementsByTagName('button');
|
4
5
|
var inputs = inDocument.getElementsByTagName('input');
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
var result = $A(inputs).concat($A(buttons)).find(function(candidate){
|
7
|
+
var type = candidate.getAttribute('type');
|
8
|
+
if (type == 'submit' || type == 'image' || type == 'button') {
|
9
|
+
var matches_id = PatternMatcher.matches(locator, candidate.id);
|
10
|
+
var matches_value = PatternMatcher.matches(locator, candidate.value);
|
11
|
+
var matches_html = PatternMatcher.matches(locator, candidate.innerHTML);
|
12
|
+
var matches_alt = PatternMatcher.matches(locator, candidate.alt);
|
13
|
+
if (matches_id || matches_value || matches_html || matches_alt) {
|
14
|
+
return true;
|
15
|
+
}
|
16
|
+
}
|
17
|
+
return false;
|
12
18
|
});
|
19
|
+
return result;
|
@@ -1,6 +1,8 @@
|
|
1
1
|
var links = inDocument.getElementsByTagName('a');
|
2
2
|
var candidateLinks = $A(links).select(function(candidateLink) {
|
3
|
-
|
3
|
+
var textMatched = PatternMatcher.matches(locator, getText(candidateLink));
|
4
|
+
var idMatched = PatternMatcher.matches(locator, candidateLink.id);
|
5
|
+
return textMatched || idMatched;
|
4
6
|
});
|
5
7
|
if (candidateLinks.length == 0) {
|
6
8
|
return null;
|
@@ -34,15 +34,16 @@ module Webrat
|
|
34
34
|
yield
|
35
35
|
end
|
36
36
|
|
37
|
-
def visit(url)
|
37
|
+
def visit(url, timeout = nil)
|
38
38
|
selenium.open(url)
|
39
|
+
selenium.wait_for_page_to_load(timeout)
|
39
40
|
end
|
40
41
|
|
41
42
|
webrat_deprecate :visits, :visit
|
42
43
|
|
43
44
|
def fill_in(field_identifier, options)
|
44
45
|
locator = "webrat=#{Regexp.escape(field_identifier)}"
|
45
|
-
selenium.wait_for_element locator, :timeout_in_seconds =>
|
46
|
+
selenium.wait_for_element locator, :timeout_in_seconds => Webrat.configuration.browser_action_timeout
|
46
47
|
selenium.type(locator, "#{options[:with]}")
|
47
48
|
end
|
48
49
|
|
@@ -69,7 +70,7 @@ module Webrat
|
|
69
70
|
pattern ||= '*'
|
70
71
|
locator = "button=#{pattern}"
|
71
72
|
|
72
|
-
selenium.wait_for_element locator, :timeout_in_seconds =>
|
73
|
+
selenium.wait_for_element locator, :timeout_in_seconds => Webrat.configuration.browser_action_timeout
|
73
74
|
selenium.click locator
|
74
75
|
end
|
75
76
|
|
@@ -78,7 +79,7 @@ module Webrat
|
|
78
79
|
def click_link(link_text_or_regexp, options = {})
|
79
80
|
pattern = adjust_if_regexp(link_text_or_regexp)
|
80
81
|
locator = "webratlink=#{pattern}"
|
81
|
-
selenium.wait_for_element locator, :timeout_in_seconds =>
|
82
|
+
selenium.wait_for_element locator, :timeout_in_seconds => Webrat.configuration.browser_action_timeout
|
82
83
|
selenium.click locator
|
83
84
|
end
|
84
85
|
|
@@ -86,7 +87,7 @@ module Webrat
|
|
86
87
|
|
87
88
|
def click_link_within(selector, link_text, options = {})
|
88
89
|
locator = "webratlinkwithin=#{selector}|#{link_text}"
|
89
|
-
selenium.wait_for_element locator, :timeout_in_seconds =>
|
90
|
+
selenium.wait_for_element locator, :timeout_in_seconds => Webrat.configuration.browser_action_timeout
|
90
91
|
selenium.click locator
|
91
92
|
end
|
92
93
|
|
@@ -101,7 +102,7 @@ module Webrat
|
|
101
102
|
select_locator = "webratselectwithoption=#{option_text}"
|
102
103
|
end
|
103
104
|
|
104
|
-
selenium.wait_for_element select_locator, :timeout_in_seconds =>
|
105
|
+
selenium.wait_for_element select_locator, :timeout_in_seconds => Webrat.configuration.browser_action_timeout
|
105
106
|
selenium.select(select_locator, option_text)
|
106
107
|
end
|
107
108
|
|
@@ -109,7 +110,7 @@ module Webrat
|
|
109
110
|
|
110
111
|
def choose(label_text)
|
111
112
|
locator = "webrat=#{label_text}"
|
112
|
-
selenium.wait_for_element locator, :timeout_in_seconds =>
|
113
|
+
selenium.wait_for_element locator, :timeout_in_seconds => Webrat.configuration.browser_action_timeout
|
113
114
|
selenium.click locator
|
114
115
|
end
|
115
116
|
|
@@ -117,7 +118,7 @@ module Webrat
|
|
117
118
|
|
118
119
|
def check(label_text)
|
119
120
|
locator = "webrat=#{label_text}"
|
120
|
-
selenium.wait_for_element locator, :timeout_in_seconds =>
|
121
|
+
selenium.wait_for_element locator, :timeout_in_seconds => Webrat.configuration.browser_action_timeout
|
121
122
|
selenium.click locator
|
122
123
|
end
|
123
124
|
alias_method :uncheck, :check
|
@@ -1,14 +1,18 @@
|
|
1
1
|
module Webrat
|
2
2
|
module Selenium
|
3
3
|
module SilenceStream
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
stream
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
# active_support already defines silence_stream, no need to do that again if it's already present.
|
5
|
+
# http://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/kernel/reporting.rb
|
6
|
+
unless Kernel.respond_to?(:silence_stream)
|
7
|
+
def silence_stream(stream)
|
8
|
+
old_stream = stream.dup
|
9
|
+
stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
|
10
|
+
stream.sync = true
|
11
|
+
yield
|
12
|
+
ensure
|
13
|
+
stream.reopen(old_stream)
|
14
|
+
end
|
15
|
+
end
|
12
16
|
end
|
13
17
|
end
|
14
18
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jwilger-webrat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.4.
|
4
|
+
version: 0.4.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Helmkamp
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-06-01 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|