awetestlib 0.1.3-x86-mingw32 → 0.1.5-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.
Files changed (50) hide show
  1. data/awetestlib.windows.gemspec +1 -1
  2. data/bin/awetestlib +11 -4
  3. data/bin/awetestlib-helpers.rb +28 -1
  4. data/bin/awetestlib-netbeans-setup.rb +39 -0
  5. data/bin/awetestlib-rubymine-setup.rb +33 -0
  6. data/images/logo.png +0 -0
  7. data/lib/awetestlib/html_report.rb +171 -0
  8. data/lib/{regression → awetestlib}/logging.rb +10 -43
  9. data/lib/awetestlib/regression/browser.rb +1233 -0
  10. data/lib/awetestlib/regression/drag_and_drop.rb +379 -0
  11. data/lib/awetestlib/regression/find.rb +431 -0
  12. data/lib/awetestlib/regression/legacy.rb +45 -0
  13. data/lib/awetestlib/regression/page_data.rb +190 -0
  14. data/lib/awetestlib/regression/runner.rb +306 -0
  15. data/lib/awetestlib/regression/tables.rb +491 -0
  16. data/lib/awetestlib/regression/user_input.rb +1256 -0
  17. data/lib/awetestlib/regression/utilities.rb +895 -0
  18. data/lib/awetestlib/regression/validations.rb +1184 -0
  19. data/lib/awetestlib/regression/waits.rb +391 -0
  20. data/lib/awetestlib/runner.rb +16 -0
  21. data/lib/awetestlib.rb +4 -4
  22. data/lib/version.rb +2 -2
  23. data/setup_samples/sample_netbeans/demo.rb +86 -0
  24. data/setup_samples/sample_netbeans/nbproject/configs/Demo.properties +2 -0
  25. data/setup_samples/sample_netbeans/nbproject/private/config.properties +1 -0
  26. data/setup_samples/sample_netbeans/nbproject/private/configs/Demo.properties +1 -0
  27. data/setup_samples/sample_netbeans/nbproject/private/private.properties +2 -0
  28. data/setup_samples/sample_netbeans/nbproject/project.properties +5 -0
  29. data/setup_samples/sample_netbeans/nbproject/project.xml +13 -0
  30. data/setup_samples/sample_rubymine/.idea/.name +1 -0
  31. data/setup_samples/sample_rubymine/.idea/encodings.xml +5 -0
  32. data/setup_samples/sample_rubymine/.idea/misc.xml +5 -0
  33. data/setup_samples/sample_rubymine/.idea/modules.xml +9 -0
  34. data/setup_samples/sample_rubymine/.idea/sample_rubymine.iml +9 -0
  35. data/setup_samples/sample_rubymine/.idea/scopes/scope_settings.xml +5 -0
  36. data/setup_samples/sample_rubymine/.idea/vcs.xml +7 -0
  37. data/setup_samples/sample_rubymine/.idea/workspace.xml +213 -0
  38. data/setup_samples/sample_rubymine/demo.rb +86 -0
  39. metadata +44 -19
  40. data/lib/regression/browser.rb +0 -1259
  41. data/lib/regression/drag_and_drop.rb +0 -374
  42. data/lib/regression/find.rb +0 -426
  43. data/lib/regression/legacy.rb +0 -40
  44. data/lib/regression/page_data.rb +0 -185
  45. data/lib/regression/runner.rb +0 -278
  46. data/lib/regression/tables.rb +0 -486
  47. data/lib/regression/user_input.rb +0 -1255
  48. data/lib/regression/utilities.rb +0 -891
  49. data/lib/regression/validations.rb +0 -1179
  50. data/lib/regression/waits.rb +0 -387
@@ -1,374 +0,0 @@
1
- module DragAndDrop
2
-
3
- def verify_element_inside(inner_element, outer_element, desc = '')
4
- mark_testlevel("#{__method__.to_s.titleize}", 3)
5
- msg = "#{inner_element.class.to_s} (:id=#{inner_element.id}) is fully enclosed by #{outer_element.class.to_s} (:id=#{outer_element.id})."
6
- msg << " #{desc}" if desc.length > 0
7
- if overlay?(inner_element, outer_element, :inside)
8
- failed_to_log(msg)
9
- else
10
- passed_to_log(msg)
11
- true
12
- end
13
- rescue
14
- failed_to_log("Unable to verify that #{msg} '#{$!}'")
15
- end
16
-
17
- def verify_no_element_overlap(browser, above_element, above_how, above_what, below_element, below_how, below_what, side, desc = '')
18
- mark_testlevel("#{__method__.to_s.titleize}", 3)
19
- msg = "#{above_element.to_s.titleize} #{above_how}=>#{above_what} does not overlap "+
20
- "#{below_element.to_s.titleize} #{below_how}=>#{below_what} at the #{side}."
21
- msg << " #{desc}" if desc.length > 0
22
- above = browser.element(above_how, above_what)
23
- below = browser.element(below_how, below_what)
24
- if overlay?(above, below, side)
25
- failed_to_log(msg)
26
- else
27
- passed_to_log(msg)
28
- true
29
- end
30
- rescue
31
- failed_to_log("Unable to verify that #{msg} '#{$!}'")
32
- end
33
-
34
- def overlay?(inner, outer, side = :bottom)
35
- #mark_testlevel("#{__method__.to_s.titleize}", 3)
36
- inner_t, inner_b, inner_l, inner_r = inner.bounding_rectangle_offsets
37
- outer_t, outer_b, outer_l, outer_r = outer.bounding_rectangle_offsets
38
- #overlay = false
39
- case side
40
- when :bottom
41
- overlay = inner_b > outer_t
42
- when :top
43
- overlay = inner_t > outer_t
44
- when :left
45
- overlay = inner_l < outer_r
46
- when :right
47
- overlay = inner_r > outer_r
48
- when :inside
49
- overlay = !(inner_t > outer_t and
50
- inner_r < outer_r and
51
- inner_l > outer_l and
52
- inner_b < outer_b)
53
- else
54
- overlay = (inner_t > outer_b or
55
- inner_r > outer_l or
56
- inner_l < outer_r or
57
- inner_b < outer_t)
58
- end
59
- overlay
60
- rescue
61
- failed_to_log("Unable to determine overlay. '#{$!}'")
62
- end
63
-
64
- def hover(browser, element, wait = 2)
65
- w1, h1, x1, y1, xc1, yc1, xlr1, ylr1 = get_element_coordinates(browser, element, true)
66
- @ai.MoveMouse(xc1, yc1)
67
- sleep_for(1)
68
- end
69
-
70
- def move_element_with_handle(browser, element, handle_id, dx, dy)
71
- # msg = "Move element "
72
- # w1, h1, x1, y1, xc1, yc1, xlr1, ylr1 = get_element_coordinates(browser, element, true)
73
- # newx = w1 + dx
74
- # newy = h1 + dy
75
- # msg << " by [#{dx}, #{dy}] to expected [[#{newx}, #{newy}] "
76
- # handle = get_resize_handle(element, handle_id)
77
- # hw, hh, hx, hy, hxc, hyc, hxlr, hylr = get_element_coordinates(browser, handle, true)
78
-
79
- # drag_and_drop(hxc, hyc, dx, dy)
80
-
81
- # w2, h2, x2, y2, xc2, yc2, xlr2, ylr2 = get_element_coordinates(browser, element, true)
82
-
83
- # xerr = x2 - newx
84
- # yerr = y2 - newy
85
- # xdsp = (x1 - x2).abs
86
- # ydsp = (y1 - y2).abs
87
-
88
- # if x2 == newx and y2 == newy
89
- # msg << "succeeded."
90
- # passed_to_log(msg)
91
- # else
92
- # msg << "failed. "
93
- # failed_to_log(msg)
94
- # debug_to_log("x: actual #{x2}, error #{xerr}, displace #{xdsp}. y: actual #{y2}, error #{yerr}, displace #{ydsp}.")
95
- # end
96
-
97
- end
98
-
99
- def resize_element_with_handle(browser, element, target, dx, dy=nil)
100
- #TODO enhance to accept differing percentages in each direction
101
- msg = "Resize element "
102
- w1, h1, x1, y1, xc1, yc1, xlr1, ylr1 = get_element_coordinates(browser, element, true)
103
- if dy
104
- deltax = dx
105
- deltay = dy
106
- neww = w1 + dx
107
- newh = h1 + dy
108
- msg << " by [#{dx}, #{dy}] " #"" to expected dimension [#{neww}, #{newh}] "
109
- else
110
- deltax, deltay, neww, newh = adjust_dimensions_by_percent(w1, h1, dx, true)
111
- msg << "by #{dx} percent " #"" to expected dimension [#{neww}, #{newh}] "
112
- end
113
- handle = get_resize_handle_by_class(element, target) #, true)
114
- sleep_for(0.5)
115
- hw, hh, hx, hy, hxc, hyc, hxlr, hylr = get_element_coordinates(browser, handle, true)
116
- hxlr_diff = 0
117
- hylr_diff = 0
118
-
119
- # TODO These adjustments are adhoc and empirical. Need to be derived more rigorously
120
- if @browserAbbrev == 'IE'
121
- hxlr_diff = (xlr1 - hxlr)
122
- hylr_diff = (ylr1 - hylr)
123
- x_start = hxlr - 2
124
- y_start = hylr - 2
125
- else
126
- hxlr_diff = (xlr1 - hxlr) / 2 unless (xlr1 - hxlr) == 0
127
- hylr_diff = (ylr1 - hylr) / 2 unless (ylr1 - hylr) == 0
128
- x_start = hxlr
129
- y_start = hylr
130
- end
131
-
132
- newxlr = xlr1 + deltax
133
- newylr = ylr1 + deltay
134
- # msg << ", lower right [#{newxlr}, #{newylr}] - "
135
- sleep_for(0.5)
136
-
137
- drag_and_drop(x_start, y_start, deltax, deltay)
138
-
139
- sleep_for(1.5)
140
- w2, h2, x2, y2, xc2, yc2, xlr2, ylr2 = get_element_coordinates(browser, element, true)
141
-
142
- werr = w2 - neww
143
- herr = h2 - newh
144
-
145
- # TODO This adjustment is adhoc and empirical. Needs to be derived more rigorously
146
- xlrerr = xlr2 - newxlr + hxlr_diff
147
- ylrerr = ylr2 - newylr + hylr_diff
148
-
149
- xlrdsp = (xlr1 - xlr2).abs
150
- ylrdsp = (ylr1 - ylr2).abs
151
-
152
- debug_to_log("\n" +
153
- "\t\t hxlr_diff: #{hxlr_diff}\n" +
154
- "\t\t hylr_diff: #{hylr_diff}\n" +
155
- "\t\t werr: #{werr}\n" +
156
- "\t\t herr: #{herr}\n" +
157
- "\t\t xlrerr: #{xlrerr}\n" +
158
- "\t\t ylrerr: #{ylrerr}\n" +
159
- "\t\t xlrdsp: #{xlrdsp}\n" +
160
- "\t\t ylrdsp: #{ylrdsp}\n" +
161
- "\t\t @min_width: #{@min_width}\n" +
162
- "\t\t@min_height: #{@min_height}\n" +
163
- "\t\t x tol: #{@x_tolerance}\n" +
164
- "\t\t y tol: #{@y_tolerance}\n"
165
- )
166
-
167
- #TODO Add check that window _was_ resized.
168
- x_ok, x_msg = validate_move(w2, xlrerr, @x_tolerance, @min_width, xlr2)
169
- y_ok, y_msg = validate_move(h2, ylrerr, @y_tolerance, @min_height, ylr2)
170
- msg = msg + "x: #{x_msg}, y: #{y_msg}"
171
-
172
- if x_ok and y_ok
173
- passed_to_log(msg)
174
- else
175
- failed_to_log(msg)
176
- debug_to_log("x - actual #{xlr2}, error #{xlrerr}, displace #{xlrdsp}, y - actual #{ylr2}, error #{ylrerr}, displace #{ylrdsp}.")
177
- end
178
- sleep_for(1)
179
- rescue
180
- failed_to_log("Unable to validate resize. #{$!} (#{__LINE__})")
181
- sleep_for(1)
182
- end
183
-
184
- # :category: GUI
185
- def get_resize_handle_by_id(element, id, dbg=nil)
186
- handle = get_div_by_id(element, id, dbg)
187
- sleep_for(1)
188
- handle.flash(5)
189
- return handle
190
- end
191
-
192
- # :category: GUI
193
- def get_resize_handle_by_class(element, strg, dbg=nil)
194
- handle = get_div_by_class(element, strg, dbg)
195
- sleep_for(0.5)
196
- handle.flash(5)
197
- return handle
198
- end
199
-
200
- # :category: GUI
201
- def get_element_coordinates(browser, element, dbg=nil)
202
- bx, by, bw, bh = get_browser_coord(browser, dbg)
203
- if @browserAbbrev == 'IE'
204
- x_hack = @horizontal_hack_ie
205
- y_hack = @vertical_hack_ie
206
- elsif @browserAbbrev == 'FF'
207
- x_hack = @horizontal_hack_ff
208
- y_hack = @vertical_hack_ff
209
- end
210
- sleep_for(1)
211
- w, h = element.dimensions.to_a
212
- xc, yc = element.client_offset.to_a
213
- # xcc, ycc = element.client_center.to_a
214
- xcc = xc + w/2
215
- ycc = yc + h/2
216
- # screen offset:
217
- xs = bx + x_hack + xc - 1
218
- ys = by + y_hack + yc - 1
219
- # screen center:
220
- xsc = xs + w/2
221
- ysc = ys + h/2
222
- xslr = xs + w
223
- yslr = ys + h
224
- if dbg
225
- debug_to_log(
226
- "\n\t\tElement: #{element.inspect}"+
227
- "\n\t\tbrowser screen offset: x: #{bx} y: #{by}"+
228
- "\n\t\t dimensions: x: #{w} y: #{h}"+
229
- "\n\t\t client offset x: #{xc} y: #{yc}"+
230
- "\n\t\t screen offset x: #{xs} y: #{ys}"+
231
- "\n\t\t client center x: #{xcc} y: #{ycc}"+
232
- "\n\t\t screen center x: #{xsc} y: #{ysc}"+
233
- "\n\t\t screen lower right x: #{xslr} y: #{yslr}")
234
- end
235
- [w, h, xs, ys, xsc, ysc, xslr, yslr]
236
- end
237
-
238
- def adjust_dimensions_by_percent(w, h, p, returnnew=nil)
239
- p += 100
240
- nw = (w * (p/100.0)).to_i
241
- nh = (h * (p/100.0)).to_i
242
- deltaw = nw - w
243
- deltah = nh - h
244
- if returnnew
245
- [deltaw, deltah, nw, nh]
246
- else
247
- [deltaw, deltah]
248
- end
249
- end
250
-
251
- def get_browser_coord(browser=nil, dbg=nil)
252
- browser = @myBrowser if not browser
253
- title = browser.title
254
- x = @ai.WinGetPosX(title)
255
- y = @ai.WinGetPosY(title)
256
- w = @ai.WinGetPosWidth(title)
257
- h = @ai.WinGetPosHeight(title)
258
- if dbg
259
- debug_to_log("\n\t\tBrowser #{browser.inspect}\n"+
260
- "\t\tdimensions: x: #{w} y: #{h}"+
261
- "\t\tscreen offset x: #{x} y: #{y}")
262
- end
263
- [x, y, w, h]
264
- end
265
-
266
- def drag_and_drop(x1, y1, dx, dy, speed=nil)
267
- speed = 10 if not speed
268
- x2 = x1 + dx
269
- y2 = y1 + dy
270
- debug_to_log("drag_and_drop: start: [#{x1}, #{y1}] end: [#{x2}, #{y2}]")
271
-
272
- @ai.MouseMove(x1, y1, speed)
273
- @ai.MouseClick("primary", x1, y1)
274
- sleep_for(0.5)
275
- @ai.MouseClick("primary", x1, y1)
276
- sleep_for(0.5)
277
- @ai.MouseClickDrag("primary", x1, y1, x2, y2, speed)
278
- end
279
-
280
- def drag_and_drop_element(browser, element, dx, dy, speed = nil)
281
- speed = 10 if not speed
282
- w1, h1, x1, y1, xc1, yc1, xlr1, ylr1 = get_element_coordinates(browser, element, true)
283
- msg = "Move #{element} by [#{dx}, #{dy}] from center[#{xc1}, #{yc1}] "
284
- newxc = xc1 + dx
285
- newyc = yc1 + dy
286
- msg << "to center[[#{newxc}, #{newyc}]"
287
- sleep_for(0.5)
288
-
289
- drag_and_drop(xc1, yc1, dx, dy)
290
-
291
- sleep_for(1)
292
- w2, h2, x2, y2, xc2, yc2, xlr2, ylr2 = get_element_coordinates(browser, element, true)
293
-
294
- # TODO This adjustment is adhoc and empirical. Needs to be derived more rigorously
295
- xcerr = xc2 - xc1
296
- ycerr = yc2 - yc1
297
-
298
- debug_to_log("\n" +
299
- "\t\t xc1: #{xc1}\n" +
300
- "\t\t yc1: #{yc1}\n" +
301
- "\t\t xc2: #{xc2}\n" +
302
- "\t\t yc2: #{yc2}\n" +
303
- "\t\t xcerr: #{xlrerr}\n" +
304
- "\t\t ycerr: #{ylrerr}\n" +
305
- "\t\t x tol: #{@x_tolerance}\n" +
306
- "\t\t y tol: #{@y_tolerance}\n"
307
- )
308
-
309
- #TODO Add check that window _was_ resized.
310
- x_ok, x_msg = validate_drag_drop(xcerr, @x_tolerance, newxc, xc2)
311
- y_ok, y_msg = validate_drag_drop(ycerr, @y_tolerance, newyc, yc2)
312
- msg = msg + "x: #{x_msg}, y: #{y_msg}"
313
-
314
- if x_ok and y_ok
315
- passed_to_log(msg)
316
- else
317
- failed_to_log(msg)
318
- end
319
- sleep_for(1)
320
- rescue
321
- failed_to_log("Unable to validate drag and drop. #{$!} (#{__LINE__})")
322
- sleep_for(1)
323
- end
324
-
325
- def right_click(element)
326
- x = element.left_edge_absolute + 2
327
- y = element.top_edge_absolute + 2
328
- @ai.MouseClick("secondary", x, y)
329
- end
330
-
331
- def left_click(element)
332
- x = element.left_edge_absolute + 2
333
- y = element.top_edge_absolute + 2
334
- @ai.MouseClick("primary", x, y)
335
- end
336
-
337
- def screen_offset(element, browser=nil)
338
- bx, by, bw, bh = get_browser_coord(browser)
339
- ex = element.left_edge
340
- ey = element.top_edge
341
- [bx + ex, by + ey]
342
- end
343
-
344
- def screen_center(element, browser=nil)
345
- bx, by, bw, bh = get_browser_coord(browser)
346
- w, h = element.dimensions.to_a
347
- cx = bx + w/2
348
- cy = by + h/2
349
- [cx, cy]
350
- end
351
-
352
- def screen_lower_right(element, browser=nil)
353
- bx, by, bw, bh = get_browser_coord(browser)
354
- w, h = element.dimensions.to_a
355
- [bx + w, by + h]
356
- end
357
-
358
- def verify_resize(d, err, tol, min, act)
359
- ary = [false, "failed, actual #{act} err #{err}"]
360
- if err == 0
361
- ary = [true, 'succeeded ']
362
- #TODO need to find way to calculate this adjustment
363
- elsif d <= min + 4
364
- ary = [true, "reached minimum (#{min}) "]
365
- elsif err.abs <= tol
366
- ary = [true, "within tolerance (+-#{tol}px) "]
367
- end
368
- ary
369
- end
370
-
371
- alias validate_move verify_resize
372
- alias validate_resize verify_resize
373
-
374
- end