awetestlib 0.0.3-x86-mingw32 → 0.1.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitattributes +22 -0
- data/.gitignore +2 -3
- data/AwetestLib Instructions.rtf +0 -0
- data/ext/Rakefile +1 -0
- data/lib/regression/browser.rb +1259 -0
- data/lib/regression/drag_and_drop.rb +374 -0
- data/lib/regression/find.rb +426 -0
- data/lib/regression/legacy.rb +10 -4693
- data/lib/regression/page_data.rb +185 -0
- data/lib/regression/runner.rb +16 -2
- data/lib/regression/tables.rb +486 -0
- data/lib/regression/user_input.rb +1255 -0
- data/lib/regression/utilities.rb +891 -0
- data/lib/regression/validations.rb +179 -508
- data/lib/regression/waits.rb +387 -0
- data/lib/version.rb +2 -2
- data/rdoc_test.bat +1 -0
- data/test/create_zoho.rb +65 -0
- data/{create_zoho_account1.rb → test/create_zoho_account1.rb} +0 -0
- data/{create_zoho_account2.rb → test/create_zoho_account2.rb} +2 -1
- data/{demo.rb → test/demo.rb} +0 -0
- data/{google_search1.rb → test/google_search1.rb} +0 -0
- data/{google_search2.rb → test/google_search2.rb} +0 -0
- data/{zoho_util.rb → test/zoho_util.rb} +0 -0
- data/{zoho_variables.xls → test/zoho_variables.xls} +0 -0
- metadata +27 -12
@@ -0,0 +1,185 @@
|
|
1
|
+
module PageData
|
2
|
+
|
3
|
+
=begin rdoc
|
4
|
+
:category: Page Data
|
5
|
+
:tags: data, DOM, page
|
6
|
+
|
7
|
+
_Parameters_::
|
8
|
+
|
9
|
+
*browser* is any container element, usually the browser window or a div within it. Best to use is the smallest that contains the desired data.
|
10
|
+
|
11
|
+
*types* is an array that defaults to all of: :text, :textarea, :select_list, :span, :hidden, :checkbox, and :radio.
|
12
|
+
Set types to an array of a subset of these if fewer elements are desired.
|
13
|
+
|
14
|
+
No positive validations are reported but failure is rescued and reported.
|
15
|
+
=end
|
16
|
+
def capture_page_data(browser, types = [:text, :textarea, :select_list, :span, :hidden, :checkbox, :radio])
|
17
|
+
start = Time.now
|
18
|
+
debug_to_log("Begin #{__method__}")
|
19
|
+
data = Hash.new
|
20
|
+
data[:id] = Hash.new
|
21
|
+
data[:name] = Hash.new
|
22
|
+
data[:index] = Hash.new
|
23
|
+
types.each do |type|
|
24
|
+
#debug_to_log("#{__method__}: #{type}. . .")
|
25
|
+
data[:id][type], data[:name][type], data[:index][type] = parse_elements(browser, type)
|
26
|
+
end
|
27
|
+
data
|
28
|
+
rescue
|
29
|
+
failed_to_log("#{__method__}: '#{$!}'")
|
30
|
+
ensure
|
31
|
+
stop = Time.now
|
32
|
+
passed_to_log("#{__method__.to_s.titleize} finished. (#{"%.5f" % (stop - start)} secs)")
|
33
|
+
#debug_to_log("End #{__method__}")
|
34
|
+
end
|
35
|
+
|
36
|
+
def compare_page_data(before, after, how, desc = '')
|
37
|
+
[:text, :textarea, :select_list, :span, :checkbox, :radio].each do |type|
|
38
|
+
before[how][type].each_key do |what|
|
39
|
+
msg = "#{desc} #{type} #{how}=#{what}: Expected '#{before[how][type][what]}'."
|
40
|
+
if after[how][type][what] == before[how][type][what]
|
41
|
+
passed_to_log(msg)
|
42
|
+
else
|
43
|
+
failed_to_log("#{msg} Found '#{after[how][type][what]}'")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
rescue
|
48
|
+
failed_to_log("Unable to compare before and after page data. '#{$!}'")
|
49
|
+
end
|
50
|
+
|
51
|
+
=begin rdoc
|
52
|
+
:category: Page Data
|
53
|
+
:tags:data, DOM
|
54
|
+
|
55
|
+
*data* is the hash returned by capture_page_data().
|
56
|
+
|
57
|
+
*how* is one of :id, :name, :index
|
58
|
+
|
59
|
+
*what* is the target value for how. It can be a string or a regular expression
|
60
|
+
|
61
|
+
*type* is one of :text,:textarea,:select_list,:span,:hidden,:checkbox,:radio
|
62
|
+
|
63
|
+
*get_text* determines whether selected option's text or value is returned. Default is true, i.e., return the selected text.
|
64
|
+
This only applies when the *type* is :select_list.
|
65
|
+
|
66
|
+
=end
|
67
|
+
def fetch_page_data(data, how, what, type, get_text = true)
|
68
|
+
rslt = data[how][type][what]
|
69
|
+
if type == :select_list
|
70
|
+
value, text = rslt.split('::')
|
71
|
+
if get_text
|
72
|
+
rslt = text
|
73
|
+
else
|
74
|
+
rslt = value
|
75
|
+
end
|
76
|
+
end
|
77
|
+
rslt
|
78
|
+
end
|
79
|
+
|
80
|
+
=begin rdoc
|
81
|
+
:category: Page Data
|
82
|
+
:tags:data, DOM
|
83
|
+
|
84
|
+
*browser* is any container element. best to use is the smallest that contains the desired data.
|
85
|
+
|
86
|
+
*type* is one of these symbols: :text,:textarea,:select_list,:span,:hidden,:checkbox,:radio
|
87
|
+
|
88
|
+
Returns three hashes: id[type][id] = value, name[type][id] = value, index[type][id] = value
|
89
|
+
|
90
|
+
A given element appears once in the set of hashes depending on how is is found: id first
|
91
|
+
then name, then index.
|
92
|
+
|
93
|
+
Select list value is in the form 'value::text'. parse with x.split('::')
|
94
|
+
|
95
|
+
No positive validations are reported but failure is rescued and reported.
|
96
|
+
=end
|
97
|
+
def parse_elements(browser, type)
|
98
|
+
id = Hash.new
|
99
|
+
name = Hash.new
|
100
|
+
index = Hash.new
|
101
|
+
idx = 0
|
102
|
+
#debug_to_log("#{__method__}: #{type}")
|
103
|
+
case type
|
104
|
+
when :span
|
105
|
+
collection = browser.spans
|
106
|
+
when :select_list
|
107
|
+
collection = browser.select_lists
|
108
|
+
when :radio
|
109
|
+
collection = browser.radios
|
110
|
+
when :checkbox
|
111
|
+
collection = browser.checkboxes
|
112
|
+
else
|
113
|
+
collection = browser.elements(:type, type.to_s)
|
114
|
+
end
|
115
|
+
#debug_to_log("#{__method__}: collection: #{collection.inspect}")
|
116
|
+
collection.each do |e|
|
117
|
+
case type
|
118
|
+
when :span
|
119
|
+
vlu = e.text
|
120
|
+
when :select_list
|
121
|
+
vlu = "#{e.value}::#{e.selected_options[0]}"
|
122
|
+
when :radio
|
123
|
+
vlu = e.set?
|
124
|
+
when :checkbox
|
125
|
+
vlu = e.set?
|
126
|
+
else
|
127
|
+
vlu = e.value
|
128
|
+
end
|
129
|
+
idx += 1
|
130
|
+
if e.id.length > 0 and not e.id =~ /^__[A-Z]/
|
131
|
+
id[e.id] = vlu
|
132
|
+
elsif e.name.length > 0 and not e.name =~ /^__[A-Z]/
|
133
|
+
name[e.name] = vlu
|
134
|
+
else
|
135
|
+
index[idx] = vlu if not type == :hidden
|
136
|
+
end
|
137
|
+
end
|
138
|
+
[id, name, index]
|
139
|
+
|
140
|
+
rescue
|
141
|
+
failed_to_log("#{__method__}: '#{$!}'")
|
142
|
+
end
|
143
|
+
|
144
|
+
def get_textfield_value(browser, how, what, desc = '')
|
145
|
+
msg = "Return value in textfield #{how}='#{what}'"
|
146
|
+
msg << " #{desc}" if desc.length > 0
|
147
|
+
tf = browser.text_field(how, what)
|
148
|
+
if validate(browser, @myName, __LINE__)
|
149
|
+
if tf
|
150
|
+
debug_to_log("#{tf.inspect}")
|
151
|
+
vlu = tf.value
|
152
|
+
passed_to_log("#{msg} Value='#{vlu}'")
|
153
|
+
vlu
|
154
|
+
else
|
155
|
+
failed_to_log("#{msg}")
|
156
|
+
end
|
157
|
+
end
|
158
|
+
rescue
|
159
|
+
failed_to_log("Unable to #{msg}: '#{$!}'")
|
160
|
+
end
|
161
|
+
|
162
|
+
def get_textfield_value_by_name(browser, strg, desc = '')
|
163
|
+
get_textfield_value(browser, :name, strg, desc)
|
164
|
+
end
|
165
|
+
|
166
|
+
def get_textfield_value_by_id(browser, strg)
|
167
|
+
get_textfield_value(browser, :id, strg)
|
168
|
+
end
|
169
|
+
|
170
|
+
def get_element_text(browser, element, how, what, desc = '')
|
171
|
+
msg = "Return text in #{element} #{how}='#{what}'"
|
172
|
+
msg << " #{desc}" if desc.length > 0
|
173
|
+
text = browser.element(how, what).text
|
174
|
+
if validate(browser, @myName, __LINE__)
|
175
|
+
passed_to_log("#{msg} text='#{text}'")
|
176
|
+
text
|
177
|
+
end
|
178
|
+
rescue
|
179
|
+
failed_to_log("Unable to #{msg}: '#{$!}'")
|
180
|
+
end
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
end
|
data/lib/regression/runner.rb
CHANGED
@@ -1,4 +1,11 @@
|
|
1
|
-
require 'regression/
|
1
|
+
require 'regression/browser'
|
2
|
+
require 'regression/find'
|
3
|
+
require 'regression/user_input'
|
4
|
+
require 'regression/waits'
|
5
|
+
require 'regression/tables'
|
6
|
+
require 'regression/page_data'
|
7
|
+
require 'regression/drag_and_drop'
|
8
|
+
require 'regression/utilities'
|
2
9
|
require 'regression/logging'
|
3
10
|
require 'regression/validations'
|
4
11
|
|
@@ -13,7 +20,14 @@ module Awetestlib
|
|
13
20
|
|
14
21
|
# order matters here
|
15
22
|
include Logging
|
16
|
-
include
|
23
|
+
include Browser
|
24
|
+
include Find
|
25
|
+
include UserInput
|
26
|
+
include Waits
|
27
|
+
include Tables
|
28
|
+
include PageData
|
29
|
+
include DragAndDrop
|
30
|
+
include Utilities
|
17
31
|
include Validations
|
18
32
|
|
19
33
|
::DEBUG = 0
|
@@ -0,0 +1,486 @@
|
|
1
|
+
module Tables
|
2
|
+
|
3
|
+
def get_index_for_column_head(panel, table_index, strg)
|
4
|
+
rgx = Regexp.new(strg)
|
5
|
+
panel.tables[table_index].each do |row|
|
6
|
+
if row.text =~ rgx
|
7
|
+
index = 1
|
8
|
+
row.each do |cell|
|
9
|
+
if cell.text =~ rgx
|
10
|
+
return index
|
11
|
+
end
|
12
|
+
index += 1
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_index_of_last_row(table, pad = 2, every = 1)
|
19
|
+
index = calc_index(table.row_count, every)
|
20
|
+
index = index.to_s.rjust(pad, '0')
|
21
|
+
#debug_to_log("#{__method__}: index='#{index}' row_count=#{table.row_count} pad=#{pad} every=#{every}")
|
22
|
+
index
|
23
|
+
end
|
24
|
+
|
25
|
+
alias get_index_for_last_row get_index_of_last_row
|
26
|
+
|
27
|
+
def get_index_of_last_row_with_text(table, strg, column_index = nil)
|
28
|
+
debug_to_log("#{__method__}: #{get_callers(5)}")
|
29
|
+
msg = "Find last row in table :id=#{table.id} with text '#{strg}'"
|
30
|
+
msg << " in column #{column_index}" if column_index
|
31
|
+
dbg = "#{__method__}: #{table.id} text by row "
|
32
|
+
dbg << "in column #{column_index}" if column_index
|
33
|
+
index = 0
|
34
|
+
found = false
|
35
|
+
at_index = 0
|
36
|
+
#row_count = table.row_count
|
37
|
+
table.rows.each do |row|
|
38
|
+
cell_count = get_cell_count(row)
|
39
|
+
index += 1
|
40
|
+
text = ''
|
41
|
+
if column_index
|
42
|
+
col_idx = column_index.to_i
|
43
|
+
if cell_count >= col_idx
|
44
|
+
text = row[col_idx].text
|
45
|
+
end
|
46
|
+
else
|
47
|
+
text = row.text
|
48
|
+
end
|
49
|
+
dbg << "\n#{index}. [#{text}]"
|
50
|
+
if text =~ /#{strg}/
|
51
|
+
found = true
|
52
|
+
at_index = index
|
53
|
+
end
|
54
|
+
end
|
55
|
+
debug_to_log(dbg)
|
56
|
+
if found
|
57
|
+
passed_to_log("#{msg} at index #{index}.")
|
58
|
+
at_index
|
59
|
+
else
|
60
|
+
failed_to_log("#{msg}")
|
61
|
+
nil
|
62
|
+
end
|
63
|
+
rescue
|
64
|
+
failed_to_log("Unable to #{msg}. '#{$!}'")
|
65
|
+
end
|
66
|
+
|
67
|
+
alias get_index_for_last_row_with_text get_index_of_last_row_with_text
|
68
|
+
|
69
|
+
def get_index_of_row_with_text(table, strg, column_index = nil, fail_if_found = false)
|
70
|
+
debug_to_log("#{__method__}: #{get_callers(5)}")
|
71
|
+
if fail_if_found
|
72
|
+
msg = 'No '
|
73
|
+
else
|
74
|
+
msg = 'Find '
|
75
|
+
end
|
76
|
+
msg << "row in table :id=#{table.id} with text '#{strg}'"
|
77
|
+
msg << " in column #{column_index}" if column_index
|
78
|
+
dbg = "#{__method__}: #{table.id} text by row "
|
79
|
+
dbg << "in column #{column_index}" if column_index
|
80
|
+
index = 0
|
81
|
+
found = false
|
82
|
+
table.rows.each do |row|
|
83
|
+
cell_count = row.cells.length
|
84
|
+
index += 1
|
85
|
+
text = ''
|
86
|
+
if column_index
|
87
|
+
col_idx = column_index.to_i
|
88
|
+
if cell_count >= col_idx
|
89
|
+
text = row[col_idx].text
|
90
|
+
end
|
91
|
+
else
|
92
|
+
text = row.text
|
93
|
+
end
|
94
|
+
dbg << "\n#{index}. [#{text}]"
|
95
|
+
if text =~ /#{strg}/
|
96
|
+
found = true
|
97
|
+
break
|
98
|
+
end
|
99
|
+
end
|
100
|
+
debug_to_log(dbg)
|
101
|
+
if found
|
102
|
+
if fail_if_found
|
103
|
+
failed_to_log("#{msg} at index #{index}.")
|
104
|
+
else
|
105
|
+
passed_to_log("#{msg} at index #{index}.")
|
106
|
+
end
|
107
|
+
index
|
108
|
+
else
|
109
|
+
if fail_if_found
|
110
|
+
passed_to_log("#{msg}")
|
111
|
+
else
|
112
|
+
failed_to_log("#{msg}")
|
113
|
+
end
|
114
|
+
nil
|
115
|
+
end
|
116
|
+
rescue
|
117
|
+
failed_to_log("Unable to #{msg}. '#{$!}'")
|
118
|
+
end
|
119
|
+
|
120
|
+
def get_index_of_row_with_textfield_value(table, strg, how, what, column_index = nil)
|
121
|
+
msg = "Find row in table :id=#{table.id} with value '#{strg}' in text_field #{how}=>'#{what} "
|
122
|
+
msg << " in column #{column_index}" if column_index
|
123
|
+
index = 0
|
124
|
+
found = false
|
125
|
+
table.rows.each do |row|
|
126
|
+
cell_count = get_cell_count(row)
|
127
|
+
index += 1
|
128
|
+
text = ''
|
129
|
+
if column_index
|
130
|
+
col_idx = column_index.to_i
|
131
|
+
if cell_count >= col_idx
|
132
|
+
if row[col_idx].text_field(how, what).exists?
|
133
|
+
value = row[col_idx].text_field(how, what).value
|
134
|
+
end
|
135
|
+
end
|
136
|
+
else
|
137
|
+
if row.text_field(how, what).exists?
|
138
|
+
value = row.text_field(how, what).value
|
139
|
+
sleep(0.25)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
if value and value =~ /#{strg}/
|
143
|
+
found = true
|
144
|
+
break
|
145
|
+
end
|
146
|
+
end
|
147
|
+
if found
|
148
|
+
passed_to_log("#{msg} at index #{index}.")
|
149
|
+
else
|
150
|
+
failed_to_log("#{msg}")
|
151
|
+
end
|
152
|
+
index
|
153
|
+
rescue
|
154
|
+
failed_to_log("Unable to #{msg}. '#{$!}'")
|
155
|
+
end
|
156
|
+
|
157
|
+
def get_index_for_table_containing_text(browser, strg, ordinal = 1)
|
158
|
+
msg = "Get index for table containing text '#{strg}'"
|
159
|
+
index = 0
|
160
|
+
found = 0
|
161
|
+
browser.tables.each do |t|
|
162
|
+
index += 1
|
163
|
+
if t.text =~ /#{strg}/
|
164
|
+
found += 1
|
165
|
+
if ordinal > 0 and found == ordinal
|
166
|
+
break
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
if found
|
171
|
+
passed_to_log("#{msg}: #{index}")
|
172
|
+
index
|
173
|
+
else
|
174
|
+
passed_to_log("#{msg}.")
|
175
|
+
nil
|
176
|
+
end
|
177
|
+
rescue
|
178
|
+
failed_to_log("Unable to find index of table containing text '#{strg}' '#{$!}' ")
|
179
|
+
end
|
180
|
+
|
181
|
+
def get_table_containing_text(browser, strg, ordinal = 1)
|
182
|
+
msg = "Get table #{ordinal} containing text '#{strg}'"
|
183
|
+
index = get_index_for_table_containing_text(browser, strg, ordinal)
|
184
|
+
if index
|
185
|
+
passed_to_log(msg)
|
186
|
+
browser.tables[index]
|
187
|
+
else
|
188
|
+
failed_to_log(msg)
|
189
|
+
nil
|
190
|
+
end
|
191
|
+
rescue
|
192
|
+
failed_to_log("Unable to find index of table containing text '#{strg}' '#{$!}' ")
|
193
|
+
end
|
194
|
+
|
195
|
+
def get_cell_text_from_row_with_string(nc_element, table_index, column_index, strg)
|
196
|
+
rgx = Regexp.new(strg)
|
197
|
+
text = ''
|
198
|
+
debug_to_log("strg:'#{strg}', rgx:'#{rgx}', table_index:'#{table_index}', column_index:'#{column_index}'")
|
199
|
+
nc_element.tables[table_index].each do |row|
|
200
|
+
cell_count = get_cell_count(row)
|
201
|
+
if cell_count >= column_index
|
202
|
+
#TODO this assumes column 1 is a number column
|
203
|
+
# debug_to_log("row:'#{row.cells}'")
|
204
|
+
cell_1 = row[1].text
|
205
|
+
if cell_1 =~ /\d+/
|
206
|
+
row_text = row.text
|
207
|
+
if row_text =~ rgx
|
208
|
+
text = row[column_index].text
|
209
|
+
break
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
text
|
215
|
+
end
|
216
|
+
|
217
|
+
def count_rows_with_string(container, table_index, strg)
|
218
|
+
hit = 0
|
219
|
+
container.tables[table_index].each do |row|
|
220
|
+
if get_cell_count(row) >= 1
|
221
|
+
# debug_to_log("#{__method__}: #{row.text}")
|
222
|
+
#TODO this assumes column 1 is a number column
|
223
|
+
if row[1].text =~ /\d+/
|
224
|
+
if row.text =~ /#{strg}/i
|
225
|
+
hit += 1
|
226
|
+
debug_to_log("#{__method__}: #{row.text}")
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
debug_to_log("#{__method__}: hit row count: #{hit}")
|
232
|
+
hit
|
233
|
+
end
|
234
|
+
|
235
|
+
def fetch_array_for_table_column(nc_element, table_index, column_index)
|
236
|
+
ary = []
|
237
|
+
nc_element.tables[table_index].each do |row|
|
238
|
+
if get_cell_count(row) >= column_index
|
239
|
+
#TODO this assumes column 1 is a number column
|
240
|
+
if row[1].text =~ /\d+/
|
241
|
+
ary << row[column_index].text
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
return ary f
|
246
|
+
end
|
247
|
+
|
248
|
+
def fetch_hash_for_table_column(table, column_index, start_row = 2)
|
249
|
+
hash = Hash.new
|
250
|
+
row_count = 0
|
251
|
+
table.each do |row|
|
252
|
+
row_count += 1
|
253
|
+
if get_cell_count(row) >= column_index
|
254
|
+
if row_count >= start_row
|
255
|
+
hash[row_count] = row[column_index].text
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
259
|
+
hash
|
260
|
+
end
|
261
|
+
|
262
|
+
def get_row_cells_text_as_array(row)
|
263
|
+
ary = []
|
264
|
+
row.each do |cell|
|
265
|
+
ary << cell.text
|
266
|
+
end
|
267
|
+
ary
|
268
|
+
end
|
269
|
+
|
270
|
+
def count_data_rows(container, data_index, column_index)
|
271
|
+
cnt = 0
|
272
|
+
# get_objects(container, :tables, true)
|
273
|
+
table = container.tables[data_index]
|
274
|
+
dump_table_and_rows(table)
|
275
|
+
if table
|
276
|
+
table.rows.each do |row|
|
277
|
+
if get_cell_count(row) >= column_index
|
278
|
+
#TODO this assumes column 1 is a number column
|
279
|
+
if row[column_index].text =~ /\d+/
|
280
|
+
cnt += 1
|
281
|
+
end
|
282
|
+
end
|
283
|
+
end
|
284
|
+
end
|
285
|
+
sleep_for(2)
|
286
|
+
cnt
|
287
|
+
end
|
288
|
+
|
289
|
+
def get_cell_count(row)
|
290
|
+
# if @browserAbbrev == 'IE' or $use_firewatir
|
291
|
+
row.cells.length
|
292
|
+
# else
|
293
|
+
# row.cell_count
|
294
|
+
# end
|
295
|
+
end
|
296
|
+
|
297
|
+
def exercise_sorting(browser, columnList, desc = '')
|
298
|
+
#TODO put rescue inside the do loop
|
299
|
+
#parameters: browser and a list of column link text values
|
300
|
+
#example: exercise_sorting(browser,['Division', 'Payee', 'Date'], 'Sortable columns on this page')
|
301
|
+
columnList.each do |column|
|
302
|
+
click(browser, :link, :text, column, desc)
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
alias validate_sorting exercise_sorting
|
307
|
+
|
308
|
+
def verify_column_sort(browser, nc_element, strg, table_index, column_index=nil)
|
309
|
+
mark_testlevel("Verify Column Sort '#{strg}'", 3)
|
310
|
+
if not column_index
|
311
|
+
column_index = get_index_for_column_head(nc_element, table_index, strg)
|
312
|
+
end
|
313
|
+
|
314
|
+
if column_index
|
315
|
+
bfr_ary = fetch_array_for_table_column(nc_element, table_index, column_index)
|
316
|
+
if strg =~ /date/i
|
317
|
+
exp_ary = bfr_ary.sort { |x, y| Date.parse(x) <=> Date.parse(y) }
|
318
|
+
else
|
319
|
+
exp_ary = bfr_ary.sort { |x, y| x.gsub(',', '') <=> y.gsub(',', '') }
|
320
|
+
end
|
321
|
+
|
322
|
+
if click_text(browser, strg)
|
323
|
+
if column_index
|
324
|
+
sleep_for(2.5)
|
325
|
+
else
|
326
|
+
sleep_for(1)
|
327
|
+
end
|
328
|
+
act_ary = fetch_array_for_table_column(nc_element, table_index, column_index)
|
329
|
+
|
330
|
+
if exp_ary == act_ary
|
331
|
+
passed_to_log("Click on column '#{strg}' produces expected sorted list.")
|
332
|
+
true
|
333
|
+
else
|
334
|
+
failed_to_log("Click on column '#{strg}' fails to produce expected sorted list.")
|
335
|
+
debug_to_log("Original order ['#{bfr_ary.join("', '")}']")
|
336
|
+
debug_to_log("Expected order ['#{exp_ary.join("', '")}']")
|
337
|
+
debug_to_log(" Actual order ['#{act_ary.join("', '")}']")
|
338
|
+
end
|
339
|
+
end
|
340
|
+
else
|
341
|
+
failed_to_log("Unable to locate column index for '#{strg}' to verify sort.")
|
342
|
+
end
|
343
|
+
rescue
|
344
|
+
failed_to_log("Unable to verify sort on column '#{strg}'. #{$!}")
|
345
|
+
end
|
346
|
+
|
347
|
+
def verify_column_sort_temp_ff(browser, strg, table_index, column_index=nil)
|
348
|
+
mark_testlevel("Verify Column Sort '#{strg}'", 3)
|
349
|
+
|
350
|
+
if not column_index
|
351
|
+
column_index = get_index_for_column_head(browser, table_index, strg)
|
352
|
+
end
|
353
|
+
|
354
|
+
if column_index
|
355
|
+
bfr_ary = fetch_array_for_table_column(browser, table_index, column_index)
|
356
|
+
if strg =~ /date/i
|
357
|
+
exp_ary = bfr_ary.sort { |x, y| Date.parse(x) <=> Date.parse(y) }
|
358
|
+
else
|
359
|
+
exp_ary = bfr_ary.sort { |x, y| x.gsub(',', '') <=> y.gsub(',', '') }
|
360
|
+
end
|
361
|
+
|
362
|
+
if click_text(browser, strg)
|
363
|
+
sleep_for(3)
|
364
|
+
act_ary = fetch_array_for_table_column(browser, table_index, column_index)
|
365
|
+
|
366
|
+
if exp_ary == act_ary
|
367
|
+
passed_to_log("Click on column '#{strg}' produces expected sorted list.")
|
368
|
+
true
|
369
|
+
else
|
370
|
+
failed_to_log("Click on column '#{strg}' fails to produce expected sorted list.")
|
371
|
+
debug_to_log("Original order ['#{bfr_ary.join("', '")}']")
|
372
|
+
debug_to_log("Expected order ['#{exp_ary.join("', '")}']")
|
373
|
+
debug_to_log(" Actual order ['#{act_ary.join("', '")}']")
|
374
|
+
end
|
375
|
+
end
|
376
|
+
else
|
377
|
+
failed_to_log("Unable to locate column index for '#{strg}' to verify sort.")
|
378
|
+
end
|
379
|
+
rescue
|
380
|
+
failed_to_log("Unable to verify sort on column '#{strg}'. #{$!}")
|
381
|
+
end
|
382
|
+
|
383
|
+
#TODO unstub
|
384
|
+
def verify_column_hidden(browser, panel, table_index, column_name)
|
385
|
+
passed_to_log("TEST STUBBED: Column '#{column_name}' is hidden.")
|
386
|
+
return true
|
387
|
+
# id = @column_data_display_ids[column_name]
|
388
|
+
# ok = false
|
389
|
+
|
390
|
+
# row = panel.tables[2][3]
|
391
|
+
|
392
|
+
# row.each do |cell|
|
393
|
+
## strg = cell.to_s
|
394
|
+
## insp = cell.inspect
|
395
|
+
## ole = cell.ole_object
|
396
|
+
## anId = cell.attribute_value(:id)
|
397
|
+
# text = cell.text
|
398
|
+
# if text =~ /#{id}/
|
399
|
+
# if cell.to_s =~ /hidden/
|
400
|
+
# passed_to_log( "Column '#{column_name}' is hidden.")
|
401
|
+
# else
|
402
|
+
# failed_to_log( "Column '#{column_name}' is not hidden.")
|
403
|
+
# end
|
404
|
+
# ok = true
|
405
|
+
# end
|
406
|
+
# end
|
407
|
+
# if not ok
|
408
|
+
# failed_to_log( "Column '#{column_name}' not found.")
|
409
|
+
# end
|
410
|
+
# rescue
|
411
|
+
# failed_to_log("Unable to verify column '#{column_name}' is hidden: '#{$!}' (#{__LINE__})")
|
412
|
+
end
|
413
|
+
|
414
|
+
#TODO unstub
|
415
|
+
def verify_column_hidden_temp_ff(browser, data_index, row_index, column_name)
|
416
|
+
passed_to_log("TEST STUBBED: Column '#{column_name}' is hidden.")
|
417
|
+
return true
|
418
|
+
|
419
|
+
row = browser.tables[data_index][row_index]
|
420
|
+
# debug_to_log( "#{row.to_a}")
|
421
|
+
#TODO cells are all still there in the row. Need to check for clue to hidden/visible in other tag attributes
|
422
|
+
act_ary = get_row_cells_text_as_array(row)
|
423
|
+
|
424
|
+
if not act_ary.include?(column_name)
|
425
|
+
passed_to_log("Column '#{column_name}' is hidden.")
|
426
|
+
else
|
427
|
+
failed_to_log("Column '#{column_name}' is not hidden.")
|
428
|
+
end
|
429
|
+
end
|
430
|
+
|
431
|
+
#TODO unstub
|
432
|
+
def verify_column_visible_temp_ff(browser, data_index, row_index, column_name)
|
433
|
+
passed_to_log("TEST STUBBED: Column '#{column_name}' is visible.")
|
434
|
+
return true
|
435
|
+
|
436
|
+
row = browser.tables[data_index][row_index]
|
437
|
+
#TODO cells are all still there in the row. Need to check for clue to hidden/visible in other tag attributes
|
438
|
+
act_ary = get_row_cells_text_as_array(row)
|
439
|
+
|
440
|
+
if act_ary.include?(column_name)
|
441
|
+
passed_to_log("Column '#{column_name}' is visible.")
|
442
|
+
else
|
443
|
+
failed_to_log("Column '#{column_name}' is not visible.")
|
444
|
+
end
|
445
|
+
end
|
446
|
+
|
447
|
+
#TODO unstub
|
448
|
+
def verify_column_visible(browser, panel, table_index, column_name)
|
449
|
+
|
450
|
+
passed_to_log("TEST STUBBED: Column '#{column_name}' is visible.")
|
451
|
+
return true
|
452
|
+
|
453
|
+
# id = @column_data_display_ids[column_name]
|
454
|
+
# ok = false
|
455
|
+
# row = panel.tables[table_index][1]
|
456
|
+
# row.each do |cell|
|
457
|
+
# if cell.id == id
|
458
|
+
# if not cell.to_s =~ /hidden/
|
459
|
+
# passed_to_log("Column '#{column_name}' is visible.")
|
460
|
+
# else
|
461
|
+
# failed_to_log("Column '#{column_name}' is not visible.")
|
462
|
+
# end
|
463
|
+
# ok = true
|
464
|
+
# end
|
465
|
+
# end
|
466
|
+
# if not ok
|
467
|
+
# failed_to_log("Column '#{column_name}' not found.")
|
468
|
+
# end
|
469
|
+
rescue
|
470
|
+
failed_to_log("Unable to verify column '#{column_name} is visible': '#{$!}' (#{__LINE__})")
|
471
|
+
end
|
472
|
+
|
473
|
+
def verify_column_order(browser, table_index, row_index, exp_ary)
|
474
|
+
mark_testlevel("Verify Column Order", 2)
|
475
|
+
row = browser.tables[table_index][row_index]
|
476
|
+
act_ary = get_row_cells_text_as_array(row)
|
477
|
+
|
478
|
+
if exp_ary == act_ary
|
479
|
+
passed_to_log("Column order [#{act_ary.join(', ')}] appeared as expected.")
|
480
|
+
else
|
481
|
+
failed_to_log("Column order [#{act_ary.join(', ')}] not as expected [#{exp_ary.join(', ')}].")
|
482
|
+
end
|
483
|
+
sleep_for(1)
|
484
|
+
end
|
485
|
+
|
486
|
+
end
|