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 +4 -4
- data/README.md +35 -12
- data/lib/test_utils/browser_tests/browser_setup.rb +16 -19
- data/lib/test_utils/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbb5176870f09ae466b4b886d5aa61506ae28f2e
|
4
|
+
data.tar.gz: 19e6ef95190cfd5a306c5f2989bac64cc06b815d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
26
|
+
Set the environment variable "BROWSER" to "Chrome", "Firefox" or "Mobile". The drivers are already included in the (resources) directory.
|
27
27
|
|
28
|
-
|
28
|
+
`$ BROWSER=Chrome`
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
```ruby
|
31
|
+
require 'test_utils/browser_tests/browser_setup'
|
32
|
+
include BrowserSetup
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
-
|
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
|
-
|
59
|
-
|
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
|
-
|
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
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
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
|
-
|
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
|
data/lib/test_utils/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2017-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: selenium-webdriver
|