lapis_lazuli 2.1.4 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +13 -0
- data/README.md +4 -1
- data/lapis_lazuli.gemspec +16 -15
- data/lib/lapis_lazuli.rb +0 -2
- data/lib/lapis_lazuli/api.rb +1 -1
- data/lib/lapis_lazuli/argparse.rb +1 -1
- data/lib/lapis_lazuli/ast.rb +2 -141
- data/lib/lapis_lazuli/browser.rb +50 -160
- data/lib/lapis_lazuli/browser/screenshots.rb +3 -4
- data/lib/lapis_lazuli/cli.rb +1 -1
- data/lib/lapis_lazuli/cucumber.rb +1 -1
- data/lib/lapis_lazuli/generators/cucumber.rb +1 -1
- data/lib/lapis_lazuli/generators/cucumber/template/config/config.yml +1 -1
- data/lib/lapis_lazuli/generators/cucumber/template/features/1_basic.feature +14 -7
- data/lib/lapis_lazuli/generators/cucumber/template/features/helpers/authentication_helper.rb +3 -3
- data/lib/lapis_lazuli/generators/cucumber/template/features/helpers/navigation_helper.rb +1 -1
- data/lib/lapis_lazuli/generators/cucumber/template/features/helpers/registration_helper.rb +16 -7
- data/lib/lapis_lazuli/generators/cucumber/template/features/step_definitions/basic_steps.rb +7 -2
- data/lib/lapis_lazuli/generic/xpath.rb +1 -1
- data/lib/lapis_lazuli/options.rb +1 -1
- data/lib/lapis_lazuli/placeholders.rb +1 -1
- data/lib/lapis_lazuli/proxy.rb +1 -1
- data/lib/lapis_lazuli/runtime.rb +1 -1
- data/lib/lapis_lazuli/scenario.rb +1 -1
- data/lib/lapis_lazuli/storage.rb +1 -1
- data/lib/lapis_lazuli/version.rb +2 -2
- data/lib/lapis_lazuli/versions.rb +1 -1
- data/lib/lapis_lazuli/world/logging.rb +34 -33
- data/test/Gemfile +1 -3
- data/test/features/bindings.feature +6 -6
- data/test/features/browser.feature +10 -10
- data/test/features/button.feature +4 -3
- data/test/features/step_definitions/interaction_steps.rb +13 -24
- data/test/features/step_definitions/multifind_steps.rb +3 -3
- data/test/features/step_definitions/validation_steps.rb +2 -2
- data/test/features/support/env.rb +0 -1
- data/test/server/start.rb +1 -1
- metadata +55 -57
- data/lib/lapis_lazuli/browser/remote.rb +0 -140
- data/lib/lapis_lazuli/world/annotate.rb +0 -47
- data/test/features/annotation.feature +0 -23
@@ -6,6 +6,9 @@
|
|
6
6
|
# All rights reserved.
|
7
7
|
#
|
8
8
|
|
9
|
+
require 'cucumber/core/test/case'
|
10
|
+
require 'cucumber/core/test/step'
|
11
|
+
|
9
12
|
module LapisLazuli
|
10
13
|
module BrowserModule
|
11
14
|
|
@@ -82,10 +85,6 @@ module LapisLazuli
|
|
82
85
|
end
|
83
86
|
world.log.debug "Screenshot saved: #{fileloc}"
|
84
87
|
|
85
|
-
# Try to store the screenshot name
|
86
|
-
if world.respond_to? :annotate
|
87
|
-
world.annotate :screenshot => fileloc
|
88
|
-
end
|
89
88
|
rescue RuntimeError => e
|
90
89
|
world.log.debug "Failed to save screenshot to '#{fileloc}'. Error message #{e.message}"
|
91
90
|
end
|
data/lib/lapis_lazuli/cli.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# LapisLazuli
|
3
3
|
# https://github.com/spriteCloud/lapis-lazuli
|
4
4
|
#
|
5
|
-
# Copyright (c) 2013-
|
5
|
+
# Copyright (c) 2013-2019 spriteCloud B.V. and other LapisLazuli contributors.
|
6
6
|
# All rights reserved.
|
7
7
|
#
|
8
8
|
require 'thor'
|
@@ -11,13 +11,20 @@ I want to run and adjust the tests below
|
|
11
11
|
Then text "Open Source" should display somewhere on the page
|
12
12
|
|
13
13
|
@basic_02
|
14
|
-
Scenario: example02 -
|
15
|
-
Given the user navigates to "
|
16
|
-
When the user
|
17
|
-
Then text "
|
14
|
+
Scenario: example02 - scrolling down
|
15
|
+
Given the user navigates to "home"
|
16
|
+
When the user scrolls down
|
17
|
+
Then text "Project-based services are typically short-term" should display somewhere on the page
|
18
18
|
|
19
19
|
@basic_03
|
20
|
-
Scenario
|
20
|
+
Scenario: example03 - Going to a search result
|
21
|
+
Given the user navigates to "https://www.spritecloud.com/?s=lapis+lazuli"
|
22
|
+
When the user scrolls down
|
23
|
+
And the user clicks on link "/announcing-lapislazuli/"
|
24
|
+
Then text "A few days later you are working" should display somewhere on the page
|
25
|
+
|
26
|
+
@basic_04
|
27
|
+
Scenario Outline: example04 - checking multiple pages for the logo
|
21
28
|
Given the user navigates to "<page>"
|
22
29
|
When the user clicks on the spritecloud logo
|
23
30
|
Then the user should be on page "home"
|
@@ -35,8 +42,8 @@ I want to run and adjust the tests below
|
|
35
42
|
# or, if you want to test it on a specific environment:
|
36
43
|
# bundle exec cucumber -p production -p debug -t @basic_04
|
37
44
|
# Good luck fixing the problems!
|
38
|
-
@
|
39
|
-
Scenario:
|
45
|
+
@basic_05 @dev
|
46
|
+
Scenario: example_05 - confirming there is a no results page
|
40
47
|
Given the user navigates to "blog"
|
41
48
|
When the user searches for "no_results_expected"
|
42
49
|
Then the text "Nothing Found" should display on the blog page
|
data/lib/lapis_lazuli/generators/cucumber/template/features/helpers/authentication_helper.rb
CHANGED
@@ -104,8 +104,8 @@ module Auth
|
|
104
104
|
# If user=nil, we expect that there already is user data loaded in a previous step.
|
105
105
|
User.load_user_data(user) unless user.nil?
|
106
106
|
|
107
|
-
Auth.username_field.to_subtype.set(User.get('username'))
|
108
|
-
Auth.password_field.to_subtype.set(User.get('password'))
|
107
|
+
Auth.username_field.to_subtype.to_subtype.set(User.get('username'))
|
108
|
+
Auth.password_field.to_subtype.to_subtype.set(User.get('password'))
|
109
109
|
Auth.login_button.click
|
110
110
|
|
111
111
|
unless Auth.is_logged_in? user
|
@@ -114,7 +114,7 @@ module Auth
|
|
114
114
|
error "Failed to log in user #{user}"
|
115
115
|
else
|
116
116
|
alert.flash
|
117
|
-
error "Found error while logging in #{user}: `#{alert.
|
117
|
+
error "Found error while logging in #{user}: `#{alert.html}`"
|
118
118
|
end
|
119
119
|
end
|
120
120
|
end
|
@@ -8,7 +8,7 @@ module Register
|
|
8
8
|
# @formatter:off
|
9
9
|
def form; browser.wait(:like => [:form, :id, 'form-register']); end
|
10
10
|
def open_register_button; browser.find(:like => [:button, :id, 'button-register']); end
|
11
|
-
def username_field; browser.
|
11
|
+
def username_field; browser.wait(:element => {:name => 'username'}, :context => Register.form); end
|
12
12
|
def password_field; browser.find(:element => {:name => 'password'}, :context => Register.form); end
|
13
13
|
def experience_field; browser.find(:like => [:select, :id, "register-experience"], :context => form); end
|
14
14
|
def biography_field; browser.find(:like => [:textarea, :id, 'register-bio']); end
|
@@ -52,16 +52,25 @@ module Register
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def fill_form
|
55
|
-
|
56
|
-
|
55
|
+
#the setter goes too fast sometimes not finishing the username, this will re-set the username when it does
|
56
|
+
browser.wait_until(timeout: 10, message: 'False did not become true withing 10 seconds') {
|
57
|
+
Register.username_field.to_subtype.set(User.get('username'))
|
58
|
+
Register.username_field.value == User.get('username')
|
59
|
+
}
|
60
|
+
Register.username_field.to_subtype.set(User.get('username'))
|
61
|
+
Register.password_field.to_subtype.set(User.get('password'))
|
57
62
|
Register.gender_radio(User.get('gender')).click
|
58
63
|
Register.select_experiences(User.get('experience').split(','))
|
59
|
-
Register.biography_field.set(User.get('biography'))
|
60
|
-
Register.policy_checkbox.set((User.get('complete_all').to_i == 1))
|
64
|
+
Register.biography_field.to_subtype.set(User.get('biography'))
|
65
|
+
Register.policy_checkbox.to_subtype.set((User.get('complete_all').to_i == 1))
|
61
66
|
end
|
62
67
|
|
63
68
|
def submit_form
|
64
69
|
Register.submit_button.click
|
70
|
+
browser.wait(
|
71
|
+
:like => [:div, :class, 'modal-backdrop fade in'],
|
72
|
+
:condition => :while
|
73
|
+
)
|
65
74
|
end
|
66
75
|
|
67
76
|
def register_user
|
@@ -73,8 +82,8 @@ module Register
|
|
73
82
|
alert = browser.wait(like: [:div, :class, 'alert'], timeout: 2, throw: false)
|
74
83
|
if alert.nil?
|
75
84
|
return false, 'No message was displayed after registering'
|
76
|
-
elsif !alert.
|
77
|
-
return false, "An error message did display, but didn't contain the expected text: `#{alert.
|
85
|
+
elsif !alert.html.include? User.get('username')
|
86
|
+
return false, "An error message did display, but didn't contain the expected text: `#{alert.html}`"
|
78
87
|
end
|
79
88
|
return true, 'Successfully found the success message'
|
80
89
|
end
|
@@ -25,6 +25,10 @@ Given(/^the user searches for "(.*?)"$/) do |query|
|
|
25
25
|
searchbox.send_keys(:enter)
|
26
26
|
end
|
27
27
|
|
28
|
+
When(/^the user scrolls down$/) do
|
29
|
+
browser.driver.execute_script("window.scrollBy(0,400)")
|
30
|
+
end
|
31
|
+
|
28
32
|
Then(/^text "([^"]*)" should display somewhere on the page$/) do |string|
|
29
33
|
# Search for the text on the page
|
30
34
|
browser.wait(:xpath => "//*[contains(text(),\"#{string}\")]")
|
@@ -32,6 +36,7 @@ end
|
|
32
36
|
|
33
37
|
When(/^the user clicks on link "(.*?)"$/) do |url|
|
34
38
|
# Search for the element that includes the expected text
|
39
|
+
|
35
40
|
browser.wait(
|
36
41
|
:like => {
|
37
42
|
:element => :a,
|
@@ -44,8 +49,8 @@ end
|
|
44
49
|
When(/^the user clicks on the spritecloud logo$/) do
|
45
50
|
# Search for the logo
|
46
51
|
logo = browser.find(
|
47
|
-
:
|
48
|
-
:
|
52
|
+
a: {class: ['logo']},
|
53
|
+
message: 'Unable to find the logo on this page.'
|
49
54
|
)
|
50
55
|
# And click the logo
|
51
56
|
logo.click
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# LapisLazuli
|
3
3
|
# https://github.com/spriteCloud/lapis-lazuli
|
4
4
|
#
|
5
|
-
# Copyright (c) 2013-
|
5
|
+
# Copyright (c) 2013-2019 spriteCloud B.V. and other LapisLazuli contributors.
|
6
6
|
# All rights reserved.
|
7
7
|
#
|
8
8
|
module LapisLazuli
|
data/lib/lapis_lazuli/options.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# LapisLazuli
|
3
3
|
# https://github.com/spriteCloud/lapis-lazuli
|
4
4
|
#
|
5
|
-
# Copyright (c) 2013-
|
5
|
+
# Copyright (c) 2013-2019 spriteCloud B.V. and other LapisLazuli contributors.
|
6
6
|
# All rights reserved.
|
7
7
|
#
|
8
8
|
module LapisLazuli
|
data/lib/lapis_lazuli/proxy.rb
CHANGED
data/lib/lapis_lazuli/runtime.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# LapisLazuli
|
3
3
|
# https://github.com/spriteCloud/lapis-lazuli
|
4
4
|
#
|
5
|
-
# Copyright (c) 2013-
|
5
|
+
# Copyright (c) 2013-2019 spriteCloud B.V. and other LapisLazuli contributors.
|
6
6
|
# All rights reserved.
|
7
7
|
#
|
8
8
|
require 'singleton'
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# LapisLazuli
|
3
3
|
# https://github.com/spriteCloud/lapis-lazuli
|
4
4
|
#
|
5
|
-
# Copyright (c) 2013-
|
5
|
+
# Copyright (c) 2013-2019 spriteCloud B.V. and other LapisLazuli contributors.
|
6
6
|
# All rights reserved.
|
7
7
|
#
|
8
8
|
require "securerandom"
|
data/lib/lapis_lazuli/storage.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# LapisLazuli
|
3
3
|
# https://github.com/spriteCloud/lapis-lazuli
|
4
4
|
#
|
5
|
-
# Copyright (c) 2013-
|
5
|
+
# Copyright (c) 2013-2019 spriteCloud B.V. and other LapisLazuli contributors.
|
6
6
|
# All rights reserved.
|
7
7
|
#
|
8
8
|
module LapisLazuli
|
data/lib/lapis_lazuli/version.rb
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
# LapisLazuli
|
3
3
|
# https://github.com/spriteCloud/lapis-lazuli
|
4
4
|
#
|
5
|
-
# Copyright (c) 2013-
|
5
|
+
# Copyright (c) 2013-2019 spriteCloud B.V. and other LapisLazuli contributors.
|
6
6
|
# All rights reserved.
|
7
7
|
#
|
8
8
|
module LapisLazuli
|
9
|
-
VERSION = "
|
9
|
+
VERSION = "3.0.2"
|
10
10
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# LapisLazuli
|
3
3
|
# https://github.com/spriteCloud/lapis-lazuli
|
4
4
|
#
|
5
|
-
# Copyright (c) 2013-
|
5
|
+
# Copyright (c) 2013-2019 spriteCloud B.V. and other LapisLazuli contributors.
|
6
6
|
# All rights reserved.
|
7
7
|
#
|
8
8
|
require 'lapis_lazuli/api'
|
@@ -13,41 +13,42 @@ require "lapis_lazuli/runtime"
|
|
13
13
|
require "lapis_lazuli/world/config"
|
14
14
|
|
15
15
|
module LapisLazuli
|
16
|
-
module WorldModule
|
17
|
-
##
|
18
|
-
# Module for easy logging
|
19
|
-
#
|
20
|
-
# Manages the following:
|
21
|
-
# @log - TeeLogger instances
|
22
|
-
module Logging
|
23
|
-
include LapisLazuli::WorldModule::Config
|
24
|
-
|
16
|
+
module WorldModule
|
25
17
|
##
|
26
|
-
#
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
Dir.mkdir dir
|
33
|
-
rescue SystemCallError => ex
|
34
|
-
# Swallow this error; it occurs (amongst other situations) when the
|
35
|
-
# directory exists. Checking for an existing directory beforehand is
|
36
|
-
# not concurrency safe.
|
37
|
-
end
|
18
|
+
# Module for easy logging
|
19
|
+
#
|
20
|
+
# Manages the following:
|
21
|
+
# @log - TeeLogger instances
|
22
|
+
module Logging
|
23
|
+
include LapisLazuli::WorldModule::Config
|
38
24
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
if
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
25
|
+
##
|
26
|
+
# Log "singleton"
|
27
|
+
def log(msg = nil)
|
28
|
+
super(msg) if msg
|
29
|
+
return Runtime.instance.set_if(self, :logger) do
|
30
|
+
# Make log directory
|
31
|
+
dir = env_or_config('log_dir')
|
32
|
+
begin
|
33
|
+
Dir.mkdir dir
|
34
|
+
rescue SystemCallError => ex
|
35
|
+
# Swallow this error; it occurs (amongst other situations) when the
|
36
|
+
# directory exists. Checking for an existing directory beforehand is
|
37
|
+
# not concurrency safe.
|
38
|
+
end
|
47
39
|
|
48
|
-
|
40
|
+
# Start the logger with the config filename
|
41
|
+
log_file = "#{dir}#{File::SEPARATOR}#{File.basename(Config.config_files[0], ".*")}.log"
|
42
|
+
# Or a filename from the environment
|
43
|
+
if has_env_or_config?("log_file")
|
44
|
+
log_file = env_or_config("log_file")
|
45
|
+
end
|
46
|
+
l = TeeLogger::TeeLogger.new(log_file)
|
47
|
+
l.level = env_or_config("log_level")
|
48
|
+
|
49
|
+
l
|
50
|
+
end
|
49
51
|
end
|
50
|
-
end
|
51
|
-
end # module
|
52
|
-
end # module WorldModule
|
52
|
+
end # module Logging
|
53
|
+
end # module WorldModule
|
53
54
|
end # module LapisLazuli
|
data/test/Gemfile
CHANGED
@@ -3,11 +3,9 @@ source 'http://rubygems.org'
|
|
3
3
|
# Build and include the LL gem from the parent directory
|
4
4
|
gem "lapis_lazuli", path: './../'
|
5
5
|
|
6
|
-
# Gem used to import results to calliope.pro
|
7
|
-
gem 'cucumber-calliope_importer'
|
8
6
|
|
9
7
|
# Project specific gems
|
10
|
-
gem '
|
8
|
+
gem 'cucumber', '~> 6'
|
11
9
|
gem 'xml-simple'
|
12
10
|
gem 'mechanize'
|
13
11
|
gem 'simplecov'
|
@@ -7,14 +7,14 @@ And test if I can parse bindings when starting the browsers
|
|
7
7
|
@bindings_01
|
8
8
|
Scenario: bindings_01 - Custom user-agent firefox
|
9
9
|
Given I use browser bindings "1"
|
10
|
-
And I navigate to URL "
|
10
|
+
And I navigate to URL "https://www.whatsmyua.info/"
|
11
11
|
Then within 2 seconds I should see "CUSTOM-USER-AGENT"
|
12
12
|
And I close the browser
|
13
13
|
|
14
14
|
@bindings_02
|
15
15
|
Scenario: bindings_02 - Custom user-agent chrome
|
16
16
|
Given I use browser bindings "2"
|
17
|
-
And I navigate to URL "
|
17
|
+
And I navigate to URL "https://www.whatsmyua.info/"
|
18
18
|
Then within 2 seconds I should see "CUSTOM-CHROME-USER-AGENT"
|
19
19
|
And I close the browser
|
20
20
|
|
@@ -22,22 +22,22 @@ And test if I can parse bindings when starting the browsers
|
|
22
22
|
@bindings_03 @maximize_issue
|
23
23
|
Scenario: bindings_03 - Custom user-agent chrome
|
24
24
|
Given I use browser bindings "3"
|
25
|
-
And I navigate to URL "
|
25
|
+
And I navigate to URL "https://www.whatsmyua.info/"
|
26
26
|
Then the browser window size should be "full screen"
|
27
27
|
And I close the browser
|
28
28
|
|
29
29
|
@bindings_04
|
30
30
|
Scenario: bindings_04 - Using a pre-defined device (iphone5)
|
31
31
|
Given I restart the browser to device setting "iphone5"
|
32
|
-
When I navigate to URL "
|
33
|
-
Then within 2 seconds I should see "
|
32
|
+
When I navigate to URL "https://www.whatsmyua.info/"
|
33
|
+
Then within 2 seconds I should see "AppleWebKit"
|
34
34
|
And the browser window size should be "640x1136"
|
35
35
|
And I close the browser
|
36
36
|
|
37
37
|
@bindings_05
|
38
38
|
Scenario: bindings_05 - Using a pre-defined device (desktop1080)
|
39
39
|
Given I restart the browser to device setting "desktop1080"
|
40
|
-
When I navigate to URL "
|
40
|
+
When I navigate to URL "https://www.whatsmyua.info/"
|
41
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
42
|
And the browser window size should be "1920x1080"
|
43
43
|
And I close the browser
|
@@ -1,10 +1,10 @@
|
|
1
|
-
|
2
|
-
Feature: Browsers
|
3
|
-
When I want to test the Lapis Lazuli library
|
4
|
-
And test if I can start a browser with options
|
5
|
-
|
6
|
-
|
7
|
-
Scenario: browser_01 - Firefox with proxy
|
8
|
-
When I create a firefox browser named "test" with proxy to "localhost:8008"
|
9
|
-
Then the firefox browser named "test" has a profile
|
10
|
-
Then I close the browser named "test"
|
1
|
+
#@browser @p @ignore_on_remote
|
2
|
+
#Feature: Browsers
|
3
|
+
#When I want to test the Lapis Lazuli library
|
4
|
+
#And test if I can start a browser with options
|
5
|
+
#
|
6
|
+
#@browser_01
|
7
|
+
#Scenario: browser_01 - Firefox with proxy
|
8
|
+
# When I create a firefox browser named "test" with proxy to "localhost:8008"
|
9
|
+
# Then the firefox browser named "test" has a profile
|
10
|
+
# Then I close the browser named "test"
|