browza 0.0.3.3 → 0.0.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fd61a969dc11056dbb1109fc1ef5ee41cc4e7d34
4
- data.tar.gz: 89e6c7133d312ecb9bc9d4e44abdd61aea4d38d5
3
+ metadata.gz: 1f585272615cc34b9fd6cab5b62ebc7b49d81ea2
4
+ data.tar.gz: f245efdf8c0efe55343a2a8257d91d37eb130e98
5
5
  SHA512:
6
- metadata.gz: 1b5c35e769e9dd79688810167814f5e2f3ec2d1d5691e7be15b0466647d42c0556ee3792bac2f1c9932296104a436a3dffbc7faa36c07934e4ccc03fd30f8e20
7
- data.tar.gz: 194681b280cd0e17e5a490f149344b715ad0d65cea21cf183289c93b3eec813a058553f0d2246b58bd9f53f47ba6a406da215ca99591398c4a14f4c39be08b2e
6
+ metadata.gz: 9f016cc16f532f489587f270c4e95f87b08ceaf9f85b0b50266cca463560a830d5bef9c5b3c451f1e5c0b76124b90f06dcda79c59df5b829f565f272b7984c23
7
+ data.tar.gz: 87e1570f64ccfc9cecef64015bda610bc662ba008a09143cd03430589e96fd464dd9cbbc19023eb92cbbd171d0b14d5c2d5d0d8672cd45b4bae5300b280d258d
data/browza.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_development_dependency "bundler", "~> 1.14.6"
22
+ spec.add_development_dependency "bundler", "~> 1.15.4"
23
23
  spec.add_development_dependency "rake", "~> 12.0.0"
24
24
  spec.add_development_dependency "rspec", "~> 3.5.0"
25
25
  spec.add_development_dependency "appmodel", "~> 0.1.2"
@@ -9,10 +9,12 @@ module Browza
9
9
  class Manager
10
10
 
11
11
  include Singleton
12
+ include Singleton
12
13
 
13
14
  attr_accessor :drv
14
15
  attr_accessor :appModels
15
16
  attr_accessor :browserType
17
+ attr_accessor :defaultRetries
16
18
  attr_accessor :defaultTimeout
17
19
  attr_accessor :driverList
18
20
  attr_accessor :browserMgr
@@ -25,6 +27,7 @@ class Manager
25
27
  @logger.level = _logLevel
26
28
  @defaultTimeout = 30
27
29
  @appModels=[]
30
+ @defaultRetries = 2
28
31
  @browserMgr = Browza::BrowzaMgr.new()
29
32
  end
30
33
 
@@ -766,7 +769,7 @@ class Manager
766
769
 
767
770
  if _hit.is_a?(Hash)
768
771
 
769
- 2.times {
772
+ @defaultRetries.times {
770
773
 
771
774
  begin
772
775
  rcFrame = true
@@ -865,6 +868,25 @@ class Manager
865
868
  obj
866
869
  end
867
870
 
871
+
872
+ def scrollTo(_locator)
873
+
874
+ drv = @driverList[0][:drv]
875
+
876
+ obj = findLocator(_locator)
877
+
878
+ scrollElementIntoMiddle = "var viewPortHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);" +
879
+ "var elementTop = arguments[0].getBoundingClientRect().top;" +
880
+ "window.scrollBy(0, elementTop-(viewPortHeight/2) + 150);";
881
+
882
+ drv.execute_script("arguments[0].scrollIntoView(true);", obj);
883
+ drv.action.move_to(obj).perform
884
+ # drv.execute_script(scrollElementIntoMiddle, obj)
885
+
886
+ end
887
+
888
+
889
+
868
890
  ##
869
891
  # Browza.instance.click('page(sideNav).get(desktop)')
870
892
  ##
@@ -903,6 +925,9 @@ class Manager
903
925
  obj.click
904
926
  rc = true
905
927
  end
928
+
929
+ rescue Selenium::WebDriver::Error::UnknownError
930
+
906
931
  rescue => ex
907
932
  @logger.debug __FILE__ + (__LINE__).to_s + " #{ex.class} : #{_locator}"
908
933
  @logger.debug "Backtrace:\n\t#{ex.backtrace.join("\n\t")}"
@@ -917,11 +942,15 @@ class Manager
917
942
  rc
918
943
  end
919
944
 
920
- def highlight(_locator, color='red', _drv=nil, _timeout=30)
945
+ def highlight(_locator=nil, color='red', _drv=nil, _timeout=30)
921
946
  rc = false
922
947
  rgb = nil
923
948
  obj = nil
924
949
 
950
+ if _locator.nil?
951
+ _locator = @drv.switch_to.active_element
952
+ end
953
+
925
954
  if _locator.is_a?(Selenium::WebDriver::Element)
926
955
  obj = _locator
927
956
  else
@@ -977,6 +1006,44 @@ class Manager
977
1006
  end
978
1007
 
979
1008
 
1009
+ def tabUntil( opts )
1010
+ defaults = { :enableHighlight => false, :verbose => false, :max => 25 }
1011
+ opts = defaults.merge(opts)
1012
+
1013
+
1014
+ if opts[:verbose]
1015
+ puts "[tabUntil]: " + opts.to_s
1016
+ end
1017
+
1018
+ # startObj = @drv.switch_to.active_element
1019
+ i = 0
1020
+ while i < opts[:max].to_i do
1021
+
1022
+ @drv.action.send_keys(:tab).perform
1023
+
1024
+ obj = @drv.switch_to.active_element
1025
+
1026
+ if obj.is_a?(Selenium::WebDriver::Element) && obj.displayed?
1027
+ puts "#{i}. " + obj.text.to_s + " : " + obj.attribute('value').to_s if opts[:verbose]
1028
+ i += 1
1029
+ end
1030
+
1031
+ if false && obj == startObj
1032
+ puts ".. wrapped"
1033
+ break
1034
+ end
1035
+
1036
+ if opts[:enableHighlight]
1037
+ highlight(obj)
1038
+ end
1039
+
1040
+ end
1041
+
1042
+ puts "[tabUntil]: total: #{i.to_s}"
1043
+
1044
+ end
1045
+
1046
+
980
1047
  def type(_locator, _text, _timeout=30)
981
1048
  rc = false
982
1049
 
@@ -1079,14 +1146,24 @@ class Manager
1079
1146
  def isNotDisplayed?(_locator, _timeout=10)
1080
1147
  rc = false
1081
1148
  _saveDefault = @defaultTimeout
1149
+ _saveRetries = @defaultRetries
1082
1150
 
1083
1151
  @defaultTimeout = _timeout
1152
+ @defaultRetries = 1
1153
+
1154
+ i=0
1084
1155
  begin
1085
- rc = !displayed?(_locator, getDriver(), _timeout)
1156
+ while i < 4 && !rc
1157
+ rc = !displayed?(_locator, getDriver(), _timeout)
1158
+ i+=1
1159
+ sleep 0.25
1160
+ end
1086
1161
  rescue => ex
1162
+ i+=1
1087
1163
  ;
1088
1164
  end
1089
1165
 
1166
+ @defaultRetries = _saveDefault
1090
1167
  @defaultTimeout = _saveDefault
1091
1168
  rc
1092
1169
  end
@@ -1146,27 +1223,58 @@ class Manager
1146
1223
 
1147
1224
  def isVisible?(_locator, expected = true, _timeout = 30)
1148
1225
  obj = nil
1226
+ rc = nil
1149
1227
 
1228
+ begin
1229
+ @drv.switch_to.default_content
1150
1230
 
1151
- @drv.switch_to.default_content
1231
+ if _locator.is_a?(Selenium::WebDriver::Element)
1232
+ obj = _locator
1152
1233
 
1153
- if _locator.is_a?(Selenium::WebDriver::Element)
1154
- obj = _locator
1234
+ rc = Selenium::WebDriver::Wait.new(timeout: _timeout).until {
1235
+ obj.displayed?
1236
+ }
1237
+ else
1238
+ rc = Selenium::WebDriver::Wait.new(timeout: _timeout).until {
1239
+ obj = findLocator(_locator, @drv)
1240
+ obj.is_a?(Selenium::WebDriver::Element) && obj.displayed?
1241
+ }
1242
+ end
1155
1243
 
1156
- rc = Selenium::WebDriver::Wait.new(timeout: _timeout).until {
1157
- obj.displayed?
1158
- }
1159
- else
1160
- rc = Selenium::WebDriver::Wait.new(timeout: _timeout).until {
1161
- obj = findLocator(_locator, @drv)
1162
- obj.is_a?(Selenium::WebDriver::Element) && obj.displayed?
1163
- }
1244
+ rescue Selenium::WebDriver::Error::TimeOutError
1245
+ rc = false
1164
1246
  end
1165
-
1166
1247
  @logger.debug __FILE__ + (__LINE__).to_s + " isVisible?(#{_locator}) : #{rc}"
1167
1248
  rc == expected
1168
1249
  end
1169
1250
 
1251
+ def isNotVisible?(_locator, _timeout = 30)
1252
+ obj = nil
1253
+ rc = nil
1254
+
1255
+ begin
1256
+ @drv.switch_to.default_content
1257
+
1258
+ if _locator.is_a?(Selenium::WebDriver::Element)
1259
+ obj = _locator
1260
+
1261
+ rc = Selenium::WebDriver::Wait.new(timeout: _timeout).until {
1262
+ obj.displayed?
1263
+ }
1264
+ else
1265
+ rc = Selenium::WebDriver::Wait.new(timeout: _timeout).until {
1266
+ obj = findLocator(_locator, @drv)
1267
+ obj.is_a?(Selenium::WebDriver::Element) && obj.displayed?
1268
+ }
1269
+ end
1270
+
1271
+ rescue Selenium::WebDriver::Error::TimeOutError
1272
+ rc = true
1273
+ end
1274
+
1275
+ rc
1276
+ end
1277
+
1170
1278
 
1171
1279
  def isValue?(_locator, regex=nil, _timeout = 30)
1172
1280
  @logger.debug __FILE__ + (__LINE__).to_s + " isValue?(#{_locator}, #{regex})"
@@ -1274,6 +1382,11 @@ class Manager
1274
1382
  elsif k.match(/\s*^up/i)
1275
1383
  activeElt = @drv.switch_to.active_element
1276
1384
  activeElt.send_keys(:arrow_up)
1385
+ elsif k.match(/\s*escape/i)
1386
+ activeElt = @drv.switch_to.active_element
1387
+ activeElt.send_keys(:escape)
1388
+ elsif k.match(/\s*page_down/i)
1389
+ @drv.action.send_keys(:page_down).perform
1277
1390
  elsif k.match(/\s*__SHIFT_TAB__\s*$/i)
1278
1391
  @drv.action.key_down(:shift).send_keys(:tab).perform
1279
1392
  @drv.action.key_up(:shift).perform
@@ -1,3 +1,3 @@
1
1
  module Browza
2
- VERSION = "0.0.3.3"
2
+ VERSION = "0.0.3.4"
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.3.3
4
+ version: 0.0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - H20Dragon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-15 00:00:00.000000000 Z
11
+ date: 2017-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.14.6
19
+ version: 1.15.4
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.14.6
26
+ version: 1.15.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement