rwebspec 1.6.2 → 1.6.4
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/CHANGELOG +8 -0
- data/Rakefile +1 -3
- data/lib/rwebspec/driver.rb +19 -2
- data/lib/rwebspec/matchers/contains_text.rb +2 -2
- data/lib/rwebspec/web_browser.rb +83 -4
- data/lib/rwebspec.rb +1 -1
- metadata +4 -4
data/CHANGELOG
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
=========
|
3
|
+
1.6.4
|
4
|
+
added WebBrwoser.modal_dialog
|
5
|
+
added many watir ie methods such as :elements, :divs....
|
6
|
+
|
7
|
+
1.6.3
|
8
|
+
Add base_authentication for Celerity
|
9
|
+
should contains only return maxium 256 chracters in error stack trace, for full using should include
|
10
|
+
|
3
11
|
1.6.2
|
4
12
|
add helper method: basic_authentication for IE and Firefox
|
5
13
|
|
data/Rakefile
CHANGED
@@ -45,7 +45,6 @@ Rake::RDocTask.new do |rdoc|
|
|
45
45
|
rdoc.title = 'RWebSpec'
|
46
46
|
rdoc.rdoc_files.include('lib/rwebspec.rb')
|
47
47
|
rdoc.rdoc_files.include('lib/rwebspec/*.rb')
|
48
|
-
rdoc.rdoc_files.delete("lib/rwebspec/test_utils.rb")
|
49
48
|
rdoc.rdoc_files.delete("lib/rwebspec/web_testcase.rb")
|
50
49
|
rdoc.rdoc_files.delete("lib/rwebspec/checkJSDialog.rb")
|
51
50
|
rdoc.options += [
|
@@ -59,7 +58,6 @@ Rake::RDocTask.new("chm") do |rdoc|
|
|
59
58
|
rdoc.title = 'RWebSpec'
|
60
59
|
rdoc.rdoc_files.include('lib/rwebspec.rb')
|
61
60
|
rdoc.rdoc_files.include('lib/rwebspec/*.rb')
|
62
|
-
rdoc.rdoc_files.delete("lib/rwebspec/test_utils.rb")
|
63
61
|
rdoc.rdoc_files.delete("lib/rwebspec/web_testcase.rb")
|
64
62
|
rdoc.rdoc_files.delete("lib/rwebspec/checkJSDialog.rb")
|
65
63
|
rdoc.options += [
|
@@ -72,7 +70,7 @@ end
|
|
72
70
|
spec = Gem::Specification.new do |s|
|
73
71
|
s.platform= Gem::Platform::RUBY
|
74
72
|
s.name = "rwebspec"
|
75
|
-
s.version = "1.6.
|
73
|
+
s.version = "1.6.4"
|
76
74
|
s.summary = "Executable functional specification for web applications in RSpec syntax and Watir"
|
77
75
|
# s.description = ""
|
78
76
|
|
data/lib/rwebspec/driver.rb
CHANGED
@@ -13,13 +13,13 @@ require File.join(File.dirname(__FILE__), 'matchers', "contains_text.rb")
|
|
13
13
|
require 'timeout'
|
14
14
|
require 'uri'
|
15
15
|
|
16
|
-
require 'watir/screen_capture' if RUBY_PLATFORM.downcase.include?("mswin") or RUBY_PLATFORM.downcase.include?("mingw")
|
16
|
+
# require 'watir/screen_capture' if RUBY_PLATFORM.downcase.include?("mswin") or RUBY_PLATFORM.downcase.include?("mingw")
|
17
17
|
|
18
18
|
module RWebSpec
|
19
19
|
module Driver
|
20
20
|
include RWebSpec::TestWisePlugin
|
21
21
|
include RWebSpec::Popup
|
22
|
-
include Watir::ScreenCapture if RUBY_PLATFORM.downcase.include?("mswin") or RUBY_PLATFORM.downcase.include?("mingw")
|
22
|
+
# include Watir::ScreenCapture if RUBY_PLATFORM.downcase.include?("mswin") or RUBY_PLATFORM.downcase.include?("mingw")
|
23
23
|
|
24
24
|
@@default_polling_interval = 1 # second
|
25
25
|
@@default_timeout = 30 # seconds
|
@@ -154,6 +154,9 @@ module RWebSpec
|
|
154
154
|
@web_browser.is_firefox? if @web_browser
|
155
155
|
end
|
156
156
|
|
157
|
+
def is_celerity?
|
158
|
+
RUBY_PLATFORM =~ /java/ && @web_browser
|
159
|
+
end
|
157
160
|
|
158
161
|
# Go to another page on the testing site.
|
159
162
|
#
|
@@ -900,6 +903,20 @@ module RWebSpec
|
|
900
903
|
# read_socket()
|
901
904
|
end
|
902
905
|
|
906
|
+
def basic_authentication_celerity(username, password)
|
907
|
+
@web_browser.celerity.credentials = "#{username}:#{password}"
|
908
|
+
end
|
909
|
+
|
910
|
+
def basic_authentication(username, password, options = {})
|
911
|
+
if is_celerity?
|
912
|
+
basic_authentication_celerity(username, password)
|
913
|
+
elsif is_firefox?
|
914
|
+
basic_authentication_firefox(username, password)
|
915
|
+
else
|
916
|
+
basic_authentication_ie(options[:title], username, password, options)
|
917
|
+
end
|
918
|
+
end
|
919
|
+
|
903
920
|
# take_screenshot to save the current active window
|
904
921
|
# TODO can't move mouse
|
905
922
|
def take_screenshot
|
@@ -14,12 +14,12 @@ class ContainsText
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def actual_text
|
17
|
-
@actual.to_s.length >
|
17
|
+
@actual.to_s.length > 256 ? @actual[0, 255] : @actual
|
18
18
|
end
|
19
19
|
|
20
20
|
# error message for should
|
21
21
|
def failure_message
|
22
|
-
"expected '#{actual_text}' to contain '#{@expected}', but it
|
22
|
+
"expected '#{actual_text}' to contain '#{@expected}', but it didn't"
|
23
23
|
end
|
24
24
|
|
25
25
|
# error message for should_not
|
data/lib/rwebspec/web_browser.rb
CHANGED
@@ -5,14 +5,15 @@
|
|
5
5
|
|
6
6
|
begin
|
7
7
|
require 'watir'
|
8
|
-
require 'watir/contrib/enabled_popup'
|
9
|
-
require 'watir/close_all'
|
10
|
-
require 'watir/screen_capture'
|
8
|
+
# require 'watir/contrib/enabled_popup'
|
9
|
+
# require 'watir/close_all'
|
10
|
+
# require 'watir/screen_capture'
|
11
11
|
# NO need any more
|
12
12
|
# require 'watir/ie'
|
13
13
|
# require 'watir/contrib/visible'
|
14
14
|
$watir_loaded = true
|
15
15
|
rescue LoadError => e
|
16
|
+
puts e
|
16
17
|
$watir_loaded = false
|
17
18
|
end
|
18
19
|
|
@@ -21,6 +22,7 @@ begin
|
|
21
22
|
require "firewatir";
|
22
23
|
$firewatir_loaded = true
|
23
24
|
rescue LoadError => e
|
25
|
+
puts e
|
24
26
|
$firewatir_loaded = false
|
25
27
|
end
|
26
28
|
|
@@ -179,6 +181,78 @@ module RWebSpec
|
|
179
181
|
end
|
180
182
|
end
|
181
183
|
|
184
|
+
def modal_dialog(how=nil, what=nil)
|
185
|
+
@browser.modal_dialog(how, what)
|
186
|
+
end
|
187
|
+
|
188
|
+
# This is the main method for accessing a generic element with a given attibute
|
189
|
+
# * how - symbol - how we access the element. Supports all values except :index and :xpath
|
190
|
+
# * what - string, integer or regular expression - what we are looking for,
|
191
|
+
#
|
192
|
+
# Valid values for 'how' are listed in the Watir Wiki - http://wiki.openqa.org/display/WTR/Methods+supported+by+Element
|
193
|
+
#
|
194
|
+
# returns an Watir::Element object
|
195
|
+
#
|
196
|
+
# Typical Usage
|
197
|
+
#
|
198
|
+
# element(:class, /foo/) # access the first element with class 'foo'. We can use a string in place of the regular expression
|
199
|
+
# element(:id, "11") # access the first element that matches an id
|
200
|
+
def element(how, what)
|
201
|
+
return @browser.element(how, what)
|
202
|
+
end
|
203
|
+
|
204
|
+
# this is the main method for accessing generic html elements by an attribute
|
205
|
+
#
|
206
|
+
# Returns a HTMLElements object
|
207
|
+
#
|
208
|
+
# Typical usage:
|
209
|
+
#
|
210
|
+
# elements(:class, 'test').each { |l| puts l.to_s } # iterate through all elements of a given attribute
|
211
|
+
# elements(:alt, 'foo')[1].to_s # get the first element of a given attribute
|
212
|
+
# elements(:id, 'foo').length # show how many elements are foung in the collection
|
213
|
+
#
|
214
|
+
def elements(how, what)
|
215
|
+
return @browser.elements(how, what)
|
216
|
+
end
|
217
|
+
|
218
|
+
def show_all_objects
|
219
|
+
@browser.show_all_objects
|
220
|
+
end
|
221
|
+
|
222
|
+
# Returns the specified ole object for input elements on a web page.
|
223
|
+
#
|
224
|
+
# This method is used internally by Watir and should not be used externally. It cannot be marked as private because of the way mixins and inheritance work in watir
|
225
|
+
#
|
226
|
+
# * how - symbol - the way we look for the object. Supported values are
|
227
|
+
# - :name
|
228
|
+
# - :id
|
229
|
+
# - :index
|
230
|
+
# - :value etc
|
231
|
+
# * what - string that we are looking for, ex. the name, or id tag attribute or index of the object we are looking for.
|
232
|
+
# * types - what object types we will look at.
|
233
|
+
# * value - used for objects that have one name, but many values. ex. radio lists and checkboxes
|
234
|
+
def locate_input_element(how, what, types, value=nil)
|
235
|
+
@browser.locate_input_element(how, what, types, value)
|
236
|
+
end
|
237
|
+
|
238
|
+
# This is the main method for accessing map tags - http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/map.asp?frame=true
|
239
|
+
# * how - symbol - how we access the map,
|
240
|
+
# * what - string, integer or regular expression - what we are looking for,
|
241
|
+
#
|
242
|
+
# Valid values for 'how' are listed in the Watir Wiki - http://wiki.openqa.org/display/WTR/Methods+supported+by+Element
|
243
|
+
#
|
244
|
+
# returns a map object
|
245
|
+
#
|
246
|
+
# Typical Usage
|
247
|
+
#
|
248
|
+
# map(:id, /list/) # access the first map that matches list.
|
249
|
+
# map(:index,2) # access the second map on the page
|
250
|
+
# map(:title, "A Picture") # access a map using the tooltip text. See http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/title_1.asp?frame=true
|
251
|
+
#
|
252
|
+
def map(how, what=nil)
|
253
|
+
@browser.map(how, what)
|
254
|
+
end
|
255
|
+
|
182
256
|
def contains_text(text)
|
183
257
|
@browser.contains_text(text);
|
184
258
|
end
|
@@ -208,7 +282,7 @@ module RWebSpec
|
|
208
282
|
end
|
209
283
|
end
|
210
284
|
|
211
|
-
[:images, :links, :buttons, :select_lists, :checkboxes, :radios, :text_fields].each do |method|
|
285
|
+
[:images, :links, :buttons, :select_lists, :checkboxes, :radios, :text_fields, :divs, :dls, :dds, :dts, :ems, :lis, :maps, :spans, :strongs, :ps, :pres, :labels].each do |method|
|
212
286
|
define_method method do
|
213
287
|
@browser.send(method)
|
214
288
|
end
|
@@ -585,6 +659,11 @@ module RWebSpec
|
|
585
659
|
@browser
|
586
660
|
end
|
587
661
|
|
662
|
+
def celerity
|
663
|
+
raise "can't call this as it is configured to use Celerity" unless RUBY_PLATFORM =~ /java/
|
664
|
+
@browser
|
665
|
+
end
|
666
|
+
|
588
667
|
# Save current web page source to file
|
589
668
|
# usage:
|
590
669
|
# save_page("/tmp/01.html")
|
data/lib/rwebspec.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rwebspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 1.6.
|
9
|
+
- 4
|
10
|
+
version: 1.6.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Zhimin Zhan
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-10-18 00:00:00 +10:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|