scoutui 2.0.5.1.1.pre → 2.0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -2
  3. data/README.md +0 -7
  4. data/examples/ex1/phantom.chrome.json +4 -0
  5. data/examples/ex1/run.sh +85 -0
  6. data/examples/ex1/simple.yml +13 -0
  7. data/examples/ex1/win10.chromebeta.json +6 -0
  8. data/lib/scoutui/appmodel/q_model.rb +5 -0
  9. data/lib/scoutui/base/assertions.rb +49 -11
  10. data/lib/scoutui/base/q_browser.rb +181 -15
  11. data/lib/scoutui/base/q_har_mgr.rb +63 -0
  12. data/lib/scoutui/base/test_data.rb +0 -2
  13. data/lib/scoutui/base/test_scout.rb +2 -1
  14. data/lib/scoutui/base/user_vars.rb +1 -1
  15. data/lib/scoutui/base/visual_test_framework.rb +78 -15
  16. data/lib/scoutui/commands/clauses/do_until.rb +25 -6
  17. data/lib/scoutui/commands/clauses/then_clause.rb +12 -0
  18. data/lib/scoutui/commands/click_object.rb +5 -2
  19. data/lib/scoutui/commands/commands.rb +85 -10
  20. data/lib/scoutui/commands/highlight.rb +72 -21
  21. data/lib/scoutui/commands/mouse_over.rb +4 -2
  22. data/lib/scoutui/commands/pause.rb +9 -2
  23. data/lib/scoutui/commands/strategy.rb +21 -2
  24. data/lib/scoutui/commands/type.rb +40 -5
  25. data/lib/scoutui/eyes/eye_scout.rb +2 -1
  26. data/lib/scoutui/utils/utils.rb +9 -0
  27. data/lib/scoutui/version.rb +1 -1
  28. data/scoutui.gemspec +2 -3
  29. metadata +15 -59
  30. data/bin/scoutui_driver +0 -1
  31. data/examples/benchmark/ex.rb +0 -16
  32. data/examples/capabilities/win10.chrome46.json +0 -6
  33. data/examples/carmax/appmodel/search_results.json +0 -27
  34. data/examples/carmax/commands/commands.yml +0 -63
  35. data/examples/cmdshell/commands/hello.yml +0 -22
  36. data/examples/converters/jsonupdate.rb +0 -31
  37. data/examples/ex2/appmodel/common.json +0 -51
  38. data/examples/ex2/appmodel/page_model.json +0 -106
  39. data/examples/ex2/appmodel/register.model.json +0 -42
  40. data/examples/ex2/commands/commands.basic.appmodel.yml +0 -8
  41. data/examples/ex2/commands/commands.yml +0 -115
  42. data/examples/ex2/commands/ex1.yml +0 -7
  43. data/examples/ex2/commands/ex1c.yml +0 -8
  44. data/examples/ex2/commands/ex1d.yml +0 -22
  45. data/examples/ex2/commands/ex2.hover.yml +0 -43
  46. data/examples/ex2/commands/ex2.yml +0 -24
  47. data/examples/ex2/data.json +0 -6
  48. data/examples/ex2/test-configs/test.config.basic.json +0 -12
  49. data/examples/ex2/test-configs/test.config.json +0 -31
  50. data/examples/ex2/tests/run-test.sh +0 -125
  51. data/examples/ex2/tests/test-basic-appmodel.sh +0 -14
  52. data/examples/ex2/tests/test-example.sh +0 -39
  53. data/examples/ex2/tests/test-example1a.sh +0 -16
  54. data/examples/ex2/tests/test-example1b.sh +0 -13
  55. data/examples/ex2/tests/test-example1c.sh +0 -15
  56. data/examples/ex2/tests/test-example1d.sh +0 -15
  57. data/examples/ex2/tests/test-example2.forms.eyes.sh +0 -40
  58. data/examples/ex2/tests/test-example2.hover.eyes.sh +0 -40
  59. data/examples/ex2/tests/test-example2.hover.sh +0 -26
  60. data/examples/ex2/tests/test-example2.sh +0 -43
  61. data/examples/ex2/tests/test-example3.sauce.sh +0 -77
  62. data/examples/ex2/tests/test-example3.sh +0 -41
  63. data/examples/headless/run.sh +0 -15
  64. data/examples/http/sendreq.rb +0 -29
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3cc672d8ca020b2b3528156b5fd0340c2f4e1718
4
- data.tar.gz: 478704fa811c74a843c9a5ffea5b9de75c31ed7f
3
+ metadata.gz: 0bf25b876e2b1c0a035ed517d11c2d203c6cc03a
4
+ data.tar.gz: 9fca81eb8591811dab1ead346e4de8ae79e8d442
5
5
  SHA512:
6
- metadata.gz: 5151c508e519958c6795db1f4f822854f5cabdacfc716927a845a7e06343d3388c9441c28932b47a0c2d86e4f3f9b0302e20296546ad50598d26b0bae53e8c4e
7
- data.tar.gz: e769eb0f19392f50aabe0b5634a45efa5bb195821348645f635daa3dae2e62dccb32a4407c470959b0f30fb50611dca3324af43c21b8f03f5b7d5fc569279ba7
6
+ metadata.gz: 2036f7dfa5c56df51e25e2fba6a2222f05d45be3a3bd5c512fb1a9743387cd98f9395a4c7146a0c223102bb5973d886bb5fd541cf8c3a80527a2a6d02ce2424a
7
+ data.tar.gz: bfae98f500030457e0e02afb698eaa2f14c28835b2040c555351428bded9e7e5511aa7030eeed5c69569989bc6d404845377c671b56236976bc4ac9767b532d8
data/.gitignore CHANGED
@@ -4,7 +4,9 @@
4
4
  /_yardoc/
5
5
  /coverage/
6
6
  /doc/
7
+ /pkg/
7
8
  /spec/reports/
8
- /test/gateway
9
9
  /tmp/
10
- /test/travel
10
+ /.idea
11
+ /.travis.yml
12
+
data/README.md CHANGED
@@ -59,13 +59,6 @@ To run unit tests:
59
59
  To run a specific unit test:
60
60
 
61
61
  $ rspec spec/json_spec.rb
62
-
63
- To build:
64
-
65
- $ bundle exec rake build
66
-
67
- To push the build (gem)
68
- $ gem push <gem file>
69
62
 
70
63
  ## Running the examples
71
64
 
@@ -0,0 +1,4 @@
1
+ {
2
+ "browser": "phantomjs",
3
+ "useragent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36"
4
+ }
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env bash
2
+ ##
3
+ # H20Dragon
4
+ ##
5
+
6
+ ##
7
+ # Execute test on Chrome locally.
8
+ ##
9
+ run_chrome()
10
+ {
11
+ CMD=$1
12
+ ruby $SCOUTUI_BIN --config ./test.config.json \
13
+ --browser chrome \
14
+ --host "http://www.elvis-presley.com" \
15
+ --viewport 800x600 \
16
+ --dut ${CMD} --debug
17
+ }
18
+
19
+ ##
20
+ # Execute test on Firefox locally.
21
+ ##
22
+ run_firefox()
23
+ {
24
+ CMD=$1
25
+ ruby $SCOUTUI_BIN --config ./test.config.json \
26
+ --browser firefox \
27
+ --host "http://www.elvis-presley.com" \
28
+ --viewport 800x600 \
29
+ --dut ${CMD} --debug
30
+ }
31
+
32
+ ##
33
+ # Execute test on phantom (GhostDriver)
34
+ ##
35
+ run_headless()
36
+ {
37
+ CMD=$1
38
+ ruby $SCOUTUI_BIN --config ./test.config.json \
39
+ --browser phantomjs \
40
+ --host "http://www.elvis-presley.com" \
41
+ --viewport 800x600 \
42
+ --dut ${CMD} --debug
43
+ }
44
+
45
+
46
+ ##
47
+ # Run tests on ghostdriver (phantom) as defined in
48
+ # its capabilities file.
49
+ ##
50
+ run_headless2()
51
+ {
52
+ CMD=$1
53
+ ruby $SCOUTUI_BIN --config ./test.config.json \
54
+ --capabilities ./phantom.chrome.json \
55
+ --host "http://www.elvis-presley.com" \
56
+ --viewport 800x600 \
57
+ --dut ${CMD} --debug
58
+ }
59
+
60
+
61
+ ##
62
+ # Run a test on ghostdriver (phantom) defined by
63
+ # capabilities files, while taking screen shots.
64
+ ##
65
+ run_screenshots_phantom()
66
+ {
67
+ CMD=$1
68
+ ruby $SCOUTUI_BIN --config ./test.config.json \
69
+ --capabilities ./phantom.chrome.json \
70
+ --screenshots:run true \
71
+ --screenshots:dir /tmp/phantom \
72
+ --host "http://www.elvis-presley.com" \
73
+ --viewport 800x600 \
74
+ --dut ${CMD} --debug
75
+ }
76
+
77
+
78
+
79
+ run_chrome ./simple.yml
80
+ run_firefox ./simple.yml
81
+
82
+ #run_headless ./simple.yml
83
+ #run_headless2 ./simple.yml
84
+ #run_screenshots_phantom ./simple.yml
85
+
@@ -0,0 +1,13 @@
1
+ page:
2
+ name: Home
3
+ action: navigate(http://www.elvis.com)
4
+ ---
5
+ page:
6
+ name: TAB
7
+ action: type(__TAB__)
8
+ do:
9
+ - focused.Highlight
10
+ - press(__TAB__)
11
+ until:
12
+ - true
13
+
@@ -0,0 +1,6 @@
1
+ {
2
+ "platform": "Windows 10",
3
+ "browser": "chrome",
4
+ "version": "beta",
5
+ "screenResolution": "1280x1024"
6
+ }
@@ -6,6 +6,11 @@ module Scoutui::ApplicationModel
6
6
  attr_accessor :_file
7
7
  attr_accessor :app_model
8
8
 
9
+
10
+ def self.isPageObject?(_locator)
11
+ _locator.is_a?(String)? _locator.match(/^\s*page\s*\(\s*[\w\d_\-]+\s*\)/) : nil
12
+ end
13
+
9
14
  def initialize(f=nil)
10
15
 
11
16
  if !f.nil?
@@ -18,6 +18,7 @@ module Scoutui::Base
18
18
  { :cmd => 'isText', :pattern => '^\s*[!]*(isText)\s*\(.*\)\s*\=\s*(.*)\s*$', :parse => lambda { |_a| _parseWith('isText', _a) } },
19
19
  { :cmd => 'isValue', :pattern => '^\s*[!]*(isValue)\s*\(.*\)\s*\=\s*(.*)\s*$', :parse => lambda { |_a| _parseWith('isValue', _a) } },
20
20
  { :cmd => 'visible', :pattern => '^\s*[!]*visible\((.*)\)\s*$', :parse => nil },
21
+ { :cmd => 'isUrl', :pattern => '^\s*isUrl\((.*)\)\s*$', :parse => lambda { |_a| _parseWith('isUrl', _a) } },
21
22
  { :cmd => 'url', :pattern => '^\s*url\((.*)\)\s*$', :parse => lambda { |_a| _parseWith('url', _a) } },
22
23
  { :cmd => 'compare', :pattern => '/^\s*(\$\{.*\})\s*(==|!=)(.*)$', :parse => nil }
23
24
  ]
@@ -48,12 +49,12 @@ module Scoutui::Base
48
49
 
49
50
  def isUrlMatch(my_driver, _a)
50
51
  current_url = my_driver.current_url.to_s
51
- expected_url = _a.match(/^\s*(url)\s*\((.*)\)/)[2].to_s
52
+ expected_url = _a.match(/^\s*(url|isUrl)\s*\((.*)\)\s*$/)[2].to_s
52
53
 
53
54
  expected_regex = Regexp.new(Scoutui::Base::UserVars.instance.normalize(expected_url))
54
55
  rc=!current_url.match(expected_regex).nil?
55
56
 
56
- Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " verify current url #{current_url} matches #{rc}"
57
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " verify current url #{current_url} matches regex #{expected_url} : #{rc}"
57
58
 
58
59
  return rc
59
60
  end
@@ -423,26 +424,31 @@ module Scoutui::Base
423
424
 
424
425
 
425
426
 
426
- elsif _t.has_key?('cmd') && !_t['cmd'].empty? && _t['cmd'].match(/[!]*isText/i)
427
+ elsif _t.has_key?('cmd') && !_t['cmd'].empty? && _t['cmd'].match(/[!]*is[tT]ext/i)
427
428
  rc=false
428
429
 
429
430
  if _obj.is_a?(Selenium::WebDriver::Element)
430
431
  _v = _obj.text.to_s
432
+
433
+ puts __FILE__ + (__LINE__).to_s + " isText(#{_locator.to_s}) : #{_v} (tagname: #{_obj.tag_name}, displayed: #{_obj.displayed?.to_s}"
431
434
  rc=!_v.match(/#{_t['expected_value']}/).nil?
432
435
 
433
- if _t['cmd'].match(/^!\s*isText/i)
436
+ if _t['cmd'].match(/^!\s*is[tT]ext/i)
434
437
  rc=!rc
435
438
  end
436
439
  end
437
440
 
438
- elsif _t.has_key?('cmd') && !_t['cmd'].empty? && _t['cmd'].match(/[!]*isValue/i)
441
+ elsif _t.has_key?('cmd') && !_t['cmd'].empty? && _t['cmd'].match(/[!]*is[vV]alue/i)
439
442
  rc=false
440
443
 
441
444
  if _obj.is_a?(Selenium::WebDriver::Element)
442
445
  _v = _obj.attribute('value')
443
- rc=!_v.match(/#{_t['expected_value']}/).nil?
444
446
 
445
- if _t['cmd'].match(/^!\s*isValue/i)
447
+ _t['expected_value'] = Scoutui::Base::UserVars.instance.normalize(_t['expected_value'])
448
+
449
+ rc=!_v.match(/#{_t['expected_value']}/).nil?
450
+
451
+ if _t['cmd'].match(/^!\s*is[vV]alue/i)
446
452
  rc=!rc
447
453
  end
448
454
  end
@@ -482,6 +488,7 @@ module Scoutui::Base
482
488
 
483
489
  def isVisible?(my_driver, _execute_when, _enableAsserts=true)
484
490
  rc=true
491
+ _state=nil
485
492
 
486
493
  _tm = Scoutui::Commands::Utils.instance.getTimeout
487
494
 
@@ -518,11 +525,37 @@ module Scoutui::Base
518
525
 
519
526
  Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " visible => #{_locator}"
520
527
 
521
- _obj = Scoutui::Base::QBrowser.findElement(my_driver, _locator, Scoutui::Commands::Utils.instance.getFrameSearch(), _tm) # Scoutui::Commands::Utils.instance.getTimeout)
528
+ (0..3).each do |_retry|
529
+ begin
530
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
531
+
532
+ _obj=nil
533
+
534
+ isDisplayed = wait.until {
535
+ _obj = Scoutui::Base::QBrowser.findElement(my_driver, _locator, Scoutui::Commands::Utils.instance.getFrameSearch(), _tm) # Scoutui::Commands::Utils.instance.getTimeout)
536
+ _obj.is_a?(Selenium::WebDriver::Element) # && _obj.displayed?
537
+ }
538
+
539
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " #{_locator} => #{_obj} displayed:#{_obj.displayed?}"
522
540
 
523
- Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " obj => #{_obj}"
541
+ _state = Scoutui::Base::QBrowser.isDisplayed?(_obj)
524
542
 
525
- _state = Scoutui::Base::QBrowser.isDisplayed?(_obj)
543
+
544
+ break if _state
545
+
546
+ rescue Selenium::WebDriver::Error::TimeOutError
547
+ puts __FILE__ + (__LINE__).to_s + " Timed out => #{_locator}"
548
+
549
+ rescue Selenium::WebDriver::Error::StaleElementReferenceError
550
+ puts __FILE__ + (__LINE__).to_s + " StaleElementReferenceError: retry #{_retry} : #{_locator}";
551
+ sleep(0.5)
552
+ end
553
+ end
554
+
555
+
556
+ if !_state
557
+ puts __FILE__ + (__LINE__).to_s + " Paused due to fail to find #{_locator}"; #STDIN.gets();
558
+ end
526
559
 
527
560
  if !_enableAsserts
528
561
  _rc=false
@@ -880,7 +913,12 @@ module Scoutui::Base
880
913
 
881
914
  locator = pageObject['locator'].to_s
882
915
 
883
- _obj = Scoutui::Base::QBrowser.getFirstObject(my_driver, locator, Scoutui::Commands::Utils.instance.getTimeout)
916
+ if pageObject.has_key?('frame')
917
+ # 5150
918
+ _obj=Scoutui::Base::QBrowser.findElementwithinFrame(my_driver, locator, pageObject['frame'], Scoutui::Commands::Utils.instance.getTimeout)
919
+ else
920
+ _obj = Scoutui::Base::QBrowser.getFirstObject(my_driver, locator, Scoutui::Commands::Utils.instance.getTimeout)
921
+ end
884
922
 
885
923
  if cmd=='visible'
886
924
  if !_obj.nil?
@@ -13,12 +13,23 @@ module Scoutui::Base
13
13
  drv.browser.to_s.match(/chrome/i)
14
14
  end
15
15
 
16
+ def self.saveScreenShot(drv, fullPath)
17
+ rc=false
18
+ begin
19
+ drv.save_screenshot(fullPath)
20
+ rc=true
21
+ rescue => ex
22
+ ;
23
+ end
24
+ rc
25
+ end
26
+
16
27
  def self.wait_for_not_displayed(drv, locator, _timeout=30)
17
- Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " wait_for_not_displayed(#{xpath}"
28
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " wait_for_not_displayed(#{locator}"
18
29
  rc=nil
19
30
  begin
20
31
  Selenium::WebDriver::Wait.new(timeout: _timeout).until {
21
- rc=drv.find_element(:xpath => xpath).displayed?
32
+ rc=drv.find_element(:xpath => locator).displayed?
22
33
  obj=getObject(drv, obj, _timeout=nil)
23
34
  }
24
35
  rescue => ex
@@ -146,21 +157,22 @@ module Scoutui::Base
146
157
 
147
158
 
148
159
  def self.switch_into_frame(drv, id)
149
- Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " switch_into_frame(#{id})"
160
+ _fcnId=" [switch_into_frame]"
161
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + "#{_fcnId}: (#{id})"
150
162
 
151
163
  hit=nil
152
164
 
153
165
  if isChrome?(drv)
154
166
 
155
- Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " swtich on Chrome browser"
167
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + "#{_fcnId}: switch on Chrome browser"
156
168
  bframes = drv.find_elements(:xpath, '//iframe')
157
169
 
158
- Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " //iframe : size #{bframes.size}"
170
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + "#{_fcnId}: //iframe : size #{bframes.size}"
159
171
 
160
172
  if bframes.size == 0
161
173
  bframes = drv.find_elements(:xpath, '//frame')
162
174
 
163
- Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " //frame : #{bframes.size}"
175
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + "#{_fcnId}: //frame : #{bframes.size}"
164
176
  end
165
177
 
166
178
  for i in 0 .. bframes.size - 1
@@ -180,7 +192,7 @@ module Scoutui::Base
180
192
  hit = bframes[i]
181
193
  drv.switch_to.frame hit
182
194
 
183
- Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " swtichframe to #{i} - #{_tag}"
195
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + "#{_fcnId}: swtichframe to #{i} - #{_tag}"
184
196
  break
185
197
  end
186
198
 
@@ -193,7 +205,7 @@ module Scoutui::Base
193
205
 
194
206
  else
195
207
  # Firefox, IE
196
- Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " [switch_into_frame]: drv.switch_to.frame(#{id.to_s}";
208
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + "#{_fcnId}: drv.switch_to.frame(#{id.to_s}";
197
209
 
198
210
  hit = drv.switch_to.frame(id.to_s.strip)
199
211
  end
@@ -546,6 +558,103 @@ module Scoutui::Base
546
558
 
547
559
  end
548
560
 
561
+ def self.findElementwithinFrame(drv, _locator, _frames, _timeout=nil)
562
+
563
+ puts __FILE__ + (__LINE__).to_s + " frameElementWithinFrame(#{_locator}, #{_frames}"
564
+
565
+ # 5150
566
+
567
+ obj=nil
568
+ if _frames.nil?
569
+ obj=findElement(drv, _locator, _frames, _timeout)
570
+ else
571
+ # Switch to default window
572
+ drv.switch_to.default_content
573
+ if switch_frame(drv, _frames)
574
+
575
+ (0..3).each do |_i|
576
+ obj = Scoutui::Base::QBrowser.getObject(drv, _locator, _timeout)
577
+ if !obj.nil?
578
+ break
579
+ end
580
+ end
581
+
582
+ end
583
+
584
+ end
585
+
586
+ puts __FILE__ + (__LINE__).to_s + " [return]:frameElementsWithinFrame(#{_locator}, #{_frames}) => #{obj.class}"
587
+ obj
588
+ end
589
+
590
+
591
+ def self.parseLocator(_locator)
592
+ # TODO: If its a pageObject reference (page(one).get().get()), then retrieve it.
593
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " parseLocator(#{_locator}"
594
+
595
+ if _locator.is_a?(Hash)
596
+
597
+ if _locator.has_key?('frame') && _locator.has_key?('locator')
598
+
599
+ _locator="#{_locator['frame']}.locator(#{_locator['locator']})"
600
+ elsif _locator.has_key?('locator')
601
+ _locator = _locator['locator']
602
+ end
603
+
604
+ end
605
+
606
+ return _locator if !_locator.is_a?(String)
607
+
608
+ locator=_locator
609
+
610
+ if Scoutui::ApplicationModel::QModel.isPageObject?(_locator) # _locator.match(/^page\([\w\d]+\)/)
611
+ pg = Scoutui::Utils::TestUtils.instance.getPageElement(_locator)
612
+ puts __FILE__ + (__LINE__).to_s + " [parseLocator]: pageObject(#{_locator}) => #{pg}"
613
+
614
+ if pg.is_a?(Hash)
615
+
616
+ if pg.has_key?('frame') && pg.has_key?('locator')
617
+ locator="#{pg['frame']}.locator(#{pg['locator']})"
618
+ elsif pg.has_key?('locator')
619
+
620
+ if pg['locator'].match((/^\s*([(frame\([^\(]*?\)\.)]*)\.(locator\((.*)\))\s*$/))
621
+ locator=pg['locator']
622
+ else
623
+ locator="locator(#{pg['locator']})"
624
+ end
625
+
626
+ end
627
+
628
+ end
629
+ end
630
+
631
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " | locator => #{locator}"
632
+
633
+
634
+ rc=locator.match(/^\s*([(frame\([^\(]*?\)\.)]*)\.(locator\((.*)\))\s*$/)
635
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " parseIt: #{locator} => #{rc}";
636
+
637
+
638
+ if rc
639
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + "o rc[1] : #{rc[1].to_s}"
640
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + "o rc[2] : #{rc[2]}"
641
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + "o rc[3] : #{rc[3]}"
642
+ return { 'frame' => rc[1], 'locator' => rc[3] }
643
+ end
644
+
645
+
646
+ rc=locator.match(/^\s*(locator\((.*)\))\s*$/)
647
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " parseIt2: #{locator} => #{rc}"
648
+
649
+ if rc
650
+ puts "o rc[1] : #{rc[1]}"
651
+ puts "o rc[2] : #{rc[2]}"
652
+ return { 'locator' => rc[2] }
653
+ end
654
+
655
+ return { 'locator' => locator }
656
+ end
657
+
549
658
 
550
659
  def self.findElement(drv, _locator, _frames, _timeout=nil)
551
660
 
@@ -559,6 +668,7 @@ module Scoutui::Base
559
668
  obj = Scoutui::Base::QBrowser.getObject(drv, _locator, _timeout)
560
669
 
561
670
  elsif Scoutui::Commands::Utils.instance.isFrameSearch?
671
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " isFrameSearch"
562
672
  hits = Scoutui::Base::QBrowser.frame_getObject(drv, _locator, _timeout)
563
673
 
564
674
  Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " hits => #{hits.class} : #{hits}"
@@ -569,7 +679,19 @@ module Scoutui::Base
569
679
  end
570
680
 
571
681
  else
572
- obj = Scoutui::Base::QBrowser.getObject(drv, _locator, _timeout)
682
+
683
+ puts __FILE__ + (__LINE__).to_s + " Analyze locator : #{_locator}"
684
+
685
+ _parsed = Scoutui::Base::QBrowser.parseLocator(_locator)
686
+
687
+ puts __FILE__ + (__LINE__).to_s + " _parsed(#{_locator}) => #{_parsed}"
688
+
689
+ if _parsed.has_key?('frame') && _parsed.has_key?('locator')
690
+ obj = Scoutui::Base::QBrowser.findElementwithinFrame(drv, _parsed['locator'], _parsed['frame'], _timeout)
691
+ else
692
+ obj = Scoutui::Base::QBrowser.getObject(drv, _locator, _timeout)
693
+ end
694
+
573
695
  end
574
696
 
575
697
 
@@ -681,6 +803,8 @@ module Scoutui::Base
681
803
  locator=obj
682
804
  locateBy=:xpath
683
805
  locator=nil
806
+ _frame=nil
807
+
684
808
 
685
809
  begin
686
810
 
@@ -701,6 +825,7 @@ module Scoutui::Base
701
825
  if elt.is_a?(Hash)
702
826
  Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " JSON or Hash => #{elt}" if Scoutui::Utils::TestUtils.instance.isDebug?
703
827
  locator = elt['locator'].to_s
828
+ _frame = elt['frame'] if elt.has_key?('frame')
704
829
  else
705
830
  locator=elt.to_s
706
831
  end
@@ -726,6 +851,8 @@ module Scoutui::Base
726
851
  else
727
852
  locator=elt.to_s
728
853
  end
854
+ else # Update locator to the defined user var.
855
+ locator = _x
729
856
  end
730
857
 
731
858
  end
@@ -743,19 +870,32 @@ module Scoutui::Base
743
870
  end
744
871
 
745
872
  Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " By => #{locateBy.to_s}"
873
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " Frame => #{_frame.to_s}"
746
874
  Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " Locator => #{locator}"
747
875
  Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " Visible_When => #{visible_when}"
748
876
  Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " Timeout => #{_timeout}"
749
877
 
878
+ current_window=drv.window_handle
879
+
880
+ if !_frame.nil?
881
+ switch_frame(drv, _frame)
882
+ end
750
883
  Selenium::WebDriver::Wait.new(timeout: _timeout).until { rc=drv.find_element( locateBy => locator) }
751
884
 
752
885
 
886
+ ## The following line would render the found element as Stale (TBD).
887
+ ## The caller is responsible to switching (back) to the target window.
888
+ if false && !_frame.nil?
889
+ drv.switch_to.window(current_window)
890
+ end
891
+
892
+
753
893
  rescue Selenium::WebDriver::Error::TimeOutError
754
- Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + "TimeoutError: #{locator} time out."
894
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " TimeoutError: #{locator} time out."
755
895
  rc=nil
756
896
 
757
897
  rescue Selenium::WebDriver::Error::NoSuchElementError
758
- Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + "NoSuchElementError: #{locator} not found."
898
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " NoSuchElementError: #{locator} not found."
759
899
  rc=nil
760
900
 
761
901
  rescue => ex
@@ -792,8 +932,8 @@ module Scoutui::Base
792
932
  rc
793
933
  end
794
934
 
795
- def self.highlight(drv, locator, style={"color" => 255, "border" => 2}, fAncestors=true)
796
- Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " highLight(#{locator})"
935
+ def self.highlight(drv, locator, style={"color" => 'rgb(255, 16, 16)', "border" => 2}, fAncestors=true)
936
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " highLight(#{locator} with style #{style})"
797
937
 
798
938
  rc=false
799
939
 
@@ -809,10 +949,36 @@ module Scoutui::Base
809
949
  return rc
810
950
  end
811
951
 
812
- color=style.has_key?("color")? style["color"] : 255
952
+
953
+ if style.has_key?("color")
954
+
955
+ color=style.has_key?("color")? style["color"] : 'rgb(255, 16, 16)'
956
+
957
+ _c = style["color"]
958
+
959
+ # TODO: refactor with command 'highlight.rb'
960
+
961
+ if _c.match(/\s*blue/i)
962
+ color='rgb(0, 0, 255)'
963
+ elsif _c.match(/\s*red/i)
964
+ color='rgb(255, 0, 0)'
965
+ elsif _c.match(/\s*yellow/i)
966
+ color='rgb(255, 255, 0)'
967
+ elsif _c.match(/\s*green/i)
968
+ color='rgb(0, 255, 0)'
969
+ elsif _c.match(/\s*gray/i)
970
+ color='rgb(128, 128, 128)'
971
+ end
972
+
973
+ end
974
+
975
+
813
976
  border=style.has_key?("border")? style["border"] : 1
814
977
 
815
- drv.execute_script("hlt = function(c) { c.style.border='solid #{border}px rgb(#{color}, 16, 16)'; }; return hlt(arguments[0]);", element)
978
+ _js = "hlt = function(c) { c.style.border='solid #{border}px rgb(#{color}, 16, 16)'; }; return hlt(arguments[0]);"
979
+
980
+ # drv.execute_script("hlt = function(c) { c.style.border='solid #{border}px rgb(#{color}, 16, 16)'; }; return hlt(arguments[0]);", element)
981
+ drv.execute_script("hlt = function(c) { c.style.border='solid #{border}px #{color}'; }; return hlt(arguments[0]);", element)
816
982
  parents = ""
817
983
 
818
984
  if fAncestors
@@ -0,0 +1,63 @@
1
+ require 'singleton'
2
+ #require 'browsermob/proxy'
3
+
4
+
5
+ module Scoutui::Base
6
+
7
+ class QHarMgr
8
+ include Singleton
9
+
10
+ attr_accessor :proxy_binary
11
+ attr_accessor :proxy
12
+ attr_accessor :seleniumProfile
13
+
14
+
15
+ def initialize()
16
+ puts __FILE__ + (__LINE__).to_s + " -- start BrowserMob --" if Scoutui::Utils::TestUtils.instance.isDebug?
17
+ @proxy_binary = BrowserMob::Proxy::Server.new(ENV['BROWSER_MOB_BIN'], { :port => 8088 })
18
+ end
19
+
20
+ def start()
21
+ puts __FILE__ + (__LINE__).to_s + " --start --"
22
+ @proxy_binary.start
23
+ @proxy = @proxy_binary.create_proxy
24
+ @seleniumProfile = @proxy.selenium_proxy # Needed by Selenium instance
25
+
26
+ @proxy.new_har(:capture_headers => true)
27
+ end
28
+
29
+
30
+ def getSeleniumProfile()
31
+ puts __FILE__ + (__LINE__).to_s + " == getSeleniumProfile() => #{@seleniumProfile} --"
32
+ @seleniumProfile
33
+ end
34
+
35
+ def stop(save_as=nil)
36
+ puts __FILE__ + (__LINE__).to_s + " -- stop(#{save_as.to_s} --"
37
+ # @proxy.close
38
+
39
+ if !save_as.nil?
40
+ @proxy.har.save_to(save_as)
41
+ end
42
+
43
+ @proxy.close
44
+ end
45
+
46
+ def capture_traffic
47
+ # @proxy.new_har
48
+ yield
49
+ @proxy.har
50
+ end
51
+
52
+ def run(n)
53
+ puts __FILE__ + (__LINE__).to_s + " -- run --"
54
+ @har = capture_traffic { yield }
55
+ # @proxy.close
56
+ # @har.save_to(n)
57
+ end
58
+
59
+
60
+ end
61
+
62
+
63
+ end
@@ -1,8 +1,6 @@
1
1
 
2
2
 
3
3
  require 'singleton'
4
-
5
- gem 'DataMgr', '=0.1.1.1.pre'
6
4
  require 'DataMgr'
7
5
 
8
6
  module Scoutui::Base
@@ -103,7 +103,8 @@ module Scoutui::Base
103
103
  rescue => ex
104
104
  Scoutui::Utils::TestUtils.instance.setState(:abort, __FILE__ + (__LINE__).to_s + " : #{ex.class.to_s}: #{ex}")
105
105
  Scoutui::Logger::LogMgr.instance.warn __FILE__ + (__LINE__).to_s + " #{ex.class.to_s} Error during processing: #{ex}"
106
- Scoutui::Logger::LogMgr.instance.warn ex.backtrace
106
+ # Scoutui::Logger::LogMgr.instance.warn ex.backtrace
107
+ Scoutui::Logger::LogMgr.instance.warn __FILE__ + (__LINE__).to_s + "Backtrace:\n\t#{ex.backtrace.join("\n\t")}"
107
108
  ensure
108
109
  Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__ ).to_s + " Close Eyes" if Scoutui::Utils::TestUtils.instance.isDebug?
109
110
  @eyeScout.closeOut()