browza 0.0.2.beta1 → 0.0.2.beta2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 46ab3b79c7bdaa2d454b94768594d7c02ddd5f7a
4
- data.tar.gz: a6a1c728eb52d6aece54f428a99d82f242bac1df
3
+ metadata.gz: 58d7a048ff31099323ddbe6b22a0960e4e7d554c
4
+ data.tar.gz: 49a4e1ee2cb8145b8c6b5c509dc42816c271961f
5
5
  SHA512:
6
- metadata.gz: 4a7342c4068a943d2d9994b92a96427672858165dc3bbdd5f2d21320c5bce750a5348613405f7e4d0524c9440bf9df3a5fa69d7b194e0ee592fc574d97131369
7
- data.tar.gz: f7d17f6a11aad99be4a76f7ccdf9080bf796eaa5755b986fd8789b78dad207861907978482a8c107ca0ead18dc5797e710635d82981afb4dc95685066fae079d
6
+ metadata.gz: 10a3f291df8bf8615146bb526f8ba6cb68eb1e05057d1a70c2b4e3cf3a119f29f3542b98508cd3d791953cedb05038079a93638ef1e750c8d1816b9ac466dd11
7
+ data.tar.gz: 777b465d8950e7f3208c2658007509ec0291b4dc82e21e0af4aab7cca072c2d906cee23896c7e9f53f32afee4bd9382d8368b3575bfcc3789f5b13a23dd33254
@@ -11,14 +11,25 @@ class Manager
11
11
 
12
12
  attr_accessor :drv
13
13
  attr_accessor :appModels
14
- attr_accessor :browserType
14
+ attr_accessor :browserType
15
+ attr_accessor :defaultTimeout
15
16
 
16
17
  def initialize(logLevel = :warn)
17
18
  @logger = Logging.logger(STDOUT)
18
19
  @logger.level = logLevel
20
+ @defaultTimeout = 30
19
21
  @appModels=[]
20
22
  end
21
23
 
24
+ def setLogLevel(l)
25
+ puts __FILE__ + (__LINE__).to_s + " setLogLevel(#{l})"
26
+ @logger.level = l
27
+ end
28
+
29
+ def setTimeout(s)
30
+ @defaultTimeout = s
31
+ end
32
+
22
33
  def addModel(_a)
23
34
  @logger.debug __FILE__ + (__LINE__).to_s + " [addModel]: #{_a}"
24
35
  @appModels << Appmodel::Model.new(_a)
@@ -78,8 +89,6 @@ class Manager
78
89
  locator = { :css => _locator }
79
90
  elsif _locator.match(/^\s*css\s*=\s*(.*)\s*$/)
80
91
  locator = { :css => _locator.match(/^\s*css\s*=\s*(.*)$/)[1].to_s }
81
- puts "LOCATOR.CSS => #{locator}"
82
-
83
92
  end
84
93
  end
85
94
 
@@ -145,6 +154,7 @@ class Manager
145
154
  @logger.warn __FILE__ + (__LINE__).to_s + " NoSuchElementError : #{locator}"
146
155
 
147
156
  rescue => ex
157
+ @logger.warn __FILE__ + (__LINE__).to_s + " #{ex.class}"
148
158
  @logger.warn "Error during processing: #{$!}"
149
159
  @logger.warn "Backtrace:\n\t#{ex.backtrace.join("\n\t")}"
150
160
  end
@@ -339,17 +349,32 @@ class Manager
339
349
  end
340
350
 
341
351
  if _hit.is_a?(Hash)
342
- if _hit.has_key?('frame')
343
- @logger.debug __FILE__ + (__LINE__).to_s + "swtich_to_frame : #{_hit['frame']}"
344
- switch_frame(_hit['frame'])
345
- end
346
352
 
347
- if _hit.has_key?('locator')
348
- obj = getElement(_hit['locator'], @drv, 30)
349
- end
353
+ 2.times {
354
+
355
+ begin
356
+ if _hit.has_key?('frame')
357
+ @logger.debug __FILE__ + (__LINE__).to_s + "swtich_to_frame : #{_hit['frame']}"
358
+ switch_frame(_hit['frame'])
359
+ end
360
+
361
+ if _hit.has_key?('locator')
362
+ obj = getElement(_hit['locator'], @drv, @defaultTimeout)
363
+ end
364
+
365
+ if !obj.nil?
366
+ break
367
+ end
368
+
369
+ sleep(0.25)
370
+
371
+ rescue => e
372
+ ;
373
+ end
374
+ }
350
375
 
351
376
  else
352
- obj = getElement(Appmodel::Model.toBy(_locator), @drv, 30)
377
+ obj = getElement(Appmodel::Model.toBy(_locator), @drv, @defaultTimeout)
353
378
  end
354
379
 
355
380
  @logger.debug __FILE__ + (__LINE__).to_s + " [return findLocator(#{_locator})] : #{_hit}"
@@ -418,14 +443,58 @@ class Manager
418
443
  obj.is_a?(Selenium::WebDriver::Element) && rc
419
444
  end
420
445
 
446
+ def hover(_locator)
447
+ rc = false
448
+
449
+ obj = findLocator(_locator)
450
+ if !obj.nil?
451
+ begin
452
+ @drv.action.move_to(obj).perform
453
+ rc = true
454
+ rescue => ex
455
+ @logger.warn "Error during processing: #{$!} - #{ex.class}"
456
+ @logger.warn "Backtrace:\n\t#{ex.backtrace.join("\n\t")}"
457
+ end
458
+
459
+ else
460
+ @logger.debug __FILE__ + (__LINE__).to_s + " hover(#{_locator}) not found."
461
+ end
462
+
463
+ @logger.debug __FILE__ + (__LINE__).to_s + " hover(#{_locator}) : #{rc}"
464
+ rc
465
+ end
466
+
467
+
421
468
  def type(_locator, _text, _timeout=30)
422
469
  rc = false
423
470
 
424
471
  # obj = getElement(findLocator(_locator), _drv, _timeout)
425
472
  obj = findLocator(_locator)
426
473
  if !obj.nil?
427
- obj.send_keys(_text)
428
- rc=true
474
+
475
+ if _text.match(/\s*__CLEAR__\s*$/)
476
+ _text = :clear
477
+ elsif _text.match(/\s*__DOWN__\s*$/)
478
+ _text = :arrow_down
479
+ elsif _text.match(/\s*__LEFT__\s*$/)
480
+ _text = :arrow_left
481
+ elsif _text.match(/\s*__RIGHT__\s*$/)
482
+ _text = :arrow_right
483
+ elsif _text.match(/\s*__UP__\s*$/)
484
+ _text = :arrow_up
485
+ elsif _text.match(/\s*__TAB__\s*$/)
486
+ _text = :tab
487
+ elsif _text.match(/\s*__SHIFT_TAB__\s*$/)
488
+ @drv.action.key_down(:shift).send_keys(:tab).perform
489
+ @drv.action.key_up(:shift).perform
490
+ rc = true
491
+ end
492
+
493
+ unless rc
494
+ obj.send_keys(_text)
495
+ rc=true
496
+ end
497
+
429
498
  end
430
499
 
431
500
  rc
@@ -452,6 +521,23 @@ class Manager
452
521
  activeElt.attribute('value')
453
522
  end
454
523
 
524
+ def isFocused?(_locator)
525
+
526
+ rc = false
527
+ activeElt = @drv.switch_to.active_element
528
+ obj = findLocator(_locator)
529
+
530
+
531
+ if !obj.nil?
532
+ rc = (activeElt == obj)
533
+ end
534
+
535
+ rc
536
+
537
+ end
538
+
539
+
540
+
455
541
  def press(k, n=1)
456
542
 
457
543
  n.times {
@@ -470,13 +556,25 @@ class Manager
470
556
  elsif k.match(/\s*^up/i)
471
557
  activeElt = @drv.switch_to.active_element
472
558
  activeElt.send_keys(:arrow_up)
559
+ elsif k.match(/\s*__SHIFT_TAB__\s*$/i)
560
+ @drv.action.key_down(:shift).send_keys(:tab).perform
561
+ @drv.action.key_up(:shift).perform
473
562
  else
474
563
  break
475
564
  end
476
565
  }
477
566
  end
478
567
 
568
+ def selected?(_locator, _drv=nil, _timeout=30)
569
+ rc=false
479
570
 
571
+ # obj=getElement(findLocator(_locator), _drv, _timeout)
572
+ obj = findLocator(_locator)
573
+ if !obj.nil?
574
+ rc=obj.selected?
575
+ end
576
+ rc
577
+ end
480
578
 
481
579
  def getCount(_locator, _drv=nil, _timeout=30)
482
580
  rc=0
@@ -1,3 +1,3 @@
1
1
  module Browza
2
- VERSION = "0.0.2.beta1"
2
+ VERSION = "0.0.2.beta2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: browza
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2.beta1
4
+ version: 0.0.2.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - H20Dragon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-11 00:00:00.000000000 Z
11
+ date: 2017-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler