test_utils 0.1.1 → 0.1.2

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: 6f5cc67e26da491024e823bc41b1a50db9c5b55c
4
- data.tar.gz: 12439ec011be63d4494c7437d9f031b22479b2cc
3
+ metadata.gz: cbb5176870f09ae466b4b886d5aa61506ae28f2e
4
+ data.tar.gz: 19e6ef95190cfd5a306c5f2989bac64cc06b815d
5
5
  SHA512:
6
- metadata.gz: bbad3487f30cc243dcfe444e0d5a502466dbefb91860fef118098e0e86a86456d3ed9716f2af17ce6f29788bdece5781326877e9ec158c090177898ac23e8c76
7
- data.tar.gz: 4704927d1ed5712c7042f16f8155d7fbc009e73c1b18b5cf7c713a10ceb16e11b939d9572f33ab5a26e9fd7c5aea4389d05f0ea22a5d69a8043570b23370702e
6
+ metadata.gz: 833ff1cf55fe0dd0da232c5f6a7e0e3e24be9a6fd155561a30b5c035f1613eed52c0d9c8ffc11d27b4bfc68f01d36c2d15d8aa07818eab250104cafa0ca74708
7
+ data.tar.gz: 0c645c1fde916ba8485c994a5ec80796da85b93c2df5e3f75c948b586f3d0c807ebb314ebaa1833a293c96edc33acefa779a47d9c8b6583bcecb14a457af197d
data/README.md CHANGED
@@ -23,27 +23,50 @@ Or install it yourself as:
23
23
 
24
24
  ### Start up a browser locally
25
25
 
26
- 1. Set the environment variable "PLATFORM" to "Chrome", "Firefox" or "Mobile". The drivers are already included in the (resources) directory.
26
+ Set the environment variable "BROWSER" to "Chrome", "Firefox" or "Mobile". The drivers are already included in the (resources) directory.
27
27
 
28
- `$ PLATFORM=Chrome`
28
+ `$ BROWSER=Chrome`
29
29
 
30
- ```ruby
31
- require 'test_utils/browser_tests/browser_setup'
32
- include BrowserSetup
30
+ ```ruby
31
+ require 'test_utils/browser_tests/browser_setup'
32
+ include BrowserSetup
33
33
 
34
- start_browser
35
- @browser.goto 'https://github.com/ef-ice/test_utils'
36
- raise 'not found!' unless @browser.title.include?('Readme')
37
- close_browser
38
-
39
- ```
34
+ start_browser
35
+ @browser.goto 'https://github.com/ef-ice/test_utils'
36
+ raise 'not found!' unless @browser.title.include?('Readme')
37
+ close_browser
38
+ ```
40
39
 
41
40
  Note: Using "Mobile" will start a browser in mobile size (this uses the [webdriver-user-agent](https://github.com/alisterscott/webdriver-user-agent) gem)
42
41
 
43
42
 
44
43
  ### Start up a browser in Browser stack
45
44
 
46
- 1. Set the environment variable "BS":
45
+ Browserstack requires to set four capabilities to start up a browser (os, osVersion, browser, browserVersion). This is too cumbersome, so instead with this gem you can set a single environment variable called "BS" that combines all of these together and sets them up on their corresponding capabilities when you call "start_browser".
46
+
47
+ The format for the "BS" environment variable is "osName_osVersion_browserName_browserVersion" in desktop, and "device_version" in mobile.
48
+
49
+ #### Running tests in desktop:
50
+
51
+ 1. osName: win (windows), mac.
52
+
53
+ 2. osVersion: See options [here](https://www.browserstack.com/list-of-browsers-and-platforms?product=automate).
54
+
55
+ 3. browserName: ie, chrome, firefox, etc.
56
+
57
+ 4. browserVersion: blank for latest, otherwise any option from [here](https://www.browserstack.com/list-of-browsers-and-platforms?product=automate).
58
+
59
+
60
+ #### Valid values for mobile:
61
+
62
+ 1. device: iphone, android.
63
+
64
+ 2. deviceVersion: 6s, nexus5, etc. (see options [here](https://www.browserstack.com/list-of-browsers-and-platforms?product=automate))
65
+
66
+
67
+ #### Examples
68
+
69
+ 1. Set your "BS" env var:
47
70
 
48
71
  `$ BS="win_7_ie_11"`
49
72
 
@@ -55,13 +55,13 @@ module BrowserSetup
55
55
  @browser = Watir::Browser.new(:chrome, :http_client => client, :switches => %w[--no-sandbox])
56
56
  rescue Net::ReadTimeout => error
57
57
  if times_retried < max_retries
58
- p '### ERROR: Net::ReadTimeout on Browser Initialize (Watir::Browser.new) ###'
59
- p '### RETRYING ... ###'
58
+ puts '### ERROR: Net::ReadTimeout on Browser Initialize (Watir::Browser.new) ###'
59
+ puts '### RETRYING ... ###'
60
60
  sleep 2
61
61
  times_retried += 1
62
62
  retry
63
63
  else
64
- p '### ERROR: Net::ReadTimeout on Browser Initialize (Watir::Browser.new) ###'
64
+ puts '### ERROR: Net::ReadTimeout on Browser Initialize (Watir::Browser.new) ###'
65
65
  p error
66
66
  fail "Browser failed to initialize after #{(times_retried + 1)} attempts. ###"
67
67
  end
@@ -120,23 +120,20 @@ module BrowserSetup
120
120
 
121
121
  # Closes the browser
122
122
  # Takes screenshot and prints relevant information before closing
123
- def close_browser(scenario = nil)
124
- if !scenario.nil? && !@browser.nil?
125
- if @current_page.nil?
126
- file_name = "#{DateTime.now.strftime("%Y%m%d_%H%M%S")}.png"
127
- @browser.screenshot.save file_name
128
- embed(file_name, 'image/png')
129
- else
130
- file_name = "#{@current_page.class}-#{DateTime.now.strftime("%Y%m%d_%H%M%S")}.png"
131
- @current_page.save_screenshot(file_name)
132
- embed(file_name, 'image/png')
133
- end
134
- if scenario.failed?
135
- print_session_storage
136
- print_console_errors
137
- end
123
+ def close_browser
124
+ unless @browser.nil?
125
+ take_screenshot
126
+ print_session_storage
127
+ print_console_errors
128
+ @browser.close
138
129
  end
139
- @browser.close unless @browser.nil?
130
+ end
131
+
132
+ # Save screenshot
133
+ def take_screenshot
134
+ file_name = "error-#{DateTime.now.strftime("%Y%m%d_%H%M%S")}.png"
135
+ @browser.screenshot.save file_name
136
+ embed(file_name, 'image/png')
140
137
  end
141
138
 
142
139
  # Prints all sessionStorage data
@@ -1,3 +1,3 @@
1
1
  module TestUtils
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cinthya Villalobos
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-06 00:00:00.000000000 Z
11
+ date: 2017-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: selenium-webdriver