browser_loader 0.0.1
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 +7 -0
- data/.gitignore +16 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +121 -0
- data/Rakefile +2 -0
- data/browser_loader.gemspec +29 -0
- data/lib/browser_loader/factory.rb +229 -0
- data/lib/browser_loader/version.rb +3 -0
- data/lib/browser_loader.rb +6 -0
- data/spec/browser_loader/factory_spec.rb +84 -0
- data/spec/browser_loader_spec.rb +7 -0
- data/spec/spec_helper.rb +106 -0
- metadata +160 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9786f16b4c91590fdf042a5af94ec91f7e7d8f84
|
4
|
+
data.tar.gz: dc0d6aeed2d7ab216b73a8139c721eb29241c107
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7e6c7075a6daf172b48ce29766bd49d224cc8ad9b68df620831c9f7f03f1d17978121c879ffbc2bfd92d9e6ca3c6b940664c203ee7795ee18ec1fdaee8a58710
|
7
|
+
data.tar.gz: 14540904aa50ba8b0bed54713adab5d1919580a95584b2019c8f4624a6b95a8a08e7098433fa53d5745019e5899cdff474b80465c873ea4967f0c029bc9365f7
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Jeff McAffee
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
# BrowserLoader
|
2
|
+
|
3
|
+
BrowserLoader is a watir-webdriver based browser loader class. It provides
|
4
|
+
additional chromium configuration options.
|
5
|
+
|
6
|
+
After I re-created this functionality for the 3rd time, I decided to turn it
|
7
|
+
into a gem so updates could take place in one location rather than multiple
|
8
|
+
places.
|
9
|
+
|
10
|
+
While BrowserLoader provides configuration for Chromium, it can load Firefox
|
11
|
+
or IE if desired. At this time, default configurations are used when loading
|
12
|
+
Firefox or IE.
|
13
|
+
|
14
|
+
When running on a linux OS, BrowserLoader will start the system's version of
|
15
|
+
the browser; the executable returned by `which chromium-browser`. When running
|
16
|
+
on windows, if using Chromium, a path to the Chromium/Chrome executable must
|
17
|
+
be provided.
|
18
|
+
|
19
|
+
Rather than being a nuisance, providing the executable path allows you to use
|
20
|
+
an older version of chromium for your testing. This becomes valuable if you
|
21
|
+
consider the breaking changes automatic updates of the browser can cause.
|
22
|
+
|
23
|
+
For me, this was especially a problem on windows.
|
24
|
+
|
25
|
+
Current versions of Chromium can be found at [http://chromium.woolyss.com](http://chromium.woolyss.com)
|
26
|
+
and older versions can be downloaded from the `continous` repo maintained by
|
27
|
+
Google at [https://storage.googleapis.com/chromium-browser-continuous/index.html](https://storage.googleapis.com/chromium-browser-continuous/index.html).
|
28
|
+
|
29
|
+
When creating the browser object, BrowserLoader looks for an environment variable
|
30
|
+
named `BROWSER`. If it exists and is populated with a recognized value, Firefox
|
31
|
+
or IE will be started. By default, Chromium will be started.
|
32
|
+
|
33
|
+
Possible `BROWSER` values:
|
34
|
+
|
35
|
+
+ `ie`: Internet Explorer
|
36
|
+
+ `ff`: Firefox
|
37
|
+
|
38
|
+
## Installation
|
39
|
+
|
40
|
+
Add this line to your application's Gemfile:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
gem 'browser_loader'
|
44
|
+
```
|
45
|
+
|
46
|
+
And then execute:
|
47
|
+
|
48
|
+
$ bundle
|
49
|
+
|
50
|
+
Or install it yourself as:
|
51
|
+
|
52
|
+
$ gem install browser_loader
|
53
|
+
|
54
|
+
## Usage
|
55
|
+
|
56
|
+
You can use the BrowserLoader::Factory class directly in your code, or derive/
|
57
|
+
compose a class from it.
|
58
|
+
|
59
|
+
Using it stand-alone:
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
require 'browser_loader'
|
63
|
+
|
64
|
+
# Set the user data (profile) directory
|
65
|
+
BrowserLoader::Factory.user_data_dir = '/tmp/chromium_user_data'
|
66
|
+
|
67
|
+
# Override the default timeout period (in seconds)
|
68
|
+
BrowserLoader::Factory.timeout = 360
|
69
|
+
|
70
|
+
# Configure and start the Chromium browser
|
71
|
+
browser = BrowserLoader::Factory.build
|
72
|
+
|
73
|
+
# Do something with browser...
|
74
|
+
|
75
|
+
```
|
76
|
+
|
77
|
+
Using it through composition:
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
require 'browser_loader'
|
81
|
+
|
82
|
+
module MyModule
|
83
|
+
|
84
|
+
def browser
|
85
|
+
if @browser.nil?
|
86
|
+
# Set the user data (profile) directory
|
87
|
+
BrowserLoader::Factory.user_data_dir = '/tmp/chromium_user_data'
|
88
|
+
|
89
|
+
# Override the default timeout period (in seconds)
|
90
|
+
BrowserLoader::Factory.timeout = 360
|
91
|
+
|
92
|
+
# Configure and start the Chromium browser
|
93
|
+
@browser = BrowserLoader::Factory.build
|
94
|
+
|
95
|
+
# Add an +at_exit+ proc to close the browser when the program exits.
|
96
|
+
at_exit do
|
97
|
+
@browser.close unless @browser.nil?
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end # module
|
102
|
+
|
103
|
+
|
104
|
+
class SomeClass
|
105
|
+
include MyModule
|
106
|
+
|
107
|
+
def goto_google
|
108
|
+
browser.goto 'http://google.com'
|
109
|
+
end
|
110
|
+
end # class
|
111
|
+
|
112
|
+
```
|
113
|
+
|
114
|
+
|
115
|
+
## Contributing
|
116
|
+
|
117
|
+
1. Fork it ( https://github.com/[my-github-username]/browser_loader/fork )
|
118
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
119
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
120
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
121
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'browser_loader/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "browser_loader"
|
8
|
+
spec.version = BrowserLoader::VERSION
|
9
|
+
spec.authors = ["Jeff McAffee"]
|
10
|
+
spec.email = ["jeff@ktechsystems.com"]
|
11
|
+
spec.summary = %q{Watir-webdriver based browser loader class.}
|
12
|
+
spec.description = %q{Watir-webdriver based browser loader class providing additional chromium configuration options.}
|
13
|
+
spec.homepage = "https://github.com/jmcaffee/browser_loader"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_development_dependency "pry"
|
25
|
+
spec.add_development_dependency "pry-byebug"
|
26
|
+
|
27
|
+
spec.add_runtime_dependency "watir-webdriver"
|
28
|
+
spec.add_runtime_dependency "ktutils"
|
29
|
+
end
|
@@ -0,0 +1,229 @@
|
|
1
|
+
##############################################################################
|
2
|
+
# File: factory.rb
|
3
|
+
# Purpose: Browser configuration factory
|
4
|
+
#
|
5
|
+
# Author: Jeff McAffee 10/16/2015
|
6
|
+
# Copyright: Copyright (c) 2015, Jeff McAffee
|
7
|
+
# All rights reserved. See LICENSE.txt for details.
|
8
|
+
# Website: http://JeffMcAffee.com
|
9
|
+
#
|
10
|
+
# Some additional configuration is provided through the environment (variables).
|
11
|
+
#
|
12
|
+
# BROWSER_PROXY_PORT: when present, will be used to proxy connections.
|
13
|
+
#
|
14
|
+
# BROWSER: defaults to chrome/chromium when not set
|
15
|
+
# ie: start Internet Explorer
|
16
|
+
# ff: start Firefox
|
17
|
+
#
|
18
|
+
##############################################################################
|
19
|
+
|
20
|
+
require 'watir-webdriver'
|
21
|
+
require 'ktutils'
|
22
|
+
|
23
|
+
module BrowserLoader
|
24
|
+
class Factory
|
25
|
+
|
26
|
+
def self.client
|
27
|
+
# Client is explicitly instantiated so we can adjust the timeout period
|
28
|
+
# or replace with a mock for testing.
|
29
|
+
@@client ||= Selenium::WebDriver::Remote::Http::Default.new
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.client= new_client
|
33
|
+
@@client = new_client
|
34
|
+
end
|
35
|
+
|
36
|
+
##
|
37
|
+
# Timeout period for browser.
|
38
|
+
# Defaults to 60 seconds
|
39
|
+
#
|
40
|
+
|
41
|
+
def self.browser_timeout
|
42
|
+
@@browser_timeout ||= 60
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.browser_timeout= timeout
|
46
|
+
@@browser_timeout = timeout
|
47
|
+
end
|
48
|
+
|
49
|
+
##
|
50
|
+
# Directory to store profile data in
|
51
|
+
# Defaults to test/chrome-data.
|
52
|
+
#
|
53
|
+
# Directory will be created if it doesn't exist. Note that it is a relative
|
54
|
+
# path, so it is created relative to the current working directory.
|
55
|
+
#
|
56
|
+
# NOTE: The only way I've found to stop the EULA from being displayed is to
|
57
|
+
# use the user-data-dir switch and point to a dir where chrome can put the
|
58
|
+
# data indicating it (EULA) has already been accepted.
|
59
|
+
#
|
60
|
+
|
61
|
+
def self.user_data_dir
|
62
|
+
@@user_data_dir ||= "test/chrome-data"
|
63
|
+
|
64
|
+
# user_data_dir must be expanded to a full (absolute) path. A relative path
|
65
|
+
# results in chromedriver failing to start.
|
66
|
+
@@user_data_dir = File.expand_path(@@user_data_dir)
|
67
|
+
#puts "*** user_data_dir location: #{@@user_data_dir}"
|
68
|
+
|
69
|
+
# Create the data dir if it doesn't exist (or chromedriver fails to start).
|
70
|
+
unless File.exists?(@@user_data_dir) and File.directory?(@@user_data_dir)
|
71
|
+
FileUtils.makedirs @@user_data_dir
|
72
|
+
end
|
73
|
+
|
74
|
+
@@user_data_dir
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.user_data_dir= dir
|
78
|
+
@@user_data_dir = dir
|
79
|
+
end
|
80
|
+
|
81
|
+
##
|
82
|
+
# Directory to store cache data in
|
83
|
+
# Defaults to test/cache-data.
|
84
|
+
#
|
85
|
+
# Directory will be deleted and recreated to ensure a clean cache.
|
86
|
+
# Note thata the path is a relative path. It will be created relative
|
87
|
+
# to the current working directory.
|
88
|
+
#
|
89
|
+
|
90
|
+
def self.disk_cache_dir
|
91
|
+
@@disk_cache_dir ||= "test/cache-data"
|
92
|
+
|
93
|
+
# Store chrome cache at test/cache-data.
|
94
|
+
# We will wipe out this directory on each start to keep a clean cache.
|
95
|
+
@@disk_cache_dir = File.expand_path(@@disk_cache_dir)
|
96
|
+
# Delete the cache dir if it exists, then recreate it.
|
97
|
+
if File.exists?(@@disk_cache_dir) and File.directory?(@@disk_cache_dir)
|
98
|
+
FileUtils.rm_rf @@disk_cache_dir
|
99
|
+
end
|
100
|
+
FileUtils.makedirs @@disk_cache_dir
|
101
|
+
|
102
|
+
@@disk_cache_dir
|
103
|
+
end
|
104
|
+
|
105
|
+
def self.disk_cache_dir= dir
|
106
|
+
@@disk_cache_dir = dir
|
107
|
+
end
|
108
|
+
|
109
|
+
def self.log_level
|
110
|
+
@@log_level ||= 0
|
111
|
+
end
|
112
|
+
|
113
|
+
##
|
114
|
+
# Set the browser logging level
|
115
|
+
#
|
116
|
+
# Sets the minimum log level.
|
117
|
+
# Valid values are from 0 to 3:
|
118
|
+
# INFO = 0
|
119
|
+
# WARNING = 1
|
120
|
+
# LOG_ERROR = 2
|
121
|
+
# LOG_FATAL = 3
|
122
|
+
#
|
123
|
+
|
124
|
+
def self.log_level= level
|
125
|
+
@@log_level = level
|
126
|
+
end
|
127
|
+
|
128
|
+
##
|
129
|
+
# Switches used to configure the chrome/chromium browser
|
130
|
+
#
|
131
|
+
# To modify/add switches:
|
132
|
+
# Factory.switches << "--some-other-switch=#{data}"
|
133
|
+
#
|
134
|
+
# See http://peter.sh/experiments/chromium-command-line-switches/ for a list of available switches.
|
135
|
+
# See https://sites.google.com/a/chromium.org/chromedriver/capabilities for details on setting ChromeDriver caps.
|
136
|
+
#
|
137
|
+
# If BROWSER_PROXY_PORT environment variable is set to a port number,
|
138
|
+
# the --proxy-server switch will be added.
|
139
|
+
#
|
140
|
+
# If you intend to override the user-data-dir, cache-data-dir or logging
|
141
|
+
# level, do so before calling this method.
|
142
|
+
#
|
143
|
+
|
144
|
+
def self.switches
|
145
|
+
@@switches ||= Array.new
|
146
|
+
|
147
|
+
if @@switches.empty?
|
148
|
+
# Default switches:
|
149
|
+
# ignore-certificate-errors: Ignores certificate-related errors.
|
150
|
+
# disable-popup-blocking: Disable pop-up blocking.
|
151
|
+
# disable-translate: Allows disabling of translate from
|
152
|
+
# the command line to assist with
|
153
|
+
# automated browser testing.
|
154
|
+
# no-first-run: Skip First Run tasks, whether or not
|
155
|
+
# it's actually the First Run.
|
156
|
+
@@switches = %w[--ignore-certificate-errors --disable-popup-blocking --disable-translate --no-first-run]
|
157
|
+
@@switches << "--log-level=#{log_level}"
|
158
|
+
@@switches << "--user-data-dir=#{user_data_dir}"
|
159
|
+
@@switches << "--disk-cache-dir=#{disk_cache_dir}"
|
160
|
+
|
161
|
+
proxy_port = ENV['BROWSER_PROXY_PORT']
|
162
|
+
if proxy_port && ! proxy_port.empty?
|
163
|
+
proxy_connection_string = "socks://localhost:#{proxy_port}"
|
164
|
+
@@switches << "--proxy-server=#{proxy_connection_string}"
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
@@switches
|
169
|
+
end
|
170
|
+
|
171
|
+
##
|
172
|
+
# Clear out all switches so they can be reconfigured
|
173
|
+
#
|
174
|
+
|
175
|
+
def self.reset_switches
|
176
|
+
@@switches = Array.new
|
177
|
+
end
|
178
|
+
|
179
|
+
##
|
180
|
+
# Configure and return a browser object
|
181
|
+
#
|
182
|
+
|
183
|
+
def self.build
|
184
|
+
# We must clear out any environmental proxy or Selenium fails
|
185
|
+
# to connect to the local application.
|
186
|
+
ENV['http_proxy'] = nil
|
187
|
+
|
188
|
+
# No configuration is done if IE or Firefox browser is specified.
|
189
|
+
env_browser = ENV['BROWSER']
|
190
|
+
if env_browser
|
191
|
+
if env_browser == "ie"
|
192
|
+
return Watir::Browser.new :ie
|
193
|
+
end
|
194
|
+
|
195
|
+
if env_browser == "ff"
|
196
|
+
return Watir::Browser.new :firefox
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
# Specify chrome browser capabilities.
|
201
|
+
caps = Selenium::WebDriver::Remote::Capabilities.chrome
|
202
|
+
caps['chromeOptions'] = {'binary' => chromium_exe }
|
203
|
+
|
204
|
+
# Set the browser timeout. Default is 60 seconds.
|
205
|
+
client.timeout = browser_timeout
|
206
|
+
|
207
|
+
browser = Watir::Browser.new :chrome,
|
208
|
+
:switches => switches,
|
209
|
+
:http_client => client,
|
210
|
+
:service_log_path => user_data_dir + '/chromedriver.out',
|
211
|
+
:desired_capabilities => caps
|
212
|
+
end
|
213
|
+
|
214
|
+
private
|
215
|
+
|
216
|
+
def self.chromium_exe
|
217
|
+
if Ktutils::OS.windows?
|
218
|
+
# Download from http://chromium.woolyss.com/
|
219
|
+
chromium_exe = ENV["chrome_browser_path"]
|
220
|
+
unless (! chromium_exe.nil? && ! chromium_exe.empty? && File.exist?(chromium_exe))
|
221
|
+
raise "chrome_browser_path environment variable not set"
|
222
|
+
end
|
223
|
+
chromium_exe
|
224
|
+
else
|
225
|
+
chromium_exe = `which chromium-browser`.chomp
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BrowserLoader::Factory do
|
4
|
+
|
5
|
+
let(:factory) { BrowserLoader::Factory }
|
6
|
+
|
7
|
+
it "uses a default client" do
|
8
|
+
expect(factory.client).to_not be nil
|
9
|
+
end
|
10
|
+
|
11
|
+
it "log level is 0 by default" do
|
12
|
+
expect(factory.log_level).to eq 0
|
13
|
+
end
|
14
|
+
|
15
|
+
it "browser timeout is 60 seconds by default" do
|
16
|
+
expect(factory.browser_timeout).to eq 60
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'user_data_dir is test/chrome-data by default' do
|
20
|
+
expect(factory.user_data_dir.end_with?('test/chrome-data')).to be true
|
21
|
+
end
|
22
|
+
|
23
|
+
it "disk_cache_dir is test/cache-data by default" do
|
24
|
+
expect(factory.disk_cache_dir.end_with?('test/cache-data')).to be true
|
25
|
+
end
|
26
|
+
|
27
|
+
it "switches contain default values" do
|
28
|
+
switches = factory.switches
|
29
|
+
expect(switches).to include "--ignore-certificate-errors"
|
30
|
+
expect(switches).to include "--disable-popup-blocking"
|
31
|
+
expect(switches).to include "--disable-translate"
|
32
|
+
expect(switches).to include "--no-first-run"
|
33
|
+
|
34
|
+
log_level = "--log-level=#{factory.log_level}"
|
35
|
+
data_dir = "--user-data-dir=#{factory.user_data_dir}"
|
36
|
+
cache_dir = "--disk-cache-dir=#{factory.disk_cache_dir}"
|
37
|
+
expect(switches).to include log_level
|
38
|
+
expect(switches).to include data_dir
|
39
|
+
expect(switches).to include cache_dir
|
40
|
+
end
|
41
|
+
|
42
|
+
it "switches contain proxy string if configured" do
|
43
|
+
port = '123'
|
44
|
+
ENV['BROWSER_PROXY_PORT'] = port
|
45
|
+
proxy_string = "--proxy-server=socks://localhost:#{port}"
|
46
|
+
|
47
|
+
# Clear out the switches so they're regenerated.
|
48
|
+
factory.reset_switches
|
49
|
+
switches = factory.switches
|
50
|
+
|
51
|
+
expect(switches).to include proxy_string
|
52
|
+
|
53
|
+
# Clear out the switches so they're clean for other tests
|
54
|
+
factory.reset_switches
|
55
|
+
ENV['BROWSER_PROXY_PORT'] = nil
|
56
|
+
end
|
57
|
+
|
58
|
+
it "starts chrome and browses to google" do
|
59
|
+
browser = factory.build
|
60
|
+
browser.goto "https://google.com"
|
61
|
+
expect(browser.html).to include "searchform"
|
62
|
+
browser.close
|
63
|
+
end
|
64
|
+
|
65
|
+
it "starts firefox and browses to google" do
|
66
|
+
ENV['BROWSER'] = 'ff'
|
67
|
+
browser = factory.build
|
68
|
+
browser.goto "https://google.com"
|
69
|
+
expect(browser.html).to include "searchform"
|
70
|
+
browser.close
|
71
|
+
ENV['BROWSER'] = nil
|
72
|
+
end
|
73
|
+
|
74
|
+
if Ktutils::OS.windows?
|
75
|
+
it "starts IE and browses to google" do
|
76
|
+
ENV['BROWSER'] = 'ie'
|
77
|
+
browser = factory.build
|
78
|
+
browser.goto "https://google.com"
|
79
|
+
expect(browser.html).to include "searchform"
|
80
|
+
browser.close
|
81
|
+
ENV['BROWSER'] = nil
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
require 'browser_loader'
|
3
|
+
|
4
|
+
if ENV['coverage']
|
5
|
+
raise 'simplecov only works on Ruby 1.9' unless RUBY_VERSION =~ /^1\.9/
|
6
|
+
|
7
|
+
require 'simplecov'
|
8
|
+
SimpleCov.start { add_filter "spec/" }
|
9
|
+
end
|
10
|
+
|
11
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
12
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
13
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
14
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
15
|
+
# files.
|
16
|
+
#
|
17
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
18
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
19
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
20
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
21
|
+
# a separate helper file that requires the additional dependencies and performs
|
22
|
+
# the additional setup, and require it from the spec files that actually need
|
23
|
+
# it.
|
24
|
+
#
|
25
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
26
|
+
# users commonly want.
|
27
|
+
#
|
28
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
29
|
+
RSpec.configure do |config|
|
30
|
+
# rspec-expectations config goes here. You can use an alternate
|
31
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
32
|
+
# assertions if you prefer.
|
33
|
+
config.expect_with :rspec do |expectations|
|
34
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
35
|
+
# and `failure_message` of custom matchers include text for helper methods
|
36
|
+
# defined using `chain`, e.g.:
|
37
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
38
|
+
# # => "be bigger than 2 and smaller than 4"
|
39
|
+
# ...rather than:
|
40
|
+
# # => "be bigger than 2"
|
41
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
42
|
+
end
|
43
|
+
|
44
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
45
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
46
|
+
config.mock_with :rspec do |mocks|
|
47
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
48
|
+
# a real object. This is generally recommended, and will default to
|
49
|
+
# `true` in RSpec 4.
|
50
|
+
mocks.verify_partial_doubles = true
|
51
|
+
end
|
52
|
+
|
53
|
+
# The settings below are suggested to provide a good initial experience
|
54
|
+
# with RSpec, but feel free to customize to your heart's content.
|
55
|
+
# These two settings work together to allow you to limit a spec run
|
56
|
+
# to individual examples or groups you care about by tagging them with
|
57
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
58
|
+
# get run.
|
59
|
+
config.filter_run :focus
|
60
|
+
config.run_all_when_everything_filtered = true
|
61
|
+
|
62
|
+
# Allows RSpec to persist some state between runs in order to support
|
63
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
64
|
+
# you configure your source control system to ignore this file.
|
65
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
66
|
+
|
67
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
68
|
+
# recommended. For more details, see:
|
69
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
70
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
71
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
72
|
+
#config.disable_monkey_patching!
|
73
|
+
|
74
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
75
|
+
# be too noisy due to issues in dependencies.
|
76
|
+
config.warnings = false
|
77
|
+
|
78
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
79
|
+
# file, and it's useful to allow more verbose output when running an
|
80
|
+
# individual spec file.
|
81
|
+
if config.files_to_run.one?
|
82
|
+
# Use the documentation formatter for detailed output,
|
83
|
+
# unless a formatter has already been configured
|
84
|
+
# (e.g. via a command-line flag).
|
85
|
+
config.default_formatter = 'doc'
|
86
|
+
end
|
87
|
+
|
88
|
+
# Print the 10 slowest examples and example groups at the
|
89
|
+
# end of the spec run, to help surface which specs are running
|
90
|
+
# particularly slow.
|
91
|
+
config.profile_examples = 10
|
92
|
+
|
93
|
+
# Run specs in random order to surface order dependencies. If you find an
|
94
|
+
# order dependency and want to debug it, you can fix the order by providing
|
95
|
+
# the seed, which is printed after each run.
|
96
|
+
# --seed 1234
|
97
|
+
config.order = :random
|
98
|
+
|
99
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
100
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
101
|
+
# test failures related to randomization by passing the same `--seed` value
|
102
|
+
# as the one that triggered the failure.
|
103
|
+
Kernel.srand config.seed
|
104
|
+
end
|
105
|
+
|
106
|
+
|
metadata
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: browser_loader
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jeff McAffee
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry-byebug
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: watir-webdriver
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: ktutils
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Watir-webdriver based browser loader class providing additional chromium
|
112
|
+
configuration options.
|
113
|
+
email:
|
114
|
+
- jeff@ktechsystems.com
|
115
|
+
executables: []
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".gitignore"
|
120
|
+
- ".rspec"
|
121
|
+
- Gemfile
|
122
|
+
- LICENSE.txt
|
123
|
+
- README.md
|
124
|
+
- Rakefile
|
125
|
+
- browser_loader.gemspec
|
126
|
+
- lib/browser_loader.rb
|
127
|
+
- lib/browser_loader/factory.rb
|
128
|
+
- lib/browser_loader/version.rb
|
129
|
+
- spec/browser_loader/factory_spec.rb
|
130
|
+
- spec/browser_loader_spec.rb
|
131
|
+
- spec/spec_helper.rb
|
132
|
+
homepage: https://github.com/jmcaffee/browser_loader
|
133
|
+
licenses:
|
134
|
+
- MIT
|
135
|
+
metadata: {}
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options: []
|
138
|
+
require_paths:
|
139
|
+
- lib
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
requirements: []
|
151
|
+
rubyforge_project:
|
152
|
+
rubygems_version: 2.3.0
|
153
|
+
signing_key:
|
154
|
+
specification_version: 4
|
155
|
+
summary: Watir-webdriver based browser loader class.
|
156
|
+
test_files:
|
157
|
+
- spec/browser_loader/factory_spec.rb
|
158
|
+
- spec/browser_loader_spec.rb
|
159
|
+
- spec/spec_helper.rb
|
160
|
+
has_rdoc:
|