lapis_lazuli 1.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lapis_lazuli.gemspec +2 -0
- data/lib/lapis_lazuli/browser.rb +87 -19
- data/lib/lapis_lazuli/browser/wait.rb +9 -2
- data/lib/lapis_lazuli/generators/cucumber/template/config/config.yml +3 -1
- data/lib/lapis_lazuli/generators/cucumber/template/config/devices.yml +43 -0
- data/lib/lapis_lazuli/generators/cucumber/template/features/support/env.rb +8 -16
- data/lib/lapis_lazuli/version.rb +1 -1
- data/lib/lapis_lazuli/world/config.rb +33 -21
- data/test/config/config.yml +1 -0
- data/test/config/cucumber.yml +0 -1
- data/test/config/devices.yml +43 -0
- data/test/features/bindings.feature +43 -0
- data/test/features/step_definitions/interaction_steps.rb +37 -0
- data/test/features/step_definitions/validation_steps.rb +21 -1
- data/test/features/support/env.rb +8 -0
- metadata +35 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a15abf383ad8fc113b64f6ec8ead73fb7e59f37e
|
4
|
+
data.tar.gz: aba6ba53323e5930a3d8bc34797fd033ce0f56f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e64992dbcfa112b9e4deaa1f320e033ae16523e96ecd57ea2975f4646ffa663c2ba2614b3e60e41e6fbe2adc6f386a918e749ee135b4396123cb1f48a59afe1
|
7
|
+
data.tar.gz: 07f565653d8fefc1a0801216bc60afdddde03d3387724a3e8a9e9472a4e95bd0b25f8e2695d8f7e88e5e387c7a0ec69ee8b6ecbd3d162b55c0902ee8641ffefd
|
data/.gitignore
CHANGED
data/lapis_lazuli.gemspec
CHANGED
@@ -40,6 +40,8 @@ Gem::Specification.new do |spec|
|
|
40
40
|
spec.add_dependency "multi_xml", "~> 0.6"
|
41
41
|
spec.add_dependency "teelogger", "~> 0.5"
|
42
42
|
spec.add_dependency "minitest", "~> 5.10"
|
43
|
+
spec.add_dependency "thor", "~> 0.19" # Used in the cucumber project generator
|
44
|
+
spec.add_dependency "facets", "~> 3.1" # Used in the cucumber project generator
|
43
45
|
|
44
46
|
# webdriver specifics
|
45
47
|
spec.add_dependency "selenium-webdriver", "~> 3"
|
data/lib/lapis_lazuli/browser.rb
CHANGED
@@ -130,10 +130,10 @@ module LapisLazuli
|
|
130
130
|
|
131
131
|
##
|
132
132
|
# Close and create a new browser
|
133
|
-
def restart
|
133
|
+
def restart(*args)
|
134
134
|
world.log.debug "Restarting browser"
|
135
|
-
|
136
|
-
self.start
|
135
|
+
self.close
|
136
|
+
self.start(*args)
|
137
137
|
end
|
138
138
|
|
139
139
|
##
|
@@ -214,15 +214,9 @@ module LapisLazuli
|
|
214
214
|
if @@browsers.length != 0 and @@world.env_or_config("close_browser_after") != "never"
|
215
215
|
# Notify user
|
216
216
|
@@world.log.debug("Closing all browsers")
|
217
|
-
|
218
217
|
# Close each browser
|
219
218
|
@@browsers.each do |b|
|
220
|
-
|
221
|
-
b.close reason, false
|
222
|
-
rescue Exception => err
|
223
|
-
# Provide some details
|
224
|
-
@@world.log.debug("Failed to close the browser, probably chrome: #{err.to_s}")
|
225
|
-
end
|
219
|
+
b.close reason, true
|
226
220
|
end
|
227
221
|
|
228
222
|
# Make sure the array is cleared
|
@@ -233,25 +227,48 @@ module LapisLazuli
|
|
233
227
|
private
|
234
228
|
##
|
235
229
|
# The main browser window for testing
|
236
|
-
def init(browser_wanted=
|
237
|
-
# Store the optional data so on restart of the browser it still has the
|
238
|
-
|
239
|
-
|
240
|
-
|
230
|
+
def init(browser_wanted=nil, optional_data=nil)
|
231
|
+
# Store the optional data so on restart of the browser it still has the correct configuration
|
232
|
+
if optional_data.nil? and @@cached_browser_options.has_key?(:optional_data) and (browser_wanted.nil? or browser_wanted == @@cached_browser_options[:browser])
|
233
|
+
optional_data = @@cached_browser_options[:optional_data].dup
|
234
|
+
if !@@cached_browser_options[:optional_data][:profile].nil?
|
235
|
+
# A selenium profile needs to be duplicated separately, else it doesn't get a new ID.
|
236
|
+
optional_data[:profile] = @@cached_browser_options[:optional_data][:profile].dup
|
237
|
+
end
|
241
238
|
elsif optional_data.nil?
|
242
239
|
optional_data = {}
|
243
240
|
end
|
244
241
|
|
245
242
|
# Do the same caching stuff for the browser
|
246
|
-
if
|
243
|
+
if browser_wanted.nil? and @@cached_browser_options.has_key?(:browser)
|
247
244
|
browser_wanted = @@cached_browser_options[:browser]
|
248
245
|
end
|
249
246
|
|
247
|
+
# Set the default device if the optional data does not contain a specific device
|
248
|
+
if optional_data[:device].nil?
|
249
|
+
# Check if there is a cached value of a previously used
|
250
|
+
if @@cached_browser_options.has_key?(:device)
|
251
|
+
optional_data[:device] = @@cached_browser_options[:device]
|
252
|
+
# Check if the ENV['DEVICE'] variable is set
|
253
|
+
elsif !world.env_or_config('DEVICE').nil?
|
254
|
+
optional_data[:device] = world.env_or_config('DEVICE')
|
255
|
+
# Else grab the default set device
|
256
|
+
elsif !world.env_or_config('default_device').nil?
|
257
|
+
optional_data[:device] = world.env_or_config('default_device')
|
258
|
+
else
|
259
|
+
warn 'No default device, nor a selected device was set. Browser default settings will be loaded. More info: http://testautomation.info/Lapis_Lazuli:Device_Simulation'
|
260
|
+
end
|
261
|
+
end
|
250
262
|
|
251
|
-
if
|
263
|
+
# cache all the settings if this is the first time opening the browser.
|
264
|
+
if !@@cached_browser_options.has_key? :browser and !@@cached_browser_options.has_key? :optional_data
|
252
265
|
@@cached_browser_options[:browser] = browser_wanted
|
253
266
|
# Duplicate the data as Webdriver modifies it
|
254
267
|
@@cached_browser_options[:optional_data] = optional_data.dup
|
268
|
+
if !@@cached_browser_options[:optional_data][:profile].nil?
|
269
|
+
# A selenium profile needs to be duplicated separately, else it doesn't get a new ID.
|
270
|
+
@@cached_browser_options[:optional_data][:profile] = optional_data[:profile].dup
|
271
|
+
end
|
255
272
|
end
|
256
273
|
|
257
274
|
@browser_wanted = browser_wanted
|
@@ -264,6 +281,24 @@ module LapisLazuli
|
|
264
281
|
# Create a new browser depending on settings
|
265
282
|
# Always cached the supplied arguments
|
266
283
|
def create_driver(browser_wanted=nil, optional_data=nil)
|
284
|
+
# Remove device information from optional_data and create a separate variable for it
|
285
|
+
device = optional_data[:device]
|
286
|
+
optional_data.delete :device
|
287
|
+
|
288
|
+
# If device is set, load it from the devices.yml config
|
289
|
+
if !device.nil?
|
290
|
+
begin
|
291
|
+
world.add_config_from_file('./config/devices.yml')
|
292
|
+
rescue
|
293
|
+
raise '`./config/devices.yml` was not found. See http://testautomation.info/Lapis_Lazuli:Device_Simulation for more information'
|
294
|
+
end
|
295
|
+
if world.has_config? "devices.#{device}"
|
296
|
+
device_configuration = world.config "devices.#{device}"
|
297
|
+
else
|
298
|
+
raise "Requested device `#{device}` was not found in the configuration. See http://testautomation.info/Lapis_Lazuli:Device_Simulation for more information"
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
267
302
|
# Run-time dependency.
|
268
303
|
begin
|
269
304
|
require 'selenium-webdriver'
|
@@ -280,7 +315,6 @@ module LapisLazuli
|
|
280
315
|
# Select the correct browser
|
281
316
|
case browser_wanted.to_s.downcase
|
282
317
|
when 'chrome'
|
283
|
-
# Check Platform running script
|
284
318
|
b = :chrome
|
285
319
|
when 'safari'
|
286
320
|
b = :safari
|
@@ -303,6 +337,37 @@ module LapisLazuli
|
|
303
337
|
b = :firefox
|
304
338
|
end
|
305
339
|
|
340
|
+
# Overwrite user-agent if a device simulation is set and it contains a user-agent
|
341
|
+
if !device_configuration.nil? and !device_configuration['user-agent'].nil?
|
342
|
+
case b
|
343
|
+
when :firefox
|
344
|
+
# Create a firefox profile if it does not exist yet
|
345
|
+
if optional_data[:profile].nil?
|
346
|
+
optional_data[:profile] = Selenium::WebDriver::Firefox::Profile.new
|
347
|
+
else
|
348
|
+
# If the profile already exists, we need to create a duplicate, so we don't overwrite any settings.
|
349
|
+
optional_data[:profile] = optional_data[:profile].dup
|
350
|
+
end
|
351
|
+
# Add the user agent to it if it has not been set yet
|
352
|
+
if optional_data[:profile].instance_variable_get(:@additional_prefs)['general.useragent.override'].nil?
|
353
|
+
optional_data[:profile]['general.useragent.override'] = device_configuration['user-agent']
|
354
|
+
else
|
355
|
+
world.log.debug "User-agent was already set in the :profile."
|
356
|
+
end
|
357
|
+
when :chrome
|
358
|
+
ua_string = "--user-agent=#{device_configuration['user-agent']}"
|
359
|
+
if optional_data[:switches].nil?
|
360
|
+
optional_data[:switches] = [ua_string]
|
361
|
+
elsif !optional_data[:switches].join(',').include? '--user-agent='
|
362
|
+
optional_data[:switches].push ua_string
|
363
|
+
else
|
364
|
+
world.log.debug "User-agent was already set in the :switches."
|
365
|
+
end
|
366
|
+
else
|
367
|
+
warn "#{device} user agent cannot be set for #{b.to_s}. Only Chrome & Firefox are supported."
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
306
371
|
args = [b]
|
307
372
|
@browser_name = b.to_s
|
308
373
|
if b == :remote
|
@@ -342,9 +407,12 @@ module LapisLazuli
|
|
342
407
|
args.push({:profile => profile})
|
343
408
|
end
|
344
409
|
end
|
345
|
-
|
346
410
|
begin
|
347
411
|
browser_instance = Watir::Browser.new(*args)
|
412
|
+
# Resize the browser if the device simulation requires it
|
413
|
+
if !device_configuration.nil? and !device_configuration['width'].nil? and !device_configuration['height'].nil?
|
414
|
+
browser_instance.window.resize_to(device_configuration['width'], device_configuration['height'])
|
415
|
+
end
|
348
416
|
rescue Selenium::WebDriver::Error::UnknownError => err
|
349
417
|
raise err
|
350
418
|
end
|
@@ -74,6 +74,7 @@ module BrowserModule
|
|
74
74
|
find_proc = lambda { |dummy|
|
75
75
|
res = false
|
76
76
|
err = nil
|
77
|
+
err_msg = []
|
77
78
|
retries.times do
|
78
79
|
begin
|
79
80
|
opts = Marshal.load(Marshal.dump(options))
|
@@ -90,14 +91,20 @@ module BrowserModule
|
|
90
91
|
end
|
91
92
|
break # don't need to retry
|
92
93
|
rescue Selenium::WebDriver::Error::StaleElementReferenceError => e
|
94
|
+
# Sometimes the element becomes stale right when we're trying to check its presence.
|
93
95
|
err = e
|
96
|
+
err_msg << e.message
|
97
|
+
rescue Watir::Exception::UnknownObjectException => e
|
98
|
+
# Sometimes watir returns an unknown object exception, this should be caught when it's a wait until loop.
|
99
|
+
err = e
|
100
|
+
err_msg << e.message
|
94
101
|
end
|
95
102
|
# Retry
|
96
103
|
end
|
97
104
|
|
98
105
|
# Raise the error if the retries didn't suffice
|
99
|
-
if not err.nil? and not res
|
100
|
-
raise err, "Tried #{retries} times, but got: #{
|
106
|
+
if not err.nil? and not res === false
|
107
|
+
raise err, "Tried #{retries} times, but got: \n#{err_msg.join("\n")}\n", err.backtrace
|
101
108
|
end
|
102
109
|
|
103
110
|
# Return the results!
|
@@ -9,9 +9,11 @@
|
|
9
9
|
################################################################################
|
10
10
|
# Set the global variables
|
11
11
|
default_env: production # defines the environment
|
12
|
+
default_device: desktop720 # See devices.yml for your options
|
13
|
+
close_browser_after: end # Can be `scenario`, `feature` or `end`
|
12
14
|
|
13
15
|
################################################################################
|
14
|
-
# List of error strings.
|
16
|
+
# List of error strings. `browser.html_error` will return an array of detected strings.
|
15
17
|
error_strings:
|
16
18
|
[
|
17
19
|
"Server Error",
|
@@ -0,0 +1,43 @@
|
|
1
|
+
################################################################################
|
2
|
+
# Copyright <%= config[:year] %> spriteCloud B.V. All rights reserved.
|
3
|
+
# Generated by LapisLazuli, version <%= config[:lapis_lazuli][:version] %>
|
4
|
+
# Author: "<%= config[:user] %>" <<%= config[:email] %>>
|
5
|
+
#
|
6
|
+
# Device file to add extra device simulation.
|
7
|
+
|
8
|
+
### USAGE ###
|
9
|
+
# Add new devices by adding a device name to simulation-devices
|
10
|
+
# Then add a width, height & user-agent field
|
11
|
+
# The used browser will start the simulation in that browser.
|
12
|
+
|
13
|
+
devices:
|
14
|
+
# Desktop dimensions
|
15
|
+
desktop1080:
|
16
|
+
width: 1920
|
17
|
+
height: 1080
|
18
|
+
desktop720:
|
19
|
+
width: 1280
|
20
|
+
height: 720
|
21
|
+
desktop:
|
22
|
+
width: 1360
|
23
|
+
height: 768
|
24
|
+
iphone5:
|
25
|
+
width: 640
|
26
|
+
height: 1136
|
27
|
+
user-agent: Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3
|
28
|
+
iphone3:
|
29
|
+
width: 320
|
30
|
+
height: 480
|
31
|
+
user-agent: Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16
|
32
|
+
ipad:
|
33
|
+
width: 768
|
34
|
+
height: 1024
|
35
|
+
user-agent: Mozilla/5.0 (iPad; CPU OS 10_2_1 like Mac OS X) AppleWebKit/602.4.6 (KHTML, like Gecko) Version/10.0 Mobile/14D27 Safari/602.1
|
36
|
+
galaxys2:
|
37
|
+
width: 480
|
38
|
+
height: 800
|
39
|
+
user-agent: Mozilla/5.0 (Linux; Android 4.1.2; GT-I9100 Build/JZO54K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.109 Mobile Safari/537.36
|
40
|
+
galaxys2landscape:
|
41
|
+
width: 800
|
42
|
+
height: 480
|
43
|
+
user-agent: Mozilla/5.0 (Linux; Android 4.1.2; GT-I9100 Build/JZO54K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.109 Mobile Safari/537.36
|
@@ -10,28 +10,20 @@ World(LapisLazuli)
|
|
10
10
|
|
11
11
|
# Do something when LapisLazuli is started (This is before the browser is opened)
|
12
12
|
LapisLazuli.Start do
|
13
|
-
|
14
|
-
# This code snippet prevents the security popup to appear in FF v>47.
|
15
|
-
# If BROWSER is NIL, Lapis Lazuli will default to Firefox
|
13
|
+
#If BROWSER is NIL, Lapis Lazuli will default to Firefox
|
16
14
|
if !ENV['BROWSER'] || ENV['BROWSER'] == 'firefox'
|
15
|
+
|
17
16
|
# Get Selenium to create a profile object
|
18
17
|
require 'selenium-webdriver'
|
19
18
|
profile = Selenium::WebDriver::Firefox::Profile.new
|
19
|
+
|
20
|
+
# These settings prevent a warning after authenticating via URL
|
21
|
+
# For example user:pass@https://website.com/
|
20
22
|
profile['network.http.phishy-userpass-length'] = 255
|
23
|
+
profile['network.http.use-cache'] = false
|
24
|
+
|
25
|
+
# Start the browser with these settings
|
21
26
|
browser :firefox, :profile => profile
|
22
|
-
end
|
23
|
-
end
|
24
27
|
|
25
|
-
# This function is called before every scenario.
|
26
|
-
Before do
|
27
|
-
# This can be very handy to make sure a browser has the same settings before a new scenario starts.
|
28
|
-
# For example, to enforce a certain browser window size
|
29
|
-
new_width = 1024
|
30
|
-
new_height = 768
|
31
|
-
current_size = browser.window.size
|
32
|
-
# Only change the browser size, if it is not already the correct size
|
33
|
-
unless current_size.width == new_width && current_size.height == new_height
|
34
|
-
log.info "Resizing browser to #{new_width}x#{new_height} (Was #{current_size.width}x#{current_size.height}"
|
35
|
-
browser.window.resize_to(new_width, new_height)
|
36
28
|
end
|
37
29
|
end
|
data/lib/lapis_lazuli/version.rb
CHANGED
@@ -136,16 +136,44 @@ module WorldModule
|
|
136
136
|
# - Environment doesn't exist in config
|
137
137
|
# - Default environment not set in config if no environment is set
|
138
138
|
def load_config_from_file(filename)
|
139
|
+
# Set the global @config variable
|
140
|
+
@config = get_config_from_file(filename)
|
141
|
+
|
142
|
+
# If we have an environment this config should have it
|
143
|
+
if not @env.nil? and not self.has_config?(@env)
|
144
|
+
raise "Environment `#{@env}` doesn't exist in config file"
|
145
|
+
end
|
146
|
+
|
147
|
+
# If we don't have one then load the default
|
148
|
+
if @env.nil? and self.has_config?("default_env")
|
149
|
+
tmp = self.config("default_env")
|
150
|
+
if self.has_config?(tmp)
|
151
|
+
@env = tmp
|
152
|
+
else
|
153
|
+
raise "Default environment not present in config file"
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
# Adds the possibility to merge multiple config files.
|
159
|
+
def add_config_from_file(filename)
|
160
|
+
# Add the data to the global config
|
161
|
+
@config.merge! get_config_from_file(filename)
|
162
|
+
end
|
163
|
+
|
164
|
+
# returns the data that's loaded from a config file.
|
165
|
+
# Supports YAML and JSON
|
166
|
+
def get_config_from_file(filename)
|
139
167
|
# Try to load the file from disk
|
140
168
|
begin
|
141
169
|
# Determine the extension
|
142
170
|
ext = File.extname(filename)
|
143
171
|
# Use the correct loader
|
144
172
|
if ext == ".yml"
|
145
|
-
|
173
|
+
data = YAML.load_file(filename)
|
146
174
|
elsif ext == ".json"
|
147
175
|
json = File.read(filename)
|
148
|
-
|
176
|
+
data = JSON.parse(json)
|
149
177
|
end
|
150
178
|
rescue RuntimeError => err
|
151
179
|
# Can't help you
|
@@ -153,29 +181,13 @@ module WorldModule
|
|
153
181
|
end
|
154
182
|
|
155
183
|
# Fix up empty files
|
156
|
-
if
|
184
|
+
if data.nil? or data == false
|
157
185
|
warn "Could not load configuration from '#{Config.config_file}'; it might be empty or malformed."
|
158
|
-
|
159
|
-
end
|
160
|
-
|
161
|
-
# If we have an environment this config should have it
|
162
|
-
if not @env.nil? and not self.has_config?(@env)
|
163
|
-
raise "Environment doesn't exist in config file"
|
164
|
-
end
|
165
|
-
|
166
|
-
# If we don't have one then load the default
|
167
|
-
if @env.nil? and self.has_config?("default_env")
|
168
|
-
tmp = self.config("default_env")
|
169
|
-
if self.has_config?(tmp)
|
170
|
-
@env = tmp
|
171
|
-
else
|
172
|
-
raise "Default environment not present in config file"
|
173
|
-
end
|
186
|
+
data = {}
|
174
187
|
end
|
188
|
+
return data
|
175
189
|
end
|
176
190
|
|
177
|
-
|
178
|
-
|
179
191
|
##
|
180
192
|
# Does the config have a variable?
|
181
193
|
# Uses config and catches any errors it raises
|
data/test/config/config.yml
CHANGED
@@ -9,6 +9,7 @@
|
|
9
9
|
################################################################################
|
10
10
|
# Set the global variables
|
11
11
|
default_env: production # defines the environment
|
12
|
+
default_device: desktop720 # set the default browser dimensions and/or user agent (See devices.yml)
|
12
13
|
screenshots_dir: screenshots # where to save the screenshots
|
13
14
|
step_pause_time: 1 # Waiting time in seconds defined after a step completes
|
14
15
|
make_screenshot_on_failed_scenario: true # make a screenshot after a scenario fails
|
data/test/config/cucumber.yml
CHANGED
@@ -0,0 +1,43 @@
|
|
1
|
+
################################################################################
|
2
|
+
# Copyright 2014 spriteCloud B.V. All rights reserved.
|
3
|
+
# Generated by LapisLazuli, version 0.0.1
|
4
|
+
# Author: "spriteCloud" <info@spritecloud.com>
|
5
|
+
#
|
6
|
+
# Device file to add extra device simulation.
|
7
|
+
|
8
|
+
### USAGE ###
|
9
|
+
# Add new devices by adding a device name to simulation-devices
|
10
|
+
# Then add a width, height & user-agent field
|
11
|
+
# The used browser will start the simulation in that browser.
|
12
|
+
|
13
|
+
devices:
|
14
|
+
# Desktop dimensions
|
15
|
+
desktop1080:
|
16
|
+
width: 1920
|
17
|
+
height: 1080
|
18
|
+
desktop720:
|
19
|
+
width: 1280
|
20
|
+
height: 720
|
21
|
+
desktop:
|
22
|
+
width: 1360
|
23
|
+
height: 768
|
24
|
+
iphone5:
|
25
|
+
width: 640
|
26
|
+
height: 1136
|
27
|
+
user-agent: Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3
|
28
|
+
iphone3:
|
29
|
+
width: 320
|
30
|
+
height: 480
|
31
|
+
user-agent: Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16
|
32
|
+
ipad:
|
33
|
+
width: 768
|
34
|
+
height: 1024
|
35
|
+
user-agent: Mozilla/5.0 (iPad; CPU OS 10_2_1 like Mac OS X) AppleWebKit/602.4.6 (KHTML, like Gecko) Version/10.0 Mobile/14D27 Safari/602.1
|
36
|
+
galaxys2:
|
37
|
+
width: 480
|
38
|
+
height: 800
|
39
|
+
user-agent: Mozilla/5.0 (Linux; Android 4.1.2; GT-I9100 Build/JZO54K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.109 Mobile Safari/537.36
|
40
|
+
galaxys2landscape:
|
41
|
+
width: 800
|
42
|
+
height: 480
|
43
|
+
user-agent: Mozilla/5.0 (Linux; Android 4.1.2; GT-I9100 Build/JZO54K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.109 Mobile Safari/537.36
|
@@ -0,0 +1,43 @@
|
|
1
|
+
@bindings @p
|
2
|
+
Feature: binding
|
3
|
+
When I want to test the Lapis Lazuli library
|
4
|
+
I want to run a webserver with some test files
|
5
|
+
And test if I can parse bindings when starting the browsers
|
6
|
+
|
7
|
+
@bindings_01
|
8
|
+
Scenario: Custom user-agent firefox
|
9
|
+
Given I use browser bindings "1"
|
10
|
+
And I navigate to URL "http://whatsmyua.com/"
|
11
|
+
Then within 2 seconds I should see "CUSTOM-USER-AGENT"
|
12
|
+
And I close the browser
|
13
|
+
|
14
|
+
@bindings_02
|
15
|
+
Scenario: Custom user-agent chrome
|
16
|
+
Given I use browser bindings "2"
|
17
|
+
And I navigate to URL "http://whatsmyua.com/"
|
18
|
+
Then within 2 seconds I should see "CUSTOM-CHROME-USER-AGENT"
|
19
|
+
And I close the browser
|
20
|
+
|
21
|
+
# Known issue with maximizing the window using the chrome option --start-maximized
|
22
|
+
@bindings_03 @maximize_issue
|
23
|
+
Scenario: Custom user-agent chrome
|
24
|
+
Given I use browser bindings "3"
|
25
|
+
And I navigate to URL "http://whatsmyua.com/"
|
26
|
+
Then the browser window size should be "full screen"
|
27
|
+
And I close the browser
|
28
|
+
|
29
|
+
@bindings_04
|
30
|
+
Scenario: Using a pre-defined device (iphone5)
|
31
|
+
Given I restart the browser to device setting "iphone5"
|
32
|
+
When I navigate to URL "http://whatsmyua.com"
|
33
|
+
Then within 2 seconds I should see "Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3"
|
34
|
+
And the browser window size should be "640x1136"
|
35
|
+
And I close the browser
|
36
|
+
|
37
|
+
@bindings_05
|
38
|
+
Scenario: Using a pre-defined device (desktop1080)
|
39
|
+
Given I restart the browser to device setting "desktop1080"
|
40
|
+
When I navigate to URL "http://whatsmyua.com"
|
41
|
+
Then within 2 seconds I should see "Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3" disappear
|
42
|
+
And the browser window size should be "1920x1080"
|
43
|
+
And I close the browser
|
@@ -17,6 +17,10 @@ Given(/^I navigate to the (.*) test page$/) do |page|
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
+
Given(/^I navigate to URL "(.*)"$/) do |url|
|
21
|
+
browser.goto url
|
22
|
+
end
|
23
|
+
|
20
24
|
Given(/I click (the|a) (first|last|random|[0-9]+[a-z]+) (.*)$/) do |arg1, index, type|
|
21
25
|
# Convert the type text to a symbol
|
22
26
|
type = type.downcase.gsub(" ", "_")
|
@@ -62,6 +66,10 @@ Given(/^I close the browser named "(.*?)"$/) do |name|
|
|
62
66
|
end
|
63
67
|
end
|
64
68
|
|
69
|
+
Given(/^I close the browser$/) do
|
70
|
+
browser.close
|
71
|
+
end
|
72
|
+
|
65
73
|
When(/^I find "(.*?)" and name it "(.*?)"$/) do |id, name|
|
66
74
|
element = browser.find(id)
|
67
75
|
scenario.storage.set(name, element)
|
@@ -178,3 +186,32 @@ Then(/^the report should include (.*?) and (.*?) in the correct place$/) do |dat
|
|
178
186
|
assert ([[data1], [data2]] == values), "Stored values: #{values}, expected [[#{data1}], [#{data2}]]"
|
179
187
|
end
|
180
188
|
end
|
189
|
+
|
190
|
+
Given(/^I use browser bindings "(.*?)"$/) do |bindings|
|
191
|
+
require 'selenium-webdriver'
|
192
|
+
case bindings
|
193
|
+
when '1'
|
194
|
+
profile = Selenium::WebDriver::Firefox::Profile.new
|
195
|
+
profile['general.useragent.override'] = "CUSTOM-USER-AGENT"
|
196
|
+
browser.restart :firefox, profile: profile
|
197
|
+
when '2'
|
198
|
+
switches = %w[--user-agent=CUSTOM-CHROME-USER-AGENT]
|
199
|
+
browser.restart :chrome, :switches => switches
|
200
|
+
when '3'
|
201
|
+
caps = Selenium::WebDriver::Remote::Capabilities.chrome(
|
202
|
+
"chromeOptions" => {
|
203
|
+
"args" => [
|
204
|
+
'--start-maximized'
|
205
|
+
]
|
206
|
+
}
|
207
|
+
)
|
208
|
+
browser.restart :chrome, desired_capabilities: caps
|
209
|
+
browser.window.maximize
|
210
|
+
else
|
211
|
+
error "Requested binding setup does not exist. Requested #{bindings}"
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
Given(/^I restart the browser to device setting "(.*?)"$/) do |device|
|
216
|
+
browser.restart :chrome, device: device
|
217
|
+
end
|
@@ -99,7 +99,7 @@ Then(/^within (\d+) seconds I should see "([^"]+?)"( disappear)?$/) do |timeout,
|
|
99
99
|
:timeout => timeout,
|
100
100
|
:text => text,
|
101
101
|
:condition => condition,
|
102
|
-
:groups => ["wait"]
|
102
|
+
:groups => ["wait #{condition.to_s}"]
|
103
103
|
)
|
104
104
|
end
|
105
105
|
|
@@ -399,4 +399,24 @@ Then(/^that element should not container text "(.*?)"$/) do |text|
|
|
399
399
|
if element.text.include? text
|
400
400
|
raise 'Element did contain the text it should not contain.'
|
401
401
|
end
|
402
|
+
end
|
403
|
+
|
404
|
+
Then(/^the browser window size should be "([^"]*)"$/) do |expected_size|
|
405
|
+
case expected_size
|
406
|
+
when 'full screen'
|
407
|
+
current_size = browser.window.size
|
408
|
+
browser.window.maximize
|
409
|
+
when /^(\d+)x(\d+)$/
|
410
|
+
width = $1
|
411
|
+
height = $2
|
412
|
+
current_size = browser.window.size
|
413
|
+
browser.window.resize_to(width, height)
|
414
|
+
else
|
415
|
+
error "Unkown variable #{expected_size} in 'the browser window size should be ...'"
|
416
|
+
end
|
417
|
+
difference_width = browser.window.size.width - current_size.width
|
418
|
+
difference_height = browser.window.size.height - current_size.height
|
419
|
+
unless difference_width > -30 and difference_width < 30 and difference_height > -30 and difference_height < 30
|
420
|
+
error "Window size changed after resizing it to `#{expected_size}`. before: #{current_size.width}x#{current_size.height}. After: #{browser.window.size.width}x#{browser.window.size.height}"
|
421
|
+
end
|
402
422
|
end
|
@@ -16,6 +16,14 @@ World(LapisLazuli, TestModule)
|
|
16
16
|
|
17
17
|
LapisLazuli::WorldModule::Browser.browser_module(TestModule)
|
18
18
|
|
19
|
+
LapisLazuli.Start do
|
20
|
+
# Print gem information
|
21
|
+
print "---- VERSION INFO ----\n"
|
22
|
+
print "Lapis Lazuli: #{Gem.loaded_specs['lapis_lazuli'].version}\n"
|
23
|
+
print "Selenium webdriver: #{Gem.loaded_specs['selenium-webdriver'].version}\n"
|
24
|
+
print "Watir: #{Gem.loaded_specs['watir'].version}\n"
|
25
|
+
print "---- VERSION INFO ----\n\n"
|
26
|
+
end
|
19
27
|
|
20
28
|
# Transition function from old codebase to new
|
21
29
|
load 'server/start.rb'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lapis_lazuli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Onno Steenbergen
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2017-
|
14
|
+
date: 2017-04-06 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -125,6 +125,34 @@ dependencies:
|
|
125
125
|
- - "~>"
|
126
126
|
- !ruby/object:Gem::Version
|
127
127
|
version: '5.10'
|
128
|
+
- !ruby/object:Gem::Dependency
|
129
|
+
name: thor
|
130
|
+
requirement: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - "~>"
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0.19'
|
135
|
+
type: :runtime
|
136
|
+
prerelease: false
|
137
|
+
version_requirements: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - "~>"
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0.19'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: facets
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - "~>"
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '3.1'
|
149
|
+
type: :runtime
|
150
|
+
prerelease: false
|
151
|
+
version_requirements: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - "~>"
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '3.1'
|
128
156
|
- !ruby/object:Gem::Dependency
|
129
157
|
name: selenium-webdriver
|
130
158
|
requirement: !ruby/object:Gem::Requirement
|
@@ -206,6 +234,7 @@ files:
|
|
206
234
|
- lib/lapis_lazuli/generators/cucumber/template/README.md
|
207
235
|
- lib/lapis_lazuli/generators/cucumber/template/config/config.yml
|
208
236
|
- lib/lapis_lazuli/generators/cucumber/template/config/cucumber.yml
|
237
|
+
- lib/lapis_lazuli/generators/cucumber/template/config/devices.yml
|
209
238
|
- lib/lapis_lazuli/generators/cucumber/template/features/account.feature
|
210
239
|
- lib/lapis_lazuli/generators/cucumber/template/features/example.feature
|
211
240
|
- lib/lapis_lazuli/generators/cucumber/template/features/step_definitions/interaction_steps.rb
|
@@ -237,7 +266,9 @@ files:
|
|
237
266
|
- test/README.md
|
238
267
|
- test/config/config.yml
|
239
268
|
- test/config/cucumber.yml
|
269
|
+
- test/config/devices.yml
|
240
270
|
- test/features/annotation.feature
|
271
|
+
- test/features/bindings.feature
|
241
272
|
- test/features/browser.feature
|
242
273
|
- test/features/button.feature
|
243
274
|
- test/features/click.feature
|
@@ -292,7 +323,9 @@ test_files:
|
|
292
323
|
- test/README.md
|
293
324
|
- test/config/config.yml
|
294
325
|
- test/config/cucumber.yml
|
326
|
+
- test/config/devices.yml
|
295
327
|
- test/features/annotation.feature
|
328
|
+
- test/features/bindings.feature
|
296
329
|
- test/features/browser.feature
|
297
330
|
- test/features/button.feature
|
298
331
|
- test/features/click.feature
|