browza 0.0.2.beta2 → 0.0.3

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: 58d7a048ff31099323ddbe6b22a0960e4e7d554c
4
- data.tar.gz: 49a4e1ee2cb8145b8c6b5c509dc42816c271961f
3
+ metadata.gz: 9be45cff4eee8f679be47ac85f127f5031ed9338
4
+ data.tar.gz: 8d1f2adb8fdf39e2050bd909f8f6b56dec29981f
5
5
  SHA512:
6
- metadata.gz: 10a3f291df8bf8615146bb526f8ba6cb68eb1e05057d1a70c2b4e3cf3a119f29f3542b98508cd3d791953cedb05038079a93638ef1e750c8d1816b9ac466dd11
7
- data.tar.gz: 777b465d8950e7f3208c2658007509ec0291b4dc82e21e0af4aab7cca072c2d906cee23896c7e9f53f32afee4bd9382d8368b3575bfcc3789f5b13a23dd33254
6
+ metadata.gz: ee4d7640add30d9f0f067e0b841c0d6c488d4b740bf431f4facf2208e4f8a91fe341d82a7004fc3628297e67817b1dcef7de45b203a8e5bdad6b22ef3f5fc554
7
+ data.tar.gz: 225b1e0fc62b853f1e345fc63c568622e9f9636f0fbb8b797b95f705b2172d2764b772266577d87a01001d591e614842fd4eb50929d3c8f8f3afb649edc840e4
data/README.md CHANGED
@@ -1,2 +1,104 @@
1
1
 
2
2
  # Browza
3
+
4
+ ## Description
5
+
6
+ Very simple, yet reliable, Selenium-Webdriver3, command module. Simple set of commands to automate your browser
7
+ without having to code.
8
+
9
+ Browza also supports and easily integrates with Ruby Gem *appmodel* which supports modeling (e.g. simplify pageObjects).
10
+
11
+ ## APIs
12
+
13
+ ### click(<locator>)
14
+
15
+ ### Browser Creation
16
+ 1. createBrowser
17
+ * createBrowser(:chrome)
18
+ * createBrowser(:firefox)
19
+ 1. start()
20
+ * Run locally
21
+ 1. SELENIUM_RUN=local
22
+ 1. SELENIUM_PLATFORM=local
23
+ 1. SELENIUM_BROWSER=[ chrome | firefox | ie | edge ]
24
+ 1. SELENIUM_RESOLUTION=[widthxheight]
25
+ * 1024x768
26
+ * Run on SauceLabs
27
+ 1. SELENIUM_PLATFORM=[ Windows 8.1 | Windows 10 | linux | osx* ]
28
+ 1. SELENIUM_BROWSER=[ chrome | firefox | ie | edge ]
29
+ 1. SELENIUM_VERSION=[ version of browser ]
30
+ * 11.0 (for IE)
31
+ * 57.0 (for Chrome)
32
+ * 52.0 (for Chrome/Firefox)
33
+ * etc
34
+ 1. SELENIUM_RESOLUTION=[widthxheight]
35
+
36
+
37
+ ### displayed?(<locator>)
38
+
39
+ Returns true if the locator is displayed (visible).
40
+
41
+ ### focusedText
42
+
43
+ Returns the text of the currently focused element.
44
+
45
+ ### focusedValue
46
+
47
+ Returns the value of the currently focused element.
48
+
49
+ ### highlight(<locator>)
50
+
51
+ Highlight the provided locator.
52
+
53
+ ### hover(<locator>)
54
+
55
+ Mouseover the provided locator.
56
+
57
+ ### isFocused(<locator>)
58
+
59
+ Returns true if the currently focused element matches the locator.
60
+
61
+ ### navigate
62
+
63
+ ### press(<key>)
64
+
65
+ Press the keyboard key.
66
+
67
+
68
+ ### setTimeout
69
+
70
+ Sets the default explicit default timeout (30 sec.)
71
+
72
+ ### addModel(<path to model file>)
73
+
74
+ Add a model specified by a file (e.g. JSON). The model is a superset of a page object.
75
+
76
+ ### setDimension(width, height)
77
+
78
+ Set/resize browser viewport.
79
+
80
+ ### maximize
81
+
82
+ Maximize the browser.
83
+
84
+ ### quit
85
+
86
+ Quit browser (quit & close)
87
+
88
+ ### title
89
+
90
+ Get the title from the currently loaded page.
91
+
92
+ ### isChrome?
93
+
94
+ Returns true, if the browser under test is Chrome.
95
+
96
+
97
+ ### isTitle?(<regex>)
98
+
99
+ Returns a boolean - based on whether the current title matches the provided regEx.
100
+
101
+ ### selected?(<locator>)
102
+ Returns true, if the locator is 'selected' (e.g. radio/checkbox button)
103
+
104
+ ### type(<locator>, <text>)
data/browza.gemspec CHANGED
@@ -19,10 +19,11 @@ 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.11"
23
- spec.add_development_dependency "rake", "~> 10.0"
24
- spec.add_development_dependency "rspec", "~> 3.0"
22
+ spec.add_development_dependency "bundler", "~> 1.14.6"
23
+ spec.add_development_dependency "rake", "~> 12.0.0"
24
+ spec.add_development_dependency "rspec", "~> 3.5.0"
25
25
  spec.add_development_dependency "appmodel", "~> 0.1.2"
26
- spec.add_development_dependency "selenium-webdriver"
26
+ spec.add_development_dependency "selenium-webdriver", "~> 3.4.0"
27
27
  spec.add_development_dependency "logging", "~> 2.2"
28
+ spec.add_development_dependency "sauce_whisk", "~> 0.1.0"
28
29
  end
data/examples/ex1.rb ADDED
@@ -0,0 +1,25 @@
1
+
2
+
3
+
4
+ require_relative '../lib/browza'
5
+
6
+
7
+ puts "Creating Chrome Browser!"
8
+
9
+
10
+ ENV['SELENIUM_BROWSER']='firefox'
11
+ Browza::Manager.instance.createBrowser()
12
+
13
+
14
+ puts "Navigate to playground"
15
+ Browza::Manager.instance.navigate('https://stark-bastion-95510.herokuapp.com/playground')
16
+
17
+ Browza::Manager.instance.click("//button[text()='Van Halen']")
18
+
19
+ Browza::Manager.instance.highlight("//button[text()='Van Halen']", 'red')
20
+
21
+
22
+ puts "PRESS ENTER to Continue .."
23
+ STDIN.gets
24
+
25
+ Browza::Manager.instance.quit()
data/examples/ex2.rb ADDED
@@ -0,0 +1,23 @@
1
+
2
+
3
+
4
+ require_relative '../lib/browza'
5
+
6
+
7
+ puts "Creating Chrome Browser!"
8
+
9
+
10
+ Browza::Manager.instance.createBrowser(:chrome)
11
+ Browza::Manager.instance.createBrowser(:chrome)
12
+
13
+
14
+ puts "Navigate to playground"
15
+ Browza::Manager.instance.navigate('https://stark-bastion-95510.herokuapp.com/playground')
16
+
17
+ Browza::Manager.instance.click("//button[text()='Van Halen']")
18
+
19
+ Browza::Manager.instance.highlight("//button[text()='Van Halen']", 'red')
20
+
21
+
22
+ puts "PRESS ENTER to Continue .."
23
+ STDIN.gets
data/examples/parms.rb ADDED
@@ -0,0 +1,45 @@
1
+
2
+
3
+
4
+ def press(k, n=1)
5
+
6
+ end
7
+
8
+ def pressIt(*p)
9
+
10
+ puts "[pressIt]: length: #{p.length} p => #{p} 0:#{p[0]} 1:#{p[1]}"
11
+
12
+ end
13
+
14
+ def foo(*p)
15
+
16
+
17
+ puts __FILE__ + (__LINE__).to_s + p.class.to_s
18
+
19
+ if p.is_a?(Array)
20
+
21
+ puts __FILE__ + (__LINE__).to_s + " SZ : #{p.size.to_s}"
22
+ i=0
23
+ p.each do |elt|
24
+ puts " #{i}. #{elt.class} : #{elt.to_s}"
25
+ end
26
+ end
27
+
28
+ end
29
+
30
+
31
+
32
+ puts "START"
33
+
34
+ foo(:chrome)
35
+
36
+ foo( 100 )
37
+
38
+ foo( {:name => 'Peter'}, {:age => 'ThritySix'})
39
+
40
+
41
+
42
+ pressIt('one')
43
+
44
+
45
+ pressIt('page(one)', 'tab')
@@ -0,0 +1,110 @@
1
+
2
+ require 'logging'
3
+
4
+ module Browza
5
+
6
+
7
+
8
+ class BrowzaMgr
9
+ attr_accessor :driverList
10
+
11
+
12
+ def initialize
13
+ @logger = Logging.logger(STDOUT)
14
+ @logger.level = :debug
15
+ @driverList = []
16
+ end
17
+
18
+ def clear
19
+ @driverList=[]
20
+ end
21
+
22
+ def getBrowsers()
23
+ @driverList
24
+ end
25
+
26
+ def add(device)
27
+
28
+ if !device.is_a?(Hash)
29
+ @driverList << { :is_sauce => false, :drv => device }
30
+ else
31
+ @driverList << device
32
+ end
33
+
34
+ @driverList.last
35
+ end
36
+
37
+ def set(id, prop, val)
38
+ get(id)[prop] = val
39
+
40
+ end
41
+
42
+ def get(id)
43
+ @driverList.each do |elt|
44
+ if elt.has_key?(:id) && elt[:id] == id
45
+ return elt
46
+ end
47
+ end
48
+
49
+ nil
50
+ end
51
+
52
+ def getDriver(id=nil)
53
+
54
+ if id.nil? && @driverList.length > 0
55
+ return @driverList.first
56
+ elsif @driverList.length > 0
57
+ @driverList.each do |b|
58
+ if b.has_key?(:id) && b[:id] == id
59
+ return b[:drv]
60
+ end
61
+ end
62
+ end
63
+
64
+ nil
65
+ end
66
+
67
+
68
+ def setSauceStatus(id, status)
69
+ @driverList.each do |b|
70
+ if b.has_key?(:id) && b[:id]==id
71
+ b[:status] = status
72
+ end
73
+ end
74
+ end
75
+
76
+
77
+ # Set innerWidth and innerHeight
78
+ def setDimension(width = 1035, height = 768)
79
+
80
+ begin
81
+ @driverList.each do |b|
82
+ target_size = Selenium::WebDriver::Dimension.new(width, height)
83
+ b[:drv].manage.window.size = target_size
84
+ end
85
+ rescue => ex
86
+ @logger.warn __FILE__ + (__LINE__).to_s + " #{ex.class}"
87
+ @logger.warn "Error during processing: #{$!}"
88
+ @logger.warn "Backtrace:\n\t#{ex.backtrace.join("\n\t")}"
89
+ end
90
+ end
91
+
92
+ def maximize()
93
+ begin
94
+ @driverList.each do |b|
95
+ target_size = Selenium::WebDriver::Dimension.new(width, height)
96
+ b[:drv].manage.window.maximize
97
+ end
98
+ rescue => ex
99
+ @logger.warn __FILE__ + (__LINE__).to_s + " #{ex.class}"
100
+ @logger.warn "Error during processing: #{$!}"
101
+ @logger.warn "Backtrace:\n\t#{ex.backtrace.join("\n\t")}"
102
+ end
103
+
104
+ end
105
+
106
+ end
107
+
108
+
109
+
110
+ end