awetestlib 0.1.13-x86-mingw32 → 0.1.14-x86-mingw32

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.
@@ -1,42 +1,10 @@
1
1
  module Awetestlib
2
2
  module Regression
3
+ # Backward compatible methods and alias to support earlier versions of the Awetest DSL.
4
+ # These are deprecated in favor of the corresponding methods in the module name under which they are grouped.
5
+ # Work in Progress
3
6
  module Legacy
4
7
 
5
- #--
6
- ##def open_log
7
- # start = Time.now.to_f.to_s
8
- #
9
- # logTS = Time.at(@myRun.launched.to_f).strftime("%Y%m%d%H%M%S")
10
- # xls = @myAppEnv.xls_name.gsub('.xls', '') + '_' if @myAppEnv.xls_name.length > 0
11
- # @logFileSpec = "#{@myRoot}/#{logdir}/#{@myName}_#{@targetBrowser.abbrev}_#{xls}#{logTS}.log"
12
- # init_logger(@logFileSpec, @myName)
13
- #
14
- # # message_tolog( self.inspect )
15
- # message_to_log("#{@myName} launched at [#{@myRun.launched.to_f.to_s}][#{@myScript.id}][#{@myRun.id}][#{@myChild.id}]")
16
- # debug_to_log("pid: #{$$}")
17
- # message_to_log("#{@myName} begin at [#{start}]")
18
- # message_to_log("#{@myName} environment [#{@myAppEnv.name}]")
19
- # message_to_log("#{@myName} xls_name [#{@myAppEnv.xls_name}]") if @myAppEnv.xls_name.length > 0
20
- # message_to_log("#{@myName} rootDir [#{@myRoot}]")
21
- # message_to_log("#{@myName} Target Browser [#{@targetBrowser.name}]")
22
- # mark_testlevel(@myParent.name, @myParent.level) # Module
23
- # mark_testlevel(@myChild.name, @myChild.level) # SubModule
24
- #
25
- #end
26
- #++
27
-
28
- #def find_me(where, how, what)
29
- # me = where.element(how, what)
30
- # puts me.inspect
31
- #rescue
32
- # error_to_log("#{where.inspect} doesn't seem to respond to element() #{$!}")
33
- #end
34
-
35
- # def click_me(element)
36
- # element.click
37
- # rescue
38
- # error_to_log("#{element.inspect} doesn't seem to respond to click() #{$!}")
39
- # end
40
8
 
41
9
 
42
10
  end
@@ -1,7 +1,11 @@
1
1
  module Awetestlib
2
2
  module Regression
3
+ # Methods for capture and manipulation of data contained in
4
+ # text, values, and/or states of spans, text fields, radios, checkboxes, and select_lists.
3
5
  module PageData
4
6
 
7
+ # @!group Core
8
+
5
9
  =begin rdoc
6
10
  :category: Page Data
7
11
  :tags: data, DOM, page
@@ -36,7 +40,7 @@ No positive validations are reported but failure is rescued and reported.
36
40
  end
37
41
 
38
42
  def compare_page_data(before, after, how, desc = '')
39
- [:text, :textarea, :select_list, :span, :checkbox, :radio].each do |type|
43
+ [:text, :textarea, :select_list, :span, :hidden, :checkbox, :radio].each do |type|
40
44
  before[how][type].each_key do |what|
41
45
  msg = "#{desc} #{type} #{how}=#{what}: Expected '#{before[how][type][what]}'."
42
46
  if after[how][type][what] == before[how][type][what]
@@ -144,45 +148,42 @@ No positive validations are reported but failure is rescued and reported.
144
148
  end
145
149
 
146
150
  def get_textfield_value(browser, how, what, desc = '')
147
- msg = "Return value in textfield #{how}='#{what}'"
148
- msg << " #{desc}" if desc.length > 0
151
+ msg = build_message("Return value in textfield #{how}='#{what}'", desc)
149
152
  tf = browser.text_field(how, what)
150
- if validate(browser, @myName, __LINE__)
151
- if tf
152
- debug_to_log("#{tf.inspect}")
153
- vlu = tf.value
154
- passed_to_log("#{msg} Value='#{vlu}'")
155
- vlu
156
- else
157
- failed_to_log("#{msg}")
158
- end
153
+ if tf
154
+ debug_to_log("#{tf.inspect}")
155
+ vlu = tf.value
156
+ passed_to_log("#{msg} Value='#{vlu}'")
157
+ vlu
158
+ else
159
+ failed_to_log("#{msg}")
159
160
  end
160
161
  rescue
161
162
  failed_to_log("Unable to #{msg}: '#{$!}'")
162
163
  end
163
164
 
164
- def get_textfield_value_by_name(browser, strg, desc = '')
165
- get_textfield_value(browser, :name, strg, desc)
166
- end
167
-
168
- def get_textfield_value_by_id(browser, strg)
169
- get_textfield_value(browser, :id, strg)
170
- end
171
-
172
165
  def get_element_text(browser, element, how, what, desc = '')
173
- msg = "Return text in #{element} #{how}='#{what}'"
174
- msg << " #{desc}" if desc.length > 0
166
+ msg = build_message("Return text in #{element} #{how}='#{what}'", desc)
175
167
  text = browser.element(how, what).text
176
- if validate(browser, @myName, __LINE__)
177
- passed_to_log("#{msg} text='#{text}'")
178
- text
179
- end
168
+ passed_to_log("#{msg} text='#{text}'")
169
+ text
180
170
  rescue
181
171
  failed_to_log("Unable to #{msg}: '#{$!}'")
182
172
  end
183
173
 
174
+ # @!endgroup Core
175
+
176
+ # @!group Legacy (Backward compatible usage)
177
+
178
+ def get_textfield_value_by_name(browser, strg, desc = '')
179
+ get_textfield_value(browser, :name, strg, desc)
180
+ end
184
181
 
182
+ def get_textfield_value_by_id(browser, strg)
183
+ get_textfield_value(browser, :id, strg)
184
+ end
185
185
 
186
+ # @!endgroup Legacy
186
187
 
187
188
  end
188
189
  end
@@ -6,6 +6,7 @@ require 'awetestlib/regression/tables'
6
6
  require 'awetestlib/regression/page_data'
7
7
  require 'awetestlib/regression/drag_and_drop'
8
8
  require 'awetestlib/regression/utilities'
9
+ require 'awetestlib/regression/legacy'
9
10
  require 'awetestlib/logging'
10
11
  require 'awetestlib/regression/validations'
11
12
  require 'awetestlib/html_report'
@@ -20,6 +21,7 @@ module Awetestlib
20
21
 
21
22
  # order matters here
22
23
  include Awetestlib::Logging
24
+ include Awetestlib::Regression::Utilities
23
25
  include Awetestlib::Regression::Browser
24
26
  include Awetestlib::Regression::Find
25
27
  include Awetestlib::Regression::UserInput
@@ -27,8 +29,8 @@ module Awetestlib
27
29
  include Awetestlib::Regression::Tables
28
30
  include Awetestlib::Regression::PageData
29
31
  include Awetestlib::Regression::DragAndDrop
30
- include Awetestlib::Regression::Utilities
31
32
  include Awetestlib::Regression::Validations
33
+ include Awetestlib::Regression::Legacy
32
34
 
33
35
  ::DEBUG = 0
34
36
  ::INFO = 1
@@ -1,7 +1,12 @@
1
1
  module Awetestlib
2
2
  module Regression
3
+ # Methods for handling Tables, Rows, and Cells
4
+ # Rdoc work in progress
3
5
  module Tables
4
6
 
7
+
8
+ # Groups: Columns, Rows, Sorting
9
+
5
10
  def get_index_for_column_head(panel, table_index, strg, desc = '')
6
11
  table = panel.tables[table_index]
7
12
  get_column_index(table, strg, desc, true)
@@ -241,6 +246,32 @@ module Awetestlib
241
246
  text
242
247
  end
243
248
 
249
+ # Return a hash containing a cross reference of the header names and indexes (columns) for the specified table.
250
+ # @example
251
+ # (need example and usage)
252
+ # @param [Watir::Table] table A reference to the table.
253
+ # @param [Fixnum] header_index The index of the row containing the header names.
254
+ # @return [Hash] Two level hash of hashes. Internal hashes are 'name' which allows look-up of a column index
255
+ # by the header name, and 'index' which allows look-up of the name by the column index.
256
+ def get_table_headers(table, header_index = 1)
257
+ headers = Hash.new
258
+ headers['index'] = Hash.new
259
+ headers['name'] = Hash.new
260
+ count = 1
261
+ table[header_index].each do |cell|
262
+ if cell.text.length > 0
263
+ name = cell.text.gsub(/\s+/, ' ')
264
+ headers['index'][count] = name
265
+ headers['name'][name] = count
266
+ end
267
+ count += 1
268
+ end
269
+ #debug_to_log("#{__method__}: headers:\n#{headers.to_yaml}")
270
+ headers
271
+ rescue
272
+ failed_to_log("Unable to get content headers. '#{$!}'")
273
+ end
274
+
244
275
  def count_rows_with_string(container, table_index, strg)
245
276
  hit = 0
246
277
  container.tables[table_index].each do |row|
@@ -510,6 +541,32 @@ module Awetestlib
510
541
  sleep_for(1)
511
542
  end
512
543
 
544
+ def text_in_table?(browser, how, what, expected, desc = '')
545
+ msg = build_message("Table :#{how}=>#{what} contains '#{expected}.", desc)
546
+ if browser.table(how, what).text =~ expected
547
+ passed_to_log(msg)
548
+ true
549
+ else
550
+ failed_to_log(msg)
551
+ end
552
+ rescue
553
+ failed_to_log("Unable to verify that #{msg}': '#{$!}'")
554
+ end
555
+
556
+ def text_in_table_row_with_text?(table, text, target, desc = '')
557
+ #TODO This needs clarification, renaming
558
+ msg = build_message("Table :id=>#{table.id} row with text '#{text} also contains '#{target}.", desc)
559
+ index = get_index_of_row_with_text(table, text)
560
+ if table[index].text =~ target
561
+ passed_to_log(msg)
562
+ true
563
+ else
564
+ failed_to_log(msg)
565
+ end
566
+ end
567
+
568
+ alias verify_text_in_table_with_text text_in_table_row_with_text?
569
+
513
570
  end
514
571
  end
515
572
  end