rwebunit 1.0.3 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,23 +6,43 @@ module RWebUnit
6
6
  def connect_to_itest(message_type, body)
7
7
  begin
8
8
  the_message = message_type + "|" + body
9
- if @last_message == the_message then
9
+ if @last_message == the_message then # ignore the message same as preivous one
10
10
  return
11
11
  end
12
12
  itest_port = $ITEST2_TRACE_PORT || 7025
13
13
  itest_socket = Socket.new(Socket::AF_INET,Socket::SOCK_STREAM,0)
14
- itest_socket.connect(Socket.pack_sockaddr_in(itest_port, 'localhost'))
14
+ itest_socket.connect(Socket.pack_sockaddr_in(itest_port, '127.0.0.1'))
15
15
  itest_socket.puts(the_message)
16
16
  @last_message = the_message
17
17
  itest_socket.close
18
18
  rescue => e
19
19
  end
20
20
  end
21
+ alias connect_to_itest2 connect_to_itest
21
22
 
22
23
  def debug(message)
23
24
  connect_to_itest(" DEBUG", message + "\r\n") if $RUN_IN_ITEST
24
25
  end
25
26
 
27
+
28
+ # Support of iTest to ajust the intervals between keystroke/mouse operations
29
+ def operation_delay
30
+ begin
31
+ if $ITEST2_OPERATION_DELAY && $ITEST2_OPERATION_DELAY > 0 &&
32
+ $ITEST2_OPERATION_DELAY && $ITEST2_OPERATION_DELAY < 30000 then # max 30 seconds
33
+ sleep($ITEST2_OPERATION_DELAY / 1000)
34
+ end
35
+
36
+ while $ITEST2_PAUSE
37
+ debug("Paused, waiting ...")
38
+ sleep 1
39
+ end
40
+ rescue => e
41
+ puts "Error on delaying: #{e}"
42
+ # ignore
43
+ end
44
+ end
45
+
26
46
  # find out the line (and file) the execution is on, and notify iTest via Socket
27
47
  def dump_caller_stack
28
48
  return unless $ITEST2_TRACE_EXECUTION
@@ -43,5 +63,6 @@ module RWebUnit
43
63
  puts "failed to capture log: #{e}"
44
64
  end
45
65
  end
66
+
46
67
  end
47
68
  end
@@ -0,0 +1,147 @@
1
+ module RWebUnit
2
+ module Popup
3
+
4
+ #= Popup
5
+ #
6
+
7
+ # Start background thread to click popup windows
8
+ # Warning:
9
+ # Make browser window active
10
+ # Don't mouse your mouse to focus other window during test execution
11
+ def check_for_popups
12
+ autoit = WIN32OLE.new('AutoItX3.Control')
13
+ #
14
+ # Do forever - assumes popups could occur anywhere/anytime in your
15
+ # application.
16
+ loop do
17
+ # Look for window with given title. Give up after 1 second.
18
+ ret = autoit.WinWait('Windows Internet Explorer', '', 1)
19
+ #
20
+ # If window found, send appropriate keystroke (e.g. {enter}, {Y}, {N}).
21
+ if (ret==1) then
22
+ autoit.Send('{enter}')
23
+ end
24
+ #
25
+ # Take a rest to avoid chewing up cycles and give another thread a go.
26
+ # Then resume the loop.
27
+ sleep(3)
28
+ end
29
+ end
30
+
31
+ ##
32
+ # Check for "Security Information" and "Security Alert" alert popup, click 'Yes'
33
+ #
34
+ # Usage: For individual test suite
35
+ #
36
+ # before(:all) do
37
+ # $popup = Thread.new { check_for_alerts }
38
+ # open_in_browser
39
+ # ...
40
+ # end
41
+ #
42
+ # after(:all) do
43
+ # close_browser
44
+ # Thread.kill($popup)
45
+ # end
46
+ #
47
+ # or for all tests,
48
+ # $popup = Thread.new { check_for_alerts }
49
+ # at_exit{ Thread.kill($popup) }
50
+ def check_for_security_alerts
51
+ autoit = WIN32OLE.new('AutoItX3.Control')
52
+ loop do
53
+ ["Security Alert", "Security Information"].each do |win_title|
54
+ ret = autoit.WinWait(win_title, '', 1)
55
+ if (ret==1) then
56
+ autoit.Send('{Y}')
57
+ end
58
+ end
59
+ sleep(3)
60
+ end
61
+ end
62
+
63
+ def verify_alert(title = "Microsoft Internet Explorer", button = "OK")
64
+ if is_windows? && !is_firefox?
65
+ WIN32OLE.new('AutoItX3.Control').ControlClick(title, '', button)
66
+ else
67
+ raise "This function only supports IE"
68
+ end
69
+ end
70
+
71
+ def click_button_in_security_information_popup(button = "&Yes")
72
+ verify_alert("Security Information", "", button)
73
+ end
74
+ alias click_security_information_popup click_button_in_security_information_popup
75
+
76
+ def click_button_in_security_alert_popup(button = "&Yes")
77
+ verify_alert("Security Alert", "", button)
78
+ end
79
+ alias click_security_alert_popup click_button_in_security_alert_popup
80
+
81
+ def click_button_in_javascript_popup(button = "OK")
82
+ verify_alert()
83
+ end
84
+ alias click_javascript_popup click_button_in_javascript_popup
85
+
86
+ ##
87
+ # This only works for IEs
88
+ # Cons:
89
+ # - Slow
90
+ # - only works in IE
91
+ # - does not work for security alert ?
92
+ def ie_popup_clicker(button_name = "OK", max_wait = 15)
93
+ require 'watir/contrib/enabled_popup'
94
+ require 'win32ole'
95
+ hwnd = ie.enabled_popup(15)
96
+ if (hwnd) #yeah! a popup
97
+ popup = WinClicker.new
98
+ popup.makeWindowActive(hwnd) #Activate the window.
99
+ popup.clickWindowsButton_hwnd(hwnd, button_name) #Click the button
100
+ #popup.clickWindowsButton(/Internet/,button_name,30)
101
+ popup = nil
102
+ end
103
+ end
104
+
105
+ def click_popup_window(button, wait_time= 9, user_input=nil )
106
+ @web_browser.start_clicker(button, wait_time, user_input)
107
+ sleep 0.5
108
+ end
109
+ # run a separate process waiting for the popup window to click
110
+ #
111
+ #
112
+ def prepare_to_click_button_in_popup(button = "OK", wait_time = 3)
113
+ # !@web_browser.is_firefox?
114
+ # TODO: firefox is OK
115
+ if RUBY_PLATFORM =~ /mswin/ then
116
+ start_checking_js_dialog(button, wait_time)
117
+ else
118
+ raise "this only support on Windows and on IE"
119
+ end
120
+ end
121
+
122
+ # Start a background process to click the button on a javascript popup window
123
+ def start_checking_js_dialog(button = "OK", wait_time = 3)
124
+ w = WinClicker.new
125
+ longName = File.expand_path(File.dirname(__FILE__)).gsub("/", "\\" )
126
+ shortName = w.getShortFileName(longName)
127
+ c = "start ruby #{shortName}\\clickJSDialog.rb #{button} #{wait_time} "
128
+ w.winsystem(c)
129
+ w = nil
130
+ end
131
+
132
+ # Click the button in javascript popup dialog
133
+ # Usage:
134
+ # click_button_in_popup_after { click_link('Cancel')}
135
+ # click_button_in_popup_after("OK") { click_link('Cancel')}
136
+ #
137
+ def click_button_in_popup_after(options = {:button => "OK", :wait_time => 3}, &block)
138
+ if is_windows? then
139
+ start_checking_js_dialog(options[:button], options[:wait_time])
140
+ yield
141
+ else
142
+ raise "this only support on Windows and on IE"
143
+ end
144
+ end
145
+
146
+ end
147
+ end
@@ -21,59 +21,10 @@ module RWebUnit
21
21
  include RWebUnit::Utils
22
22
  include RWebUnit::Assert
23
23
 
24
- # open a browser, and set base_url via hash, but does not acually
25
- #
26
- # example:
27
- # open_browser :base_url => http://localhost:8080
28
- #
29
- # There are 3 ways to set base url
30
- # 1. pass as first argument
31
- # 2. If running using iTest2, used as confiured
32
- # 3. Use default value set
33
- def open_browser(base_url = nil, options = {})
34
- base_url ||= $ITEST2_PROJECT_BASE_URL
35
- base_url ||= $BASE_URL
36
- raise "base_url must be set" if base_url.nil?
37
-
38
- default_options = {:speed => "fast",
39
- :visible => true,
40
- :highlight_colour => 'yellow',
41
- :close_others => true,
42
- :start_new => false, # start a new browser always
43
- :go => true}
44
-
45
- options = default_options.merge options
46
- options[:firefox] = true if "Firefox" == $ITEST2_BROWSER || "Firefox" == $BROWSER
47
- ($ITEST2_HIDE_BROWSER) ? $HIDE_IE = true : $HIDE_IE = false
48
-
49
- uri = URI.parse(base_url)
50
- uri_base = "#{uri.scheme}://#{uri.host}:#{uri.port}"
51
- if options[:start_new]
52
- @web_browser = WebBrowser.new(uri_base, nil, options)
53
- else
54
- # Reuse existing browser
55
- @web_browser = WebBrowser.reuse(uri_base, options)
56
- end
57
-
58
- if options[:go]
59
- (uri.path.length == 0) ? begin_at("/") : begin_at(uri.path)
60
- end
61
- return @web_browser
62
- end
63
- alias open_browser_with open_browser
64
-
65
24
  # --
66
25
  # Content
67
26
  # --
68
27
 
69
- def page_title
70
- @web_browser.page_title
71
- end
72
-
73
- def page_source
74
- @web_browser.page_source
75
- end
76
-
77
28
  def table_source(table_id)
78
29
  table(:id, table_id).innerHTML
79
30
  # elem = @web_browser.document.getElementById(table_id)
@@ -92,9 +43,6 @@ module RWebUnit
92
43
  @web_browser.get_html_in_element(elem_id)
93
44
  end
94
45
 
95
- def element_by_id(elem_id)
96
- @web_browser.element_by_id(elem_id)
97
- end
98
46
 
99
47
  def button_by_id(button_id)
100
48
  button(:id, button_id)
@@ -123,18 +71,26 @@ module RWebUnit
123
71
  def save_page(file_name = nil)
124
72
  @web_browser.save_page(file_name)
125
73
  end
126
-
127
- def save_content_to_file(content, file_name = nil)
74
+
75
+ def save_content_to_file(content, file_name = nil)
128
76
  file_name ||= Time.now.strftime("%Y%m%d%H%M%S") + ".html"
129
77
  puts "about to save page: #{File.expand_path(file_name)}"
130
78
  File.open(file_name, "w").puts content
131
79
  end
132
80
 
133
- # When running
81
+ # When running
134
82
  def debugging?
135
83
  $ITEST2_DEBUGGING && $ITEST2_RUNNING_AS == "test_case"
136
84
  end
137
-
85
+
86
+ # RSpec Matchers
87
+ #
88
+ # Example,
89
+ # a_number.should be_odd_number
90
+ def be_odd_number
91
+ simple_matcher("must be odd number") { |actual| actual && actual.to_id % 2 == 1}
92
+ end
93
+
138
94
  end
139
95
 
140
96
  end
@@ -0,0 +1,8 @@
1
+ module RWebUnit
2
+ module TestScript
3
+ include RWebUnit::Driver
4
+ include RWebUnit::Utils
5
+ include RWebUnit::Assert
6
+
7
+ end
8
+ end
@@ -11,32 +11,54 @@ module RWebUnit
11
11
  # default date format returned is 29/12/2007.
12
12
  # if supplied parameter is not '%m/%d/%Y' -> 12/29/2007
13
13
  # Otherwise, "2007-12-29", which is most approiate date format
14
- def today(format = '%d/%m/%y')
15
- if format.downcase == '%d/%m/%y'
16
- format_date(Time.now, "%02d/%02d/%04d")
17
- elsif format.downcase == '%m/%d/%y'
18
- sprintf("%02d/%02d/%04d", Time.now.month, Time.now.day, Time.now.year)
19
- else
20
- sprintf("%04d-%02d-%02d", Time.now.year, Time.now.month, Time.now.day)
21
- end
14
+ #
15
+ # %a - The abbreviated weekday name (``Sun'')
16
+ # %A - The full weekday name (``Sunday'')
17
+ # %b - The abbreviated month name (``Jan'')
18
+ # %B - The full month name (``January'')
19
+ # %c - The preferred local date and time representation
20
+ # %d - Day of the month (01..31)
21
+ # %H - Hour of the day, 24-hour clock (00..23)
22
+ # %I - Hour of the day, 12-hour clock (01..12)
23
+ # %j - Day of the year (001..366)
24
+ # %m - Month of the year (01..12)
25
+ # %M - Minute of the hour (00..59)
26
+ # %p - Meridian indicator (``AM'' or ``PM'')
27
+ # %S - Second of the minute (00..60)
28
+ # %U - Week number of the current year,
29
+ # starting with the first Sunday as the first
30
+ # day of the first week (00..53)
31
+ # %W - Week number of the current year,
32
+ # starting with the first Monday as the first
33
+ # day of the first week (00..53)
34
+ # %w - Day of the week (Sunday is 0, 0..6)
35
+ # %x - Preferred representation for the date alone, no time
36
+ # %X - Preferred representation for the time alone, no date
37
+ # %y - Year without a century (00..99)
38
+ # %Y - Year with century
39
+ # %Z - Time zone name
40
+ # %% - Literal ``%'' character
41
+
42
+ def today(format = '%d/%m/%Y')
43
+ format_date(Time.now, format)
22
44
  end
23
45
  alias getToday_AU today
24
46
  alias getToday_US today
25
47
  alias getToday today
26
48
 
27
49
 
28
- def days_before(days)
50
+ def days_before(days, format = '%d/%m/%Y')
29
51
  nil if !(days.instance_of?(Fixnum))
30
- format_date(Time.now - days * 24 * 3600)
52
+ format_date(Time.now - days * 24 * 3600, format)
31
53
  end
32
54
 
33
55
  def yesterday
34
56
  days_before(1)
35
57
  end
36
58
 
37
- def days_from_now(days)
59
+ def days_from_now(days, format = '%d/%m/%Y')
38
60
  nil if !(days.instance_of?(Fixnum))
39
- format_date(Time.now + days * 24 * 3600)
61
+ format_date(Time.now + days * 24 * 3600, format)
40
62
  end
41
63
  alias days_after days_from_now
42
64
 
@@ -78,20 +100,71 @@ module RWebUnit
78
100
  end
79
101
  alias random_string_in_collection random_string_in
80
102
 
81
- def this_file
82
- __FILE__
103
+
104
+ WORDS = %w(alias consequatur aut perferendis sit voluptatem accusantium doloremque aperiam eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo aspernatur aut odit aut fugit sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt neque dolorem ipsum quia dolor sit amet consectetur adipisci velit sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem ut enim ad minima veniam quis nostrum exercitationem ullam corporis nemo enim ipsam voluptatem quia voluptas sit suscipit laboriosam nisi ut aliquid ex ea commodi consequatur quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae et iusto odio dignissimos ducimus qui blanditiis praesentium laudantium totam rem voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident sed ut perspiciatis unde omnis iste natus error similique sunt in culpa qui officia deserunt mollitia animi id est laborum et dolorum fuga et harum quidem rerum facilis est et expedita distinctio nam libero tempore cum soluta nobis est eligendi optio cumque nihil impedit quo porro quisquam est qui minus id quod maxime placeat facere possimus omnis voluptas assumenda est omnis dolor repellendus temporibus autem quibusdam et aut consequatur vel illum qui dolorem eum fugiat quo voluptas nulla pariatur at vero eos et accusamus officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae itaque earum rerum hic tenetur a sapiente delectus ut aut reiciendis voluptatibus maiores doloribus asperiores repellat)
105
+
106
+ # Pick a random value out of a given range.
107
+ def value_in_range(range)
108
+ case range.first
109
+ when Integer then number_in_range(range)
110
+ when Time then time_in_range(range)
111
+ when Date then date_in_range(range)
112
+ else range.to_a.rand
113
+ end
114
+ end
115
+
116
+ # Generate a given number of words. If a range is passed, it will generate
117
+ # a random number of words within that range.
118
+ def words(total)
119
+ (1..interpret_value(total)).map { WORDS.rand }.join(' ')
120
+ end
121
+
122
+ # Generate a given number of sentences. If a range is passed, it will generate
123
+ # a random number of sentences within that range.
124
+ def sentences(total)
125
+ (1..interpret_value(total)).map do
126
+ words(5..20).capitalize
127
+ end.join('. ')
128
+ end
129
+
130
+ # Generate a given number of paragraphs. If a range is passed, it will generate
131
+ # a random number of paragraphs within that range.
132
+ def paragraphs(total)
133
+ (1..interpret_value(total)).map do
134
+ sentences(3..8).capitalize
135
+ end.join("\n\n")
83
136
  end
84
- alias current_file this_file
85
-
86
- def this_directory
87
- File.dirname(this_file)
137
+
138
+ # If an array or range is passed, a random value will be selected to match.
139
+ # All other values are simply returned.
140
+ def interpret_value(value)
141
+ case value
142
+ when Array then value.rand
143
+ when Range then value_in_range(value)
144
+ else value
145
+ end
88
146
  end
89
- alias current_directory this_directory
90
-
147
+
91
148
  private
92
- def format_date(date, date_format = nil)
93
- date_format ||= "%02d/%02d/%04d"
94
- sprintf(date_format, date.day, date.month, date.year)
149
+
150
+ def time_in_range(range)
151
+ Time.at number_in_range(Range.new(range.first.to_i, range.last.to_i, range.exclude_end?))
152
+ end
153
+
154
+ def date_in_range(range)
155
+ Date.jd number_in_range(Range.new(range.first.jd, range.last.jd, range.exclude_end?))
156
+ end
157
+
158
+ def number_in_range(range)
159
+ if range.exclude_end?
160
+ rand(range.last - range.first) + range.first
161
+ else
162
+ rand((range.last+1) - range.first) + range.first
163
+ end
164
+ end
165
+
166
+ def format_date(date, date_format = '%d/%m/%Y')
167
+ date.strftime(date_format)
95
168
  end
96
169
 
97
170
  end
@@ -0,0 +1,49 @@
1
+ module RWebUnit
2
+ module UsingPages
3
+
4
+ # support Ruby 1.9
5
+ def self.extended(kclass)
6
+ caller_file = caller[1]
7
+ if caller_file && caller_file =~ /^(.*):\d+.*$/
8
+ file = $1
9
+ dir = File.expand_path(File.dirname(file))
10
+ kclass.const_set "TestFileDir", dir
11
+ end
12
+ end
13
+
14
+ # Example
15
+ # pages :all
16
+ # pages :login_page, :payment_page
17
+ # pages :login_page, :payment_page, :page_dir => "c:/tmp"
18
+ def pages(*args)
19
+ return if args.nil? or args.empty?
20
+
21
+ test_file_dir = class_eval{ self::TestFileDir }
22
+ default_page_dir = File.join(test_file_dir, "pages")
23
+ #puts "debug: default_page_dir :#{default_page_dir}}"
24
+ page_dir = default_page_dir
25
+
26
+ page_files = []
27
+ args.each do |x|
28
+ if x.class == Hash && x[:page_dir]
29
+ page_dir = x[:page_dir]
30
+ else
31
+ page_files << x
32
+ end
33
+ end
34
+
35
+ if page_files.size == 1 && page_files[0] == :all
36
+ Dir[File.expand_path(page_dir)+ "/*_page.rb"].each { |page_file|
37
+ load page_file
38
+ }
39
+ return
40
+ end
41
+
42
+ page_files.each do |page|
43
+ page_file = File.join(page_dir, page.to_s)
44
+ load page_file
45
+ end
46
+ end
47
+
48
+ end
49
+ end
@@ -43,6 +43,15 @@ module RWebUnit
43
43
  @browser = existing_browser
44
44
  else
45
45
  if (options[:firefox] && $firewatir_loaded) || ($firewatir_loaded and !$watir_loaded)
46
+ # JSSH is running, 9997
47
+ begin
48
+ require 'net/telnet'
49
+ firefox_jssh = Net::Telnet::new("Host" => "127.0.0.1", "Port" => 9997)
50
+ FireWatir::Firefox.firefox_started = true
51
+ rescue => e
52
+ # puts "debug: XXX #{e}"
53
+ sleep 1
54
+ end
46
55
  @browser = FireWatir::Firefox.start(base_url)
47
56
  elsif $watir_loaded
48
57
  @browser = Watir::IE.new
@@ -113,6 +122,14 @@ module RWebUnit
113
122
  end
114
123
  alias html_body page_source
115
124
 
125
+ def html
126
+ @browser.html
127
+ end
128
+
129
+ def text
130
+ @browser.text
131
+ end
132
+
116
133
  def page_title
117
134
  if is_firefox?
118
135
  @browser.title
@@ -160,11 +177,12 @@ module RWebUnit
160
177
  end
161
178
  alias close close_browser
162
179
 
180
+ #TODO determine browser type, check FireWatir support or not
163
181
  def self.close_all_browsers
164
- if is_firefox? then
165
- @browser.close_all
166
- else
182
+ if RUBY_PLATFORM.downcase.include?("mswin")
167
183
  Watir::IE.close_all
184
+ else
185
+ # raise "not supported in FireFox yet."
168
186
  end
169
187
  end
170
188
 
@@ -218,6 +236,10 @@ module RWebUnit
218
236
  @browser.goto full_url(page);
219
237
  end
220
238
 
239
+ def goto_url(url)
240
+ @browser.goto url
241
+ end
242
+
221
243
  # text fields
222
244
  def enter_text_into_field_with_name(name, text)
223
245
  if is_firefox?
@@ -334,7 +356,7 @@ module RWebUnit
334
356
  end
335
357
 
336
358
  def select_file_for_upload(file_field, file_path)
337
- normalized_file_path = is_windows? ? file_path.gsub("/", "\\") : file_path
359
+ normalized_file_path = RUBY_PLATFORM.downcase.include?("mswin") ? file_path.gsub("/", "\\") : file_path
338
360
  file_field(:name, file_field).set(normalized_file_path)
339
361
  end
340
362
 
@@ -425,7 +447,7 @@ module RWebUnit
425
447
  end
426
448
 
427
449
 
428
- def is_windows?
450
+ def self.is_windows?
429
451
  RUBY_PLATFORM.downcase.include?("mswin")
430
452
  end
431
453
 
@@ -29,7 +29,7 @@ module RWebUnit
29
29
  # page_text: text used to identify the page, title will be the first candidate
30
30
  attr_accessor :page_text
31
31
 
32
- def initialize(the_browser, page_text=nil)
32
+ def initialize(the_browser, page_text = nil)
33
33
  @web_browser = the_browser
34
34
  @web_tester = the_browser
35
35
  @page_text = page_text
@@ -58,37 +58,33 @@ module RWebUnit
58
58
  @web_browser.dump_response(stream)
59
59
  end
60
60
 
61
+
61
62
  def source
62
63
  @web_browser.page_source
63
64
  end
64
65
 
66
+ # return current page title
65
67
  def title
66
68
  @web_browser.page_title
67
69
  end
68
70
 
71
+ # return current page text
72
+ def text
73
+ @web_browser.text
74
+ end
75
+
69
76
  # TO validate
70
77
  def contains?(ary)
71
- page_source = source
78
+ the_page_source = source
72
79
  found = false
73
80
  ary.each do |str|
74
- found ||= page_source.include?(str)
81
+ found ||= the_page_source.include?(str)
75
82
  end
76
83
  return found
77
84
  end
78
- alias include contains?
79
-
80
-
81
- def snapshot
82
- if $ITEST2_DUMP_DIR
83
- spec_run_id = $ITEST2_RUNNING_SPEC_ID || "unknown"
84
- spec_run_dir_name = spec_run_id.to_s.rjust(4, "0") unless spec_run_id == "unknown"
85
- spec_run_dir = File.join($ITEST2_DUMP_DIR, spec_run_dir_name)
86
- Dir.mkdir(spec_run_dir) unless File.exists?(spec_run_dir)
87
- file_name = Time.now.strftime("%m%d%H%M%S") + "_" + self.class.name.gsub("", "") + ".html"
88
- file = File.join($ITEST2_DUMP_DIR, spec_run_dir_name, file_name)
89
- page_source = browser.page_source
90
- File.new(file, "w").puts source
91
- end
85
+
86
+ def snapshot(replace_css = false)
87
+ save_current_page(:filename => Time.now.strftime("%m%d%H%M%S") + "_" + self.class.name.gsub(" ", "") + ".html" )
92
88
  end
93
89
 
94
90
  end
data/lib/rwebunit.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #***********************************************************
2
- #* Copyright (c) 2006, Zhimin Zhan.
2
+ #* Copyright (c) 2006 - 2009, Zhimin Zhan.
3
3
  #* Distributed open-source, see full license in MIT-LICENSE
4
4
  #***********************************************************
5
5
 
@@ -12,11 +12,11 @@ rescue LoadError => no_as1_err
12
12
  end
13
13
  require 'active_support/core_ext'
14
14
  require 'spec'
15
- require 'hpricot' # for parsing HTML
16
15
 
17
- RWEBUNIT_VERSION = "1.0.3"
16
+ RWEBUNIT_VERSION = "1.3.0"
18
17
 
19
18
  # Extra full path to load libraries
19
+ require File.dirname(__FILE__) + "/rwebunit/using_pages"
20
20
  require File.dirname(__FILE__) + "/rwebunit/test_utils"
21
21
  require File.dirname(__FILE__) + "/rwebunit/web_page"
22
22
  require File.dirname(__FILE__) + "/rwebunit/assert"
@@ -25,8 +25,8 @@ require File.dirname(__FILE__) + "/rwebunit/assert"
25
25
  require File.dirname(__FILE__) + "/rwebunit/itest_plugin"
26
26
  require File.dirname(__FILE__) + "/rwebunit/web_browser"
27
27
  require File.dirname(__FILE__) + "/rwebunit/driver"
28
+ require File.dirname(__FILE__) + "/rwebunit/test_script"
28
29
  require File.dirname(__FILE__) + "/rwebunit/context"
29
- require File.dirname(__FILE__) + "/rwebunit/driver"
30
30
  require File.dirname(__FILE__) + "/rwebunit/rspec_helper"
31
31
  require File.dirname(__FILE__) + "/rspec_extensions"
32
32
  require File.dirname(__FILE__) + "/watir_extensions"