rudra 1.0.12 → 1.0.13

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 (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rudra.rb +22 -108
  3. metadata +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 11f829929ce5e13efb620e44b35f6882942dd2f8dca206db78fa19bfc4ba64d4
4
- data.tar.gz: 65dc1df4a7fe8b87c1a20cc79e9895e8c839f6e4f5c671ac9197f03fadf53ec1
3
+ metadata.gz: 8a3a4f9fb5eee63f5a3f29102e0c1161256fb30b098c108ca3c415663b062113
4
+ data.tar.gz: 72bf75e1a6bdd4913c944944b6f0a7427082ce38fe7800202710e72a3f012e23
5
5
  SHA512:
6
- metadata.gz: e1f367f85982ad45befc3214260f1236f8b5e808cc6db493b1066671c2571419a25d0aea661eda256d45c486d71bf8ed31e0d29c6ecbac58b4c3257df69e4322
7
- data.tar.gz: d31e14987b7abed8796112fe38f1301ede0214dabe9b8af31211644ba15cf4fb5b8953f66332ab726eb666999a867a225a1f563dab64099cb9848ee451145496
6
+ metadata.gz: 7f6a25ab7afd10bdc21c73c3c09710791a69b7ffb3d887a285a2f94b6069d83c7ab07a0d1f62b541dfd7e20935661be94491f731c9a79a9d2f035a3b8e760538
7
+ data.tar.gz: adc43a16f2f13f0a59acaa41de6c790ab88f9c19caf8372b9951c79ca8428d206cf13d9f80806dc7252acc05174b81880f8f3c411447aefefbfa92d896c6216b
data/lib/rudra.rb CHANGED
@@ -24,6 +24,12 @@ class Rudra
24
24
  name partial_link_text tag_name xpath
25
25
  ].freeze
26
26
 
27
+ # Attributes
28
+ ATTRIBUTES = %i[
29
+ browser driver install_dir locale
30
+ headless log_prefix timeout verbose
31
+ ].freeze
32
+
27
33
  attr_reader :browser, :driver, :install_dir, :locale,
28
34
  :headless, :log_prefix, :timeout, :verbose
29
35
 
@@ -67,14 +73,12 @@ class Rudra
67
73
  # Initialize ActionBuilder
68
74
  # @return [Selenium::WebDriver::ActionBuilder] ActionBuilder
69
75
  def action
70
- log
71
76
  driver.action
72
77
  end
73
78
 
74
79
  # Get the active element
75
80
  # @return [Selenium::WebDriver::Element] the active element
76
81
  def active_element
77
- log
78
82
  driver.switch_to.active_element
79
83
  end
80
84
 
@@ -86,43 +90,36 @@ class Rudra
86
90
  # @option opts [Boolean] :secure (false) a boolean
87
91
  # @option opts [Time, DateTime, Numeric, nil] :expires (nil) expiry date
88
92
  def add_cookie(opts = {})
89
- log(opts)
90
93
  driver.manage.add_cookie(opts)
91
94
  end
92
95
 
93
96
  # Accept an alert
94
97
  def alert_accept
95
- log
96
98
  switch_to_alert.accept
97
99
  end
98
100
 
99
101
  # Dismiss an alert
100
102
  def alert_dismiss
101
- log
102
103
  switch_to_alert.dismiss
103
104
  end
104
105
 
105
106
  # Send keys to an alert
106
107
  def alert_send_keys(keys)
107
- log(keys)
108
108
  switch_to_alert.send_keys(keys)
109
109
  end
110
110
 
111
111
  # Move back a single entry in the browser's history
112
112
  def back
113
- log
114
113
  driver.navigate.back
115
114
  end
116
115
 
117
116
  # Open a blank page
118
117
  def blank
119
- log
120
118
  open('about:blank')
121
119
  end
122
120
 
123
121
  # Close the current window, or the browser if no windows are left
124
122
  def close
125
- log
126
123
  driver.close
127
124
  end
128
125
 
@@ -130,27 +127,23 @@ class Rudra
130
127
  # @param [String] name the name of the cookie
131
128
  # @return [Hash, nil] the cookie, or nil if it wasn't found
132
129
  def cookie_named(name)
133
- log(name)
134
130
  driver.manage.cookie_named(name)
135
131
  end
136
132
 
137
133
  # Get the URL of the current page
138
134
  # @return (String) the URL of the current page
139
135
  def current_url
140
- log
141
136
  driver.current_url
142
137
  end
143
138
 
144
139
  # Delete all cookies
145
140
  def delete_all_cookies
146
- log
147
141
  driver.manage.delete_all_cookies
148
142
  end
149
143
 
150
144
  # Delete the cookie with the given name
151
145
  # @param [String] name the name of the cookie
152
146
  def delete_cookie(name)
153
- log(name)
154
147
  driver.manage.delete_cookie(name)
155
148
  end
156
149
 
@@ -162,7 +155,6 @@ class Rudra
162
155
  # @return [Selenium::WebDriver::Element, Integer, Float, Boolean, NilClass,
163
156
  # String, Array] the value returned from the script
164
157
  def execute_script(script, *args)
165
- log
166
158
  driver.execute_script(script, *args)
167
159
  end
168
160
 
@@ -171,8 +163,6 @@ class Rudra
171
163
  # identify the element or Selenium::WebDriver::Element
172
164
  # @return [Selenium::WebDriver::Element] the element found
173
165
  def find_element(locator)
174
- log(locator)
175
-
176
166
  return locator if locator.is_a?(Selenium::WebDriver::Element)
177
167
 
178
168
  element = nil
@@ -196,8 +186,6 @@ class Rudra
196
186
  # @param [String] locator the locator to identify the elements
197
187
  # @return [Array<Selenium::WebDriver::Element>] the elements found
198
188
  def find_elements(locator)
199
- log(locator)
200
-
201
189
  how, what = parse_locator(locator)
202
190
  driver.find_elements(how, what) ||
203
191
  abort("Failed to find elements: #{locator}")
@@ -205,32 +193,26 @@ class Rudra
205
193
 
206
194
  # Move forward a single entry in the browser's history
207
195
  def forward
208
- log
209
196
  driver.navigate.forward
210
197
  end
211
198
 
212
199
  # Make the current window full screen
213
200
  def full_screen
214
- log
215
201
  driver.manage.window.full_screen
216
202
  end
217
203
 
218
204
  # Quit the browser
219
205
  def quit
220
- log
221
206
  driver.quit
222
207
  end
223
208
 
224
209
  # Maximize the current window
225
210
  def maximize
226
- log
227
211
  driver.manage.window.maximize
228
212
  end
229
213
 
230
214
  # Maximize the current window to the size of the screen
231
215
  def maximize_to_screen
232
- log
233
-
234
216
  size = execute_script(%(
235
217
  return { width: window.screen.width, height: window.screen.height };
236
218
  ))
@@ -241,7 +223,6 @@ class Rudra
241
223
 
242
224
  # Minimize the current window
243
225
  def minimize
244
- log
245
226
  driver.manage.window.minimize
246
227
  end
247
228
 
@@ -249,14 +230,12 @@ class Rudra
249
230
  # @param [Integer] point_x the x coordinate
250
231
  # @param [Integer] point_y the y coordinate
251
232
  def move_window_to(point_x, point_y)
252
- log(point_x, point_y)
253
233
  driver.manage.window.move_to(point_x, point_y)
254
234
  end
255
235
 
256
236
  # Open a new tab
257
237
  # @return [String] the id of the new tab obtained from #window_handles
258
238
  def new_tab
259
- log
260
239
  execute_script('window.open();')
261
240
  window_handles.last
262
241
  end
@@ -264,7 +243,6 @@ class Rudra
264
243
  # Open a new window
265
244
  # @param [String] name the name of the window
266
245
  def new_window(name)
267
- log(name)
268
246
  execute_script(%(
269
247
  var w = Math.max(
270
248
  document.documentElement.clientWidth, window.innerWidth || 0
@@ -279,20 +257,17 @@ class Rudra
279
257
  # Open the specified URL in the browser
280
258
  # @param [String] url the URL of the page to open
281
259
  def open(url)
282
- log(url)
283
260
  driver.get(url)
284
261
  end
285
262
 
286
263
  # Get the source of the current page
287
264
  # @return (String) the source of the current page
288
265
  def page_source
289
- log
290
266
  driver.page_source
291
267
  end
292
268
 
293
269
  # Refresh the current pagef
294
270
  def refresh
295
- log
296
271
  driver.navigate.refresh
297
272
  end
298
273
 
@@ -300,14 +275,12 @@ class Rudra
300
275
  # @param [Integer] width the width of the window
301
276
  # @param [Integer] height the height of the window
302
277
  def resize_window_to(width, height)
303
- log(width, height)
304
278
  driver.manage.window.resize_to(width, height)
305
279
  end
306
280
 
307
281
  # Save a PNG screenshot to the given path
308
282
  # @param [String] png_path the path of PNG screenshot
309
283
  def save_screenshot(png_path)
310
- log(png_path)
311
284
  driver.save_screenshot(
312
285
  png_path.end_with?('.png') ? png_path : "#{png_path}.png"
313
286
  )
@@ -315,40 +288,34 @@ class Rudra
315
288
 
316
289
  # Switch to the currently active modal dialog
317
290
  def switch_to_alert
318
- log
319
291
  driver.switch_to.alert
320
292
  end
321
293
 
322
294
  # Select either the first frame on the page,
323
295
  # or the main document when a page contains iframes
324
296
  def switch_to_default_content
325
- log
326
297
  driver.switch_to.default_content
327
298
  end
328
299
 
329
300
  # Switch to the frame with the given id
330
301
  def switch_to_frame(id)
331
- log(id)
332
302
  driver.switch_to.frame(id)
333
303
  end
334
304
 
335
305
  # Switch to the parent frame
336
306
  def switch_to_parent_frame
337
- log
338
307
  driver.switch_to.parent_frame
339
308
  end
340
309
 
341
310
  # Switch to the given window handle
342
311
  # @param [String] id the window handle obtained through #window_handles
343
312
  def switch_to_window(id)
344
- log(id)
345
313
  driver.switch_to.window(id)
346
314
  end
347
315
 
348
316
  # Get the title of the current page
349
317
  # @return [String] the title of the current page
350
318
  def title
351
- log
352
319
  driver.title
353
320
  end
354
321
 
@@ -356,7 +323,6 @@ class Rudra
356
323
  # @param [Integer] seconds seconds before timed out
357
324
  # @return [Object] the result of the block
358
325
  def wait_for(seconds = timeout)
359
- log(seconds)
360
326
  Selenium::WebDriver::Wait.new(timeout: seconds).until { yield }
361
327
  end
362
328
 
@@ -364,21 +330,18 @@ class Rudra
364
330
  # @param [String, Selenium::WebDriver::Element] locator the locator to
365
331
  # identify the element or Selenium::WebDriver::Element
366
332
  def wait_for_enabled(locator)
367
- log(locator)
368
333
  wait_for { find_element(locator).enabled? }
369
334
  end
370
335
 
371
336
  # Wait until the title of the page including the given string
372
337
  # @param [String] string the string to compare
373
338
  def wait_for_title(string)
374
- log(string)
375
339
  wait_for { title.downcase.include?(string.downcase) }
376
340
  end
377
341
 
378
342
  # Wait until the URL of the page including the given url
379
343
  # @param [String] url the URL to compare
380
344
  def wait_for_url(url)
381
- log(url)
382
345
  wait_for { current_url.include?(url) }
383
346
  end
384
347
 
@@ -386,28 +349,24 @@ class Rudra
386
349
  # @param [String, Selenium::WebDriver::Element] locator the locator to
387
350
  # identify the element or Selenium::WebDriver::Element
388
351
  def wait_for_visible(locator)
389
- log(locator)
390
352
  wait_for { find_element(locator).displayed? }
391
353
  end
392
354
 
393
355
  # Get the current window handle
394
356
  # @return [String] the id of the current window handle
395
357
  def window_handle
396
- log
397
358
  driver.window_handle
398
359
  end
399
360
 
400
361
  # Get the window handles of open browser windows
401
362
  # @return [Array<String>] the ids of window handles
402
363
  def window_handles
403
- log
404
364
  driver.window_handles
405
365
  end
406
366
 
407
367
  # Zoom the current page
408
368
  # @param [Float] scale the scale of zoom
409
369
  def zoom(scale)
410
- log(scale)
411
370
  execute_script(%(document.body.style.zoom = arguments[0];), scale)
412
371
  end
413
372
 
@@ -422,7 +381,6 @@ class Rudra
422
381
  # @param [String] attribute the name of the attribute
423
382
  # @return [String, nil] attribute value
424
383
  def attribute(locator, attribute)
425
- log(locator, attribute)
426
384
  find_element(locator).property(attribute)
427
385
  end
428
386
 
@@ -432,7 +390,6 @@ class Rudra
432
390
  # @param [String] attribute the name of the attribute
433
391
  # @return [Boolean] the result of the existence of the given attribute
434
392
  def attribute?(locator, attribute)
435
- log(locator, attribute)
436
393
  execute_script(%(
437
394
  return arguments[0].hasAttribute(arguments[1]);
438
395
  ), find_element(locator), attribute)
@@ -442,7 +399,6 @@ class Rudra
442
399
  # @param [String, Selenium::WebDriver::Element] locator the locator to
443
400
  # identify the element or Selenium::WebDriver::Element
444
401
  def blur(locator)
445
- log(locator)
446
402
  execute_script(
447
403
  'var element = arguments[0]; element.blur();',
448
404
  find_element(locator)
@@ -453,7 +409,6 @@ class Rudra
453
409
  # @param [String, Selenium::WebDriver::Element] locator the locator to
454
410
  # identify the element or Selenium::WebDriver::Element
455
411
  def clear(locator)
456
- log(locator)
457
412
  find_element(locator).clear
458
413
  end
459
414
 
@@ -461,7 +416,6 @@ class Rudra
461
416
  # @param [String, Selenium::WebDriver::Element] locator the locator to
462
417
  # identify the element or Selenium::WebDriver::Element
463
418
  def click(locator)
464
- log(locator)
465
419
  find_element(locator).click
466
420
  end
467
421
 
@@ -472,8 +426,6 @@ class Rudra
472
426
  # @option offset [Integer] :x (0) offset on x coordinate
473
427
  # @option offset [Integer] :y (0) offset on y coordinate
474
428
  def click_at(locator, offset = {})
475
- log(locator, offset)
476
-
477
429
  x = offset.fetch(:x, 0)
478
430
  y = offset.fetch(:y, 0)
479
431
 
@@ -490,7 +442,6 @@ class Rudra
490
442
  # identify the element or Selenium::WebDriver::Element
491
443
  # @param [String] property the longhand name of the property
492
444
  def css_value(locator, property)
493
- log(locator, property)
494
445
  find_element(locator).css_value(property)
495
446
  end
496
447
 
@@ -499,7 +450,6 @@ class Rudra
499
450
  # identify the element or Selenium::WebDriver::Element
500
451
  # @return [Boolean]
501
452
  def displayed?(locator)
502
- log(locator)
503
453
  find_element(locator).displayed?
504
454
  end
505
455
 
@@ -510,8 +460,6 @@ class Rudra
510
460
  # @option offset [Integer] :x (0) offset on x coordinate
511
461
  # @option offset [Integer] :y (0) offset on y coordinate
512
462
  def double_click(locator, offset = {})
513
- log(locator, offset)
514
-
515
463
  x = offset.fetch(:x, 0)
516
464
  y = offset.fetch(:y, 0)
517
465
 
@@ -528,7 +476,6 @@ class Rudra
528
476
  # @param [String] to_locator the locator to to move to and release
529
477
  # the mouse at
530
478
  def drag_and_drop(from_locator, to_locator)
531
- log(from_locator, to_locator)
532
479
  el1 = find_element(from_locator)
533
480
  el2 = find_element(to_locator)
534
481
 
@@ -541,7 +488,6 @@ class Rudra
541
488
  # @option offset [Integer] :x (0) offset on x coordinate
542
489
  # @option offset [Integer] :y (0) offset on y coordinate
543
490
  def drag_and_drop_by(source, offset = {})
544
- log(source, offset)
545
491
  element = find_element(source)
546
492
  x = offset.fetch(:x, 0)
547
493
  y = offset.fetch(:y, 0)
@@ -554,7 +500,6 @@ class Rudra
554
500
  # identify the element or Selenium::WebDriver::Element
555
501
  # @return [Boolean]
556
502
  def enabled?(locator)
557
- log(locator)
558
503
  find_element(locator).enabled?
559
504
  end
560
505
 
@@ -562,8 +507,6 @@ class Rudra
562
507
  # @param [String, Selenium::WebDriver::Element] locator the locator to
563
508
  # identify the element or Selenium::WebDriver::Element
564
509
  def focus(locator)
565
- log(locator)
566
-
567
510
  execute_script(
568
511
  'var element = arguments[0]; element.focus();',
569
512
  find_element(locator)
@@ -574,8 +517,6 @@ class Rudra
574
517
  # @param [String, Selenium::WebDriver::Element] locator the locator to
575
518
  # identify the element or Selenium::WebDriver::Element
576
519
  def hide(locator)
577
- log(locator)
578
-
579
520
  execute_script(%(
580
521
  arguments[0].style.display = 'none';
581
522
  ), find_element(locator))
@@ -585,8 +526,6 @@ class Rudra
585
526
  # @param [String, Selenium::WebDriver::Element] locator the locator to
586
527
  # identify the element or Selenium::WebDriver::Element
587
528
  def highlight(locator)
588
- log(locator)
589
-
590
529
  execute_script(%(
591
530
  arguments[0].style.backgroundColor = '#ff3';
592
531
  ), find_element(locator))
@@ -595,7 +534,6 @@ class Rudra
595
534
  # Set implicit_wait timeout
596
535
  # @param [Integer] seconds timeout for implicit_wait
597
536
  def implicit_wait(seconds)
598
- log(seconds)
599
537
  driver.manage.timeouts.implicit_wait = seconds
600
538
  end
601
539
 
@@ -603,7 +541,6 @@ class Rudra
603
541
  # @param [String, Selenium::WebDriver::Element] locator the locator to
604
542
  # identify the element or Selenium::WebDriver::Element
605
543
  def js_click(locator)
606
- log(locator)
607
544
  execute_script('arguments[0].click();', find_element(locator))
608
545
  end
609
546
 
@@ -612,7 +549,6 @@ class Rudra
612
549
  # identify the element or Selenium::WebDriver::Element
613
550
  # @return [Selenium::WebDriver::Point] the point of the given element
614
551
  def location(locator)
615
- log(locator)
616
552
  find_element(locator).location
617
553
  end
618
554
 
@@ -620,7 +556,6 @@ class Rudra
620
556
  # @param [Integer] right_by horizontal offset
621
557
  # @param [Integer] down_by vertical offset
622
558
  def move_by(right_by = 0, down_by = 0)
623
- log(right_by, down_by)
624
559
  action.move_by(right_by, down_by).perform
625
560
  end
626
561
 
@@ -631,8 +566,6 @@ class Rudra
631
566
  # @option offset [Integer] :x (0) offset on x coordinate
632
567
  # @option offset [Integer] :y (0) offset on y coordinate
633
568
  def move_to(locator, offset = {})
634
- log(locator, offset)
635
-
636
569
  x = offset.fetch(:x, 0)
637
570
  y = offset.fetch(:y, 0)
638
571
 
@@ -646,7 +579,6 @@ class Rudra
646
579
  # Set page_load timeout
647
580
  # @param [Integer] seconds timeout for page_load
648
581
  def page_load(seconds)
649
- log(seconds)
650
582
  driver.manage.timeouts.page_load = seconds
651
583
  end
652
584
 
@@ -656,7 +588,6 @@ class Rudra
656
588
  # identify the element or Selenium::WebDriver::Element
657
589
  # @return [Selenium::WebDriver::Rectangle] the retangle of the given element
658
590
  def rect(locator)
659
- log(locator)
660
591
  find_element(locator).rect
661
592
  end
662
593
 
@@ -666,7 +597,6 @@ class Rudra
666
597
  # identify the element or Selenium::WebDriver::Element
667
598
  # @param [String] attribute the name of the attribute
668
599
  def remove_attribute(locator, attribute)
669
- log(locator, attribute)
670
600
  execute_script(%(
671
601
  var element = arguments[0];
672
602
  var attributeName = arguments[1];
@@ -683,8 +613,6 @@ class Rudra
683
613
  # @option offset [Integer] :x (0) offset on x coordinate
684
614
  # @option offset [Integer] :y (0) offset on y coordinate
685
615
  def right_click(locator, offset = {})
686
- log(locator, offset)
687
-
688
616
  x = offset.fetch(:x, 0)
689
617
  y = offset.fetch(:y, 0)
690
618
 
@@ -695,7 +623,6 @@ class Rudra
695
623
  # Set script_timeout timeout
696
624
  # @param [Integer] seconds timeout for script_timeout
697
625
  def script_timeout(seconds)
698
- log(seconds)
699
626
  driver.manage.timeouts.script_timeout = seconds
700
627
  end
701
628
 
@@ -705,8 +632,6 @@ class Rudra
705
632
  # @param [Boolean] align_to true if aligned on top or
706
633
  # false if aligned at the bottom
707
634
  def scroll_into_view(locator, align_to = true)
708
- log(locator, align_to)
709
-
710
635
  execute_script(
711
636
  'arguments[0].scrollIntoView(arguments[1]);',
712
637
  find_element(locator),
@@ -718,7 +643,6 @@ class Rudra
718
643
  # @param [String, Selenium::WebDriver::Element] option_locator the locator to
719
644
  # identify the element or Selenium::WebDriver::Element
720
645
  def select(option_locator)
721
- log(option_locator)
722
646
  find_element(option_locator).click
723
647
  end
724
648
 
@@ -727,7 +651,6 @@ class Rudra
727
651
  # identify the element or Selenium::WebDriver::Element
728
652
  # @return [Boolean]
729
653
  def selected?(locator)
730
- log(locator)
731
654
  find_element(locator).selected?
732
655
  end
733
656
 
@@ -736,7 +659,6 @@ class Rudra
736
659
  # identify the element or Selenium::WebDriver::Element
737
660
  # @param [String, Symbol, Array] args keystrokes to send
738
661
  def send_keys(locator, *args)
739
- log(locator, *args)
740
662
  find_element(locator).send_keys(*args)
741
663
  end
742
664
 
@@ -746,7 +668,6 @@ class Rudra
746
668
  # @param [String] attribute the name of the attribute
747
669
  # @param [String] value the value of the attribute
748
670
  def set_attribute(locator, attribute, value)
749
- log(locator, attribute, value)
750
671
  execute_script(%(
751
672
  var element = arguments[0];
752
673
  var attribute = arguments[1];
@@ -759,7 +680,6 @@ class Rudra
759
680
  # @param [String, Selenium::WebDriver::Element] locator the locator to
760
681
  # identify the element or Selenium::WebDriver::Element
761
682
  def show(locator)
762
- log(locator)
763
683
  execute_script(%(
764
684
  arguments[0].style.display = '';
765
685
  ), find_element(locator))
@@ -770,7 +690,6 @@ class Rudra
770
690
  # identify the element or Selenium::WebDriver::Element
771
691
  # @return [Selenium::WebDriver::Dimension]
772
692
  def size(locator)
773
- log(locator)
774
693
  find_element(locator).size
775
694
  end
776
695
 
@@ -778,7 +697,6 @@ class Rudra
778
697
  # @param [String, Selenium::WebDriver::Element] locator the locator to
779
698
  # identify the element or Selenium::WebDriver::Element
780
699
  def submit(locator)
781
- log("- submit(#{locator})")
782
700
  find_element(locator).submit
783
701
  end
784
702
 
@@ -787,7 +705,6 @@ class Rudra
787
705
  # identify the element or Selenium::WebDriver::Element
788
706
  # @return [String] the tag name of the given element
789
707
  def tag_name(locator)
790
- log(locator)
791
708
  find_element(locator).tag_name
792
709
  end
793
710
 
@@ -796,7 +713,6 @@ class Rudra
796
713
  # identify the element or Selenium::WebDriver::Element
797
714
  # @return [String] the text content of the given element
798
715
  def text(locator)
799
- log(locator)
800
716
  find_element(locator).text
801
717
  end
802
718
 
@@ -805,7 +721,6 @@ class Rudra
805
721
  # identify the element or Selenium::WebDriver::Element
806
722
  # @param [String] event the event name
807
723
  def trigger(locator, event)
808
- log(locator, event)
809
724
  execute_script(%(
810
725
  var element = arguments[0];
811
726
  var eventName = arguments[1];
@@ -820,7 +735,6 @@ class Rudra
820
735
 
821
736
  # Clear all drawing
822
737
  def clear_drawings
823
- log
824
738
  execute_script(%(
825
739
  var elements = window.document.body.querySelectorAll('[id*="rudra_"]');
826
740
  for (var i = 0; i < elements.length; i++) {
@@ -838,8 +752,6 @@ class Rudra
838
752
  # or Selenium::WebDriver::Element where the arrow ends
839
753
  # @return [Selenium::WebDriver::Element] the arrow element
840
754
  def draw_arrow(from_locator, to_locator)
841
- log(from_locator, to_locator)
842
-
843
755
  id = random_id
844
756
 
845
757
  execute_script(%(
@@ -907,8 +819,6 @@ class Rudra
907
819
  # @param [String] color CSS style of backgroundColor
908
820
  # @return [Selenium::WebDriver::Element] the color fill element
909
821
  def draw_color_fill(locator, color = 'rgba(255,0,0,0.8)')
910
- log(locator, color)
911
-
912
822
  rectangle = rect(locator)
913
823
  id = random_id
914
824
 
@@ -946,8 +856,6 @@ class Rudra
946
856
  # @option options [Boolean] :draw_symbol (false) if to draw symbol
947
857
  # @return [Selenium::WebDriver::Element] the tooltip element
948
858
  def draw_flyover(locator, options = {})
949
- log(locator, options)
950
-
951
859
  attribute_name = options.fetch(:attribute, 'title')
952
860
  offset_x = options.fetch(:offset_x, 5)
953
861
  offset_y = options.fetch(:offset_y, 15)
@@ -1025,8 +933,6 @@ class Rudra
1025
933
  # @option padding [Integer] :left (5) left padding
1026
934
  # @return [Selenium::WebDriver::Element] the redmark element
1027
935
  def draw_redmark(locator, padding = {})
1028
- log(locator, padding)
1029
-
1030
936
  top = padding.fetch(:top, 5)
1031
937
  right = padding.fetch(:right, 5)
1032
938
  bottom = padding.fetch(:bottom, 5)
@@ -1063,8 +969,6 @@ class Rudra
1063
969
  # @option options [Integer] :offset_y (0) offset on y coordinate
1064
970
  # @return [Selenium::WebDriver::Element] the dropdown menu element
1065
971
  def draw_select(locator, options = {})
1066
- log(locator, options)
1067
-
1068
972
  offset_x = options.fetch(:offset_x, 0)
1069
973
  offset_y = options.fetch(:offset_y, 0)
1070
974
 
@@ -1125,8 +1029,6 @@ class Rudra
1125
1029
  # @option options [Integer] :right (20) CSS style of right
1126
1030
  # @return [Selenium::WebDriver::Element] the text element
1127
1031
  def draw_text(locator, text, options = {})
1128
- log(locator, text, options)
1129
-
1130
1032
  color = options.fetch(:color, '#f00')
1131
1033
  font_size = options.fetch(:font_size, 13)
1132
1034
  top = options.fetch(:top, 2)
@@ -1160,10 +1062,22 @@ class Rudra
1160
1062
  # Create directories, recursively, for the given dir
1161
1063
  # @param [String] dir the directories to create
1162
1064
  def mkdir(dir)
1163
- log(dir)
1164
1065
  FileUtils.mkdir_p(dir)
1165
1066
  end
1166
1067
 
1068
+ (instance_methods - superclass.instance_methods).map do |method_name|
1069
+ if private_method_defined?(method_name) || ATTRIBUTES.include?(method_name)
1070
+ next
1071
+ end
1072
+
1073
+ original_method = instance_method(method_name)
1074
+
1075
+ define_method(method_name) do |*args, &block|
1076
+ log(method_name, *args)
1077
+ original_method.bind(self).call(*args, &block)
1078
+ end
1079
+ end
1080
+
1167
1081
  private
1168
1082
 
1169
1083
  def browser=(brw)
@@ -1255,13 +1169,13 @@ class Rudra
1255
1169
  [how, what]
1256
1170
  end
1257
1171
 
1258
- def log(*args)
1172
+ def log(method_name, *args)
1259
1173
  return unless @verbose && caller_locations(2, 1).first.label == @main_label
1260
1174
 
1261
- function = caller_locations(1, 1).first.label
1262
1175
  arguments = args.map(&:to_s).join(', ')
1176
+
1263
1177
  puts @log_prefix + (
1264
- arguments.empty? ? function : "#{function}(#{arguments})"
1178
+ arguments.empty? ? method_name.to_s : "#{method_name}(#{arguments})"
1265
1179
  )
1266
1180
  end
1267
1181
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rudra
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.12
4
+ version: 1.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Chen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-27 00:00:00.000000000 Z
11
+ date: 2020-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yard
@@ -50,20 +50,20 @@ dependencies:
50
50
  requirements:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: 4.2.0
53
+ version: 4.3.0
54
54
  - - "~>"
55
55
  - !ruby/object:Gem::Version
56
- version: '4.2'
56
+ version: '4.3'
57
57
  type: :runtime
58
58
  prerelease: false
59
59
  version_requirements: !ruby/object:Gem::Requirement
60
60
  requirements:
61
61
  - - ">="
62
62
  - !ruby/object:Gem::Version
63
- version: 4.2.0
63
+ version: 4.3.0
64
64
  - - "~>"
65
65
  - !ruby/object:Gem::Version
66
- version: '4.2'
66
+ version: '4.3'
67
67
  description: Selenium IDE alternative using selenium-webdriver
68
68
  email: aaron@oobo.be
69
69
  executables: []