rwebspec-webdriver 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -0
- data/Rakefile +1 -1
- data/lib/rwebspec-webdriver.rb +1 -1
- data/lib/rwebspec-webdriver/driver.rb +2 -2
- data/lib/rwebspec-webdriver/load_test_helper.rb +5 -70
- data/lib/rwebspec-webdriver/web_browser.rb +27 -32
- metadata +16 -7
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
@@ -69,7 +69,7 @@ end
|
|
69
69
|
spec = Gem::Specification.new do |s|
|
70
70
|
s.platform= Gem::Platform::RUBY
|
71
71
|
s.name = "rwebspec-webdriver"
|
72
|
-
s.version = "0.3.
|
72
|
+
s.version = "0.3.4"
|
73
73
|
s.summary = "Executable functional specification for web applications in RSpec syntax and Selenium-WebDriver"
|
74
74
|
# s.description = ""
|
75
75
|
|
data/lib/rwebspec-webdriver.rb
CHANGED
@@ -49,7 +49,7 @@ module RWebSpec
|
|
49
49
|
:highlight_colour => 'yellow',
|
50
50
|
:close_others => true,
|
51
51
|
:start_new => true, # start a new browser always
|
52
|
-
|
52
|
+
:go => true }
|
53
53
|
|
54
54
|
options = default_options.merge options
|
55
55
|
|
@@ -68,7 +68,7 @@ module RWebSpec
|
|
68
68
|
uri_base = "#{uri.scheme}://#{uri.host}:#{uri.port}"
|
69
69
|
end
|
70
70
|
|
71
|
-
if options[:start_new]
|
71
|
+
if options[:start_new]
|
72
72
|
# puts "[DEBUG] [SeleniumBrowser] creating a new browser"
|
73
73
|
@web_browser = WebBrowser.new(uri_base, nil, options)
|
74
74
|
# puts "[DEBUG] [SeleniumBrowser] browser: #{@web_browser.inspect}"
|
@@ -4,82 +4,17 @@ module RWebSpec
|
|
4
4
|
module LoadTestHelper
|
5
5
|
|
6
6
|
include RWebSpec::WebDriver::Utils
|
7
|
+
include RWebSpec::WebDriver::Driver
|
7
8
|
include RWebSpec::WebDriver::Assert
|
8
9
|
|
9
10
|
MAX_VU = 1000
|
10
11
|
|
11
12
|
# only support firefox or Celerity
|
12
13
|
def open_browser(base_url, options = {})
|
13
|
-
|
14
|
-
|
15
|
-
options
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
# maybe attach_browser
|
20
|
-
|
21
|
-
# Does not provide real function, other than make enhancing test syntax
|
22
|
-
#
|
23
|
-
# Example:
|
24
|
-
# allow { click_button('Register') }
|
25
|
-
def allow(&block)
|
26
|
-
yield
|
27
|
-
end
|
28
|
-
alias shall_allow allow
|
29
|
-
alias allowing allow
|
30
|
-
|
31
|
-
# try operation, ignore if errors occur
|
32
|
-
#
|
33
|
-
# Example:
|
34
|
-
# failsafe { click_link("Logout") } # try logout, but it still OK if not being able to (already logout))
|
35
|
-
def failsafe(&block)
|
36
|
-
begin
|
37
|
-
yield
|
38
|
-
rescue =>e
|
39
|
-
end
|
40
|
-
end
|
41
|
-
alias fail_safe failsafe
|
42
|
-
|
43
|
-
# Try the operation up to specified timeout (in seconds), and sleep given interval (in seconds).
|
44
|
-
# Error will be ignored until timeout
|
45
|
-
# Example
|
46
|
-
# try { click_link('waiting')}
|
47
|
-
# try(10, 2) { click_button('Search' } # try to click the 'Search' button upto 10 seconds, try every 2 seconds
|
48
|
-
# try { click_button('Search' }
|
49
|
-
def try(timeout = $testwise_polling_timeout, polling_interval = $testwise_polling_interval || 1, &block)
|
50
|
-
start_time = Time.now
|
51
|
-
|
52
|
-
last_error = nil
|
53
|
-
until (duration = Time.now - start_time) > timeout
|
54
|
-
begin
|
55
|
-
return if yield
|
56
|
-
last_error = nil
|
57
|
-
rescue => e
|
58
|
-
last_error = e
|
59
|
-
end
|
60
|
-
sleep polling_interval
|
61
|
-
end
|
62
|
-
|
63
|
-
raise "Timeout after #{duration.to_i} seconds with error: #{last_error}." if last_error
|
64
|
-
raise "Timeout after #{duration.to_i} seconds."
|
65
|
-
end
|
66
|
-
alias try_upto try
|
67
|
-
|
68
|
-
##
|
69
|
-
# Convert :first to 1, :second to 2, and so on...
|
70
|
-
def symbol_to_sequence(symb)
|
71
|
-
value = { :zero => 0,
|
72
|
-
:first => 1,
|
73
|
-
:second => 2,
|
74
|
-
:third => 3,
|
75
|
-
:fourth => 4,
|
76
|
-
:fifth => 5,
|
77
|
-
:sixth => 6,
|
78
|
-
:seventh => 7,
|
79
|
-
:eighth => 8,
|
80
|
-
:ninth => 9,
|
81
|
-
:tenth => 10 }[symb]
|
82
|
-
return value || symb.to_i
|
14
|
+
options[:browser] ||= (ENV['LOADWISE_PREVIEW'] || $LOADWISE_PREVIEW)
|
15
|
+
default_options = {:browser => :htmlunit , :go => true}
|
16
|
+
options = default_options.merge(options)
|
17
|
+
@web_browser = WebBrowser.new(base_url, nil, options)
|
83
18
|
end
|
84
19
|
|
85
20
|
# monitor current execution using
|
@@ -29,30 +29,17 @@ module RWebSpec
|
|
29
29
|
}
|
30
30
|
options = default_options.merge options
|
31
31
|
@context = Context.new base_url if base_url
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
initialize_celerity_browser(base_url, options)
|
36
|
-
when /mswin|windows|mingw/i
|
37
|
-
options[:browser] ||= "ie"
|
38
|
-
case options[:browser].to_s.downcase
|
32
|
+
|
33
|
+
options[:browser] ||= "ie" if RUBY_PLATFORM =~ /mingw/
|
34
|
+
case options[:browser].to_s.downcase
|
39
35
|
when "firefox"
|
40
36
|
initialize_firefox_browser(existing_browser, base_url, options)
|
41
37
|
when "chrome"
|
42
38
|
initialize_chrome_browser(existing_browser, base_url, options)
|
43
39
|
when "ie"
|
44
40
|
initialize_ie_browser(existing_browser, options)
|
45
|
-
|
46
|
-
|
47
|
-
else
|
48
|
-
puts "Ruby Linux or Mac platform: firefox"
|
49
|
-
options[:browser] ||= "firefox"
|
50
|
-
case options[:browser].to_s
|
51
|
-
when "firefox"
|
52
|
-
initialize_firefox_browser(existing_browser, base_url, options)
|
53
|
-
when "chrome"
|
54
|
-
initialize_chrome_browser(existing_browser, base_url, options)
|
55
|
-
end
|
41
|
+
when "htmlunit"
|
42
|
+
initialize_htmlunit_browser(base_url, options)
|
56
43
|
end
|
57
44
|
end
|
58
45
|
|
@@ -77,11 +64,16 @@ module RWebSpec
|
|
77
64
|
end
|
78
65
|
|
79
66
|
def initialize_htmlunit_browser(base_url, options)
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
67
|
+
puts "XXXXX start HtmlUnit..."
|
68
|
+
require 'json'
|
69
|
+
caps = Selenium::WebDriver::Remote::Capabilities.htmlunit(:javascript_enabled => false)
|
70
|
+
client = Selenium::WebDriver::Remote::Http::Default.new
|
71
|
+
# client.proxy = Selenium::WebDriver::Proxy.new(:http => "web-proxy.qdot.qld.gov.au:3128")
|
72
|
+
|
73
|
+
@browser = Selenium::WebDriver.for(:remote, :http_client => client , :desired_capabilities => caps)
|
74
|
+
if options[:go]
|
75
|
+
@browser.navigate.to(base_url)
|
76
|
+
end
|
85
77
|
end
|
86
78
|
|
87
79
|
def initialize_ie_browser(existing_browser, options)
|
@@ -284,12 +276,15 @@ module RWebSpec
|
|
284
276
|
@context = Context.new base_url
|
285
277
|
end
|
286
278
|
|
279
|
+
def driver
|
280
|
+
@browser
|
281
|
+
end
|
282
|
+
|
287
283
|
def underlying_browser
|
288
284
|
@browser
|
289
285
|
end
|
290
286
|
|
291
287
|
def is_ie?
|
292
|
-
puts @browser.browser.to_s
|
293
288
|
@browser.browser.to_s == "ie"
|
294
289
|
end
|
295
290
|
|
@@ -307,11 +302,7 @@ module RWebSpec
|
|
307
302
|
|
308
303
|
#TODO determine browser type, check FireWatir support or not
|
309
304
|
def self.close_all_browsers
|
310
|
-
|
311
|
-
Watir::IE.close_all
|
312
|
-
else
|
313
|
-
# raise "not supported in FireFox yet."
|
314
|
-
end
|
305
|
+
raise "not implemented"
|
315
306
|
end
|
316
307
|
|
317
308
|
def full_url(relative_url)
|
@@ -524,10 +515,14 @@ module RWebSpec
|
|
524
515
|
|
525
516
|
options = select_box.find_elements(:tag_name, "option")
|
526
517
|
options.each do |opt|
|
527
|
-
|
528
|
-
|
518
|
+
opt.click
|
519
|
+
if text == opt.text
|
520
|
+
opt.click
|
521
|
+
return true
|
522
|
+
end
|
529
523
|
end
|
530
|
-
|
524
|
+
|
525
|
+
raise "no option with text '#{text}' found for select list name = '#{selectName}"
|
531
526
|
end
|
532
527
|
|
533
528
|
# submit first submit button
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rwebspec-webdriver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
9
|
+
- 4
|
10
|
+
version: 0.3.4
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Zhimin Zhan
|
@@ -14,16 +15,17 @@ autorequire: rwebspec-webdriver
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2012-
|
18
|
-
default_executable:
|
18
|
+
date: 2012-03-11 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rspec
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
24
25
|
requirements:
|
25
26
|
- - "="
|
26
27
|
- !ruby/object:Gem::Version
|
28
|
+
hash: 11
|
27
29
|
segments:
|
28
30
|
- 1
|
29
31
|
- 1
|
@@ -35,9 +37,11 @@ dependencies:
|
|
35
37
|
name: selenium-webdriver
|
36
38
|
prerelease: false
|
37
39
|
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
38
41
|
requirements:
|
39
42
|
- - ">="
|
40
43
|
- !ruby/object:Gem::Version
|
44
|
+
hash: 13
|
41
45
|
segments:
|
42
46
|
- 2
|
43
47
|
- 0
|
@@ -49,9 +53,11 @@ dependencies:
|
|
49
53
|
name: sanitize
|
50
54
|
prerelease: false
|
51
55
|
requirement: &id003 !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
52
57
|
requirements:
|
53
58
|
- - ">="
|
54
59
|
- !ruby/object:Gem::Version
|
60
|
+
hash: 15
|
55
61
|
segments:
|
56
62
|
- 2
|
57
63
|
- 0
|
@@ -93,7 +99,6 @@ files:
|
|
93
99
|
- lib/rwebspec-webdriver.rb
|
94
100
|
- lib/webdriver_extensions.rb
|
95
101
|
- lib/window_script_extensions.rb
|
96
|
-
has_rdoc: true
|
97
102
|
homepage: http://github.com/zhimin/rwebspec-webdriver/tree/master
|
98
103
|
licenses: []
|
99
104
|
|
@@ -103,23 +108,27 @@ rdoc_options: []
|
|
103
108
|
require_paths:
|
104
109
|
- lib
|
105
110
|
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
106
112
|
requirements:
|
107
113
|
- - ">="
|
108
114
|
- !ruby/object:Gem::Version
|
115
|
+
hash: 3
|
109
116
|
segments:
|
110
117
|
- 0
|
111
118
|
version: "0"
|
112
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
none: false
|
113
121
|
requirements:
|
114
122
|
- - ">="
|
115
123
|
- !ruby/object:Gem::Version
|
124
|
+
hash: 3
|
116
125
|
segments:
|
117
126
|
- 0
|
118
127
|
version: "0"
|
119
128
|
requirements:
|
120
129
|
- none
|
121
130
|
rubyforge_project: rwebspec-webdriver
|
122
|
-
rubygems_version: 1.
|
131
|
+
rubygems_version: 1.8.15
|
123
132
|
signing_key:
|
124
133
|
specification_version: 3
|
125
134
|
summary: Executable functional specification for web applications in RSpec syntax and Selenium-WebDriver
|