ruby_raider 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/generators/automation/automation_examples_generator.rb +6 -1
- data/lib/generators/automation/automation_generator.rb +14 -5
- data/lib/generators/automation/templates/account_page.tt +5 -0
- data/lib/generators/automation/templates/login_page.tt +5 -5
- data/lib/generators/automation/templates/partials/selenium_account.tt +17 -0
- data/lib/generators/automation/templates/partials/watir_account.tt +15 -0
- data/lib/generators/common_generator.rb +3 -3
- data/lib/generators/cucumber/cucumber_generator.rb +1 -1
- data/lib/generators/cucumber/templates/env.tt +7 -7
- data/lib/generators/cucumber/templates/feature.tt +1 -1
- data/lib/generators/cucumber/templates/partials/driver_world.tt +10 -6
- data/lib/generators/cucumber/templates/partials/selenium_env.tt +44 -0
- data/lib/generators/cucumber/templates/partials/watir_env.tt +32 -1
- data/lib/generators/cucumber/templates/partials/watir_world.tt +3 -2
- data/lib/generators/cucumber/templates/partials/web_steps.tt +8 -3
- data/lib/generators/cucumber/templates/steps.tt +3 -3
- data/lib/generators/cucumber/templates/world.tt +5 -5
- data/lib/generators/generator.rb +25 -4
- data/lib/generators/helper_generator.rb +12 -6
- data/lib/generators/menu_generator.rb +2 -2
- data/lib/generators/rspec/rspec_examples_generator.rb +2 -2
- data/lib/generators/rspec/templates/spec.tt +13 -28
- data/lib/generators/templates/common/gemfile.tt +3 -4
- data/lib/generators/templates/common/read_me.tt +1 -1
- data/lib/generators/templates/helpers/allure_helper.tt +5 -4
- data/lib/generators/templates/helpers/driver_helper.tt +4 -4
- data/lib/generators/templates/helpers/partials/driver_and_options.tt +1 -1
- data/lib/generators/templates/helpers/partials/screenshot.tt +3 -6
- data/lib/generators/templates/helpers/raider_helper.tt +0 -2
- data/lib/generators/templates/helpers/spec_helper.tt +2 -2
- data/lib/generators/templates/helpers/visual_spec_helper.tt +5 -9
- data/ruby_raider.gemspec +1 -2
- data/spec/helpers_generator_spec.rb +0 -10
- metadata +7 -18
- data/lib/generators/cucumber/templates/partials/selenium_appium_env.tt +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8710aab0ae8636ca5829f35c5a5d5076002b02caf918284b161816eeda0b6dca
|
4
|
+
data.tar.gz: b69e53e10c6bfa0a8132e8975b8ce54cd412bfde5b88d465d244d9241005b4c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bc42e8cc009974f4793e47ed2a9eba9afd651fe1309f91a247d587a63618d3302e3ee68bcaaf71378446edd30f5e6b35582ee38c55407e34973f0a1e8fa5538
|
7
|
+
data.tar.gz: b189d100a0a4c47dcb6be4d58e7ff17e47ffb91c031a820db0d9f84f0a5368a3974d3cb2f846c0286cc6e6405a5cad851f3e44c79f637b41fbfc6b0bfbbaf993
|
data/README.md
CHANGED
@@ -54,7 +54,7 @@ Ruby Raider is a generator and scaffolding gem to make UI test automation easier
|
|
54
54
|
|
55
55
|
* Generating a visual testing framework with Rspec, Applitools and Selenium
|
56
56
|
|
57
|
-
* Generating a visual testing framework with
|
57
|
+
* Generating a visual testing framework with Cucumber, Applitools and Selenium
|
58
58
|
|
59
59
|
***In order to run the Appium tests, download the example [app](https://github.com/saucelabs/my-demo-app-rn).***
|
60
60
|
|
@@ -4,7 +4,7 @@ require_relative '../generator'
|
|
4
4
|
|
5
5
|
class AutomationExamplesGenerator < Generator
|
6
6
|
def generate_example_files
|
7
|
-
if
|
7
|
+
if mobile?
|
8
8
|
generate_home_page
|
9
9
|
generate_pdp_page
|
10
10
|
else
|
@@ -12,6 +12,7 @@ class AutomationExamplesGenerator < Generator
|
|
12
12
|
generate_model_data
|
13
13
|
generate_header_component
|
14
14
|
generate_login_page
|
15
|
+
generate_account_page
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
@@ -21,6 +22,10 @@ class AutomationExamplesGenerator < Generator
|
|
21
22
|
template('login_page.tt', "#{name}/page_objects/pages/login_page.rb")
|
22
23
|
end
|
23
24
|
|
25
|
+
def generate_account_page
|
26
|
+
template('account_page.tt', "#{name}/page_objects/pages/account_page.rb")
|
27
|
+
end
|
28
|
+
|
24
29
|
def generate_home_page
|
25
30
|
template('home_page.tt', "#{name}/page_objects/pages/home_page.rb")
|
26
31
|
end
|
@@ -3,24 +3,33 @@
|
|
3
3
|
require_relative '../generator'
|
4
4
|
|
5
5
|
class AutomationGenerator < Generator
|
6
|
+
def generate_automation_files
|
7
|
+
if mobile?
|
8
|
+
generate_appium_settings
|
9
|
+
else
|
10
|
+
generate_abstract_component
|
11
|
+
generate_visual_options
|
12
|
+
end
|
13
|
+
|
14
|
+
generate_abstract_page
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
6
19
|
def generate_abstract_page
|
7
20
|
template('abstract_page.tt', "#{name}/page_objects/abstract/abstract_page.rb")
|
8
21
|
end
|
9
22
|
|
10
23
|
def generate_abstract_component
|
11
|
-
return if mobile_platform?
|
12
|
-
|
13
24
|
template('abstract_component.tt', "#{name}/page_objects/abstract/abstract_component.rb")
|
14
25
|
end
|
15
26
|
|
16
27
|
def generate_appium_settings
|
17
|
-
return unless mobile_platform?
|
18
|
-
|
19
28
|
template('appium_caps.tt', "#{name}/config/capabilities.yml")
|
20
29
|
end
|
21
30
|
|
22
31
|
def generate_visual_options
|
23
|
-
return unless
|
32
|
+
return unless visual?
|
24
33
|
|
25
34
|
template('visual_options.tt', "#{name}/config/options.yml")
|
26
35
|
end
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<%- if automation == 'selenium' -%>
|
2
|
+
<%=- ERB.new(File.read(File.expand_path('./partials/selenium_account.tt', __dir__)), trim_mode: '-').result(binding) -%>
|
3
|
+
<%- elsif automation == 'watir' -%>
|
4
|
+
<%=- ERB.new(File.read(File.expand_path('./partials/watir_account.tt', __dir__)), trim_mode: '-').result(binding) -%>
|
5
|
+
<%- end -%>
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
<%- if automation == 'selenium' -%>
|
2
|
+
<%=- ERB.new(File.read(File.expand_path('./partials/selenium_login.tt', __dir__)), trim_mode: '-').result(binding) -%>
|
3
|
+
<%- elsif automation == 'watir' -%>
|
4
|
+
<%=- ERB.new(File.read(File.expand_path('./partials/watir_login.tt', __dir__)), trim_mode: '-').result(binding) -%>
|
5
|
+
<%- end -%>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../abstract/abstract_page'
|
4
|
+
require_relative '../components/header_component'
|
5
|
+
|
6
|
+
class AccountPage < AbstractPage
|
7
|
+
|
8
|
+
def url(_page)
|
9
|
+
'index.php?rt=account/account'
|
10
|
+
end
|
11
|
+
|
12
|
+
# Components
|
13
|
+
|
14
|
+
def header
|
15
|
+
HeaderComponent.new(driver.find_element(class: 'menu_text'))
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require_relative '../abstract/abstract_page'
|
2
|
+
require_relative '../components/header_component'
|
3
|
+
|
4
|
+
class AccountPage < AbstractPage
|
5
|
+
|
6
|
+
def url(_page)
|
7
|
+
'index.php?rt=account/account'
|
8
|
+
end
|
9
|
+
|
10
|
+
# Components
|
11
|
+
|
12
|
+
def header
|
13
|
+
HeaderComponent.new(browser.element(class: 'menu_text'))
|
14
|
+
end
|
15
|
+
end
|
@@ -8,7 +8,7 @@ class CommonGenerator < Generator
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def generate_config_file
|
11
|
-
return if
|
11
|
+
return if mobile?
|
12
12
|
|
13
13
|
template('common/config.tt', "#{name}/config/config.yml")
|
14
14
|
end
|
@@ -30,10 +30,10 @@ class CommonGenerator < Generator
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def create_allure_folder
|
33
|
-
empty_directory "#{name}/allure-results"
|
33
|
+
empty_directory "#{name}/allure-results"
|
34
34
|
end
|
35
35
|
|
36
36
|
def create_screenshots_folder
|
37
|
-
empty_directory "#{name}/allure-results/screenshots"
|
37
|
+
empty_directory "#{name}/allure-results/screenshots"
|
38
38
|
end
|
39
39
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
|
1
|
+
<%- case automation
|
2
2
|
when 'selenium' -%>
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
<%=- ERB.new(File.read(File.expand_path('./partials/selenium_env.tt', __dir__)), trim_mode: '-').result(binding) -%>
|
4
|
+
<%- when 'watir' -%>
|
5
|
+
<%=- ERB.new(File.read(File.expand_path('./partials/watir_env.tt', __dir__)), trim_mode: '-').result(binding) -%>
|
6
|
+
<%- else -%>
|
7
|
+
<%=- ERB.new(File.read(File.expand_path('./partials/appium_env.tt', __dir__)), trim_mode: '-').result(binding) -%>
|
8
|
+
<%- end -%>
|
@@ -1,7 +1,11 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require_relative '../../helpers/driver_helper'
|
2
|
+
<%- if visual_automation -%>
|
3
|
+
require_relative '../../helpers/visual_helper'
|
4
|
+
<%- end -%>
|
5
|
+
<%- if automation == 'selenium' -%>
|
6
|
+
require_relative '../../models/user_factory'
|
3
7
|
|
4
|
-
World(DriverHelper
|
5
|
-
|
6
|
-
World(DriverHelper)
|
7
|
-
|
8
|
+
World(Raider::DriverHelper<%- if visual_automation -%>, Raider::VisualHelper<%- end -%>)
|
9
|
+
<%- else -%>
|
10
|
+
World(Raider::DriverHelper)
|
11
|
+
<%- end -%>
|
@@ -0,0 +1,44 @@
|
|
1
|
+
<%- if visual_automation -%>
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative '../../helpers/driver_helper'
|
5
|
+
require_relative '../../helpers/visual_helper'
|
6
|
+
|
7
|
+
include Raider::DriverHelper
|
8
|
+
include Raider::VisualHelper
|
9
|
+
|
10
|
+
Before do
|
11
|
+
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
|
12
|
+
@grid_runner = create_grid_runner
|
13
|
+
@eyes = create_eyes(@grid_runner)
|
14
|
+
configure_eyes @eyes
|
15
|
+
@driver = @eyes.open(driver: new_driver)
|
16
|
+
end
|
17
|
+
|
18
|
+
After do |scenario|
|
19
|
+
driver.save_screenshot("allure-results/screenshots/#{scenario.name}.png")
|
20
|
+
Raider::AllureHelper.add_screenshot(scenario.name)
|
21
|
+
@eyes.close
|
22
|
+
@driver.quit
|
23
|
+
@eyes.abort_async
|
24
|
+
results = @grid_runner.get_all_test_results
|
25
|
+
puts results
|
26
|
+
end
|
27
|
+
|
28
|
+
<%- else -%>
|
29
|
+
# frozen_string_literal: true
|
30
|
+
|
31
|
+
require_relative '../../helpers/driver_helper'
|
32
|
+
|
33
|
+
include Raider::DriverHelper
|
34
|
+
|
35
|
+
Before do
|
36
|
+
new_driver
|
37
|
+
end
|
38
|
+
|
39
|
+
After do |scenario|
|
40
|
+
driver.save_screenshot("allure-results/screenshots/#{scenario.name}.png")
|
41
|
+
Raider::AllureHelper.add_screenshot(scenario.name)
|
42
|
+
driver.quit
|
43
|
+
end
|
44
|
+
<%- end -%>
|
@@ -1,3 +1,33 @@
|
|
1
|
+
<%- if visual_automation -%>
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative '../../helpers/browser_helper'
|
5
|
+
require_relative '../../helpers/visual_helper'
|
6
|
+
|
7
|
+
include Raider::BrowserHelper
|
8
|
+
include Raider::VisualHelper
|
9
|
+
|
10
|
+
Before do
|
11
|
+
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
|
12
|
+
@grid_runner = create_grid_runner
|
13
|
+
@eyes = create_eyes(@grid_runner)
|
14
|
+
configure_eyes @eyes
|
15
|
+
@browser = @eyes.open(driver: new_browser.driver)
|
16
|
+
end
|
17
|
+
|
18
|
+
After do |scenario|
|
19
|
+
browser.screenshot.save("allure-results/screenshots/#{scenario.name}.png")
|
20
|
+
Raider::AllureHelper.add_screenshot(scenario.name)
|
21
|
+
@eyes.close
|
22
|
+
@browser.quit
|
23
|
+
@eyes.abort_async
|
24
|
+
results = @grid_runner.get_all_test_results
|
25
|
+
puts results
|
26
|
+
end
|
27
|
+
|
28
|
+
<%- else -%>
|
29
|
+
# frozen_string_literal: true
|
30
|
+
|
1
31
|
require_relative '../../helpers/browser_helper'
|
2
32
|
|
3
33
|
include Raider::BrowserHelper
|
@@ -10,4 +40,5 @@ After do |scenario|
|
|
10
40
|
browser.screenshot.save("allure-results/screenshots/#{scenario.name}.png")
|
11
41
|
Raider::AllureHelper.add_screenshot(scenario.name)
|
12
42
|
browser.quit
|
13
|
-
end
|
43
|
+
end
|
44
|
+
<%- end -%>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative '../../page_objects/pages/account_page'
|
3
4
|
require_relative '../../page_objects/pages/login_page'
|
4
|
-
require_relative '../../models/user_factory'
|
5
5
|
|
6
6
|
Given("I'm a {user} on the login page") do |user|
|
7
7
|
@user = user
|
@@ -13,6 +13,11 @@ When('I login with my credentials') do
|
|
13
13
|
@login_page.login(@user['username'], @user['password'])
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
Then("I'm logged in") do
|
17
|
+
account_page = AccountPage.new(<% if automation == 'watir' %>browser<% else %>driver<% end %>)
|
18
|
+
<%- if visual_automation == true -%>
|
19
|
+
check_page account_page
|
20
|
+
<%- else -%>
|
21
|
+
expect(account_page.header.customer_name).to eq "Welcome back #{@user['name']}"
|
22
|
+
<%- end -%>
|
18
23
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<% if %w[selenium watir].include? automation -%>
|
2
|
-
<%= ERB.new(File.read(File.expand_path('./partials/web_steps.tt', __dir__))).result(binding).strip! -%>
|
2
|
+
<%= ERB.new(File.read(File.expand_path('./partials/web_steps.tt', __dir__)), trim_mode: '-').result(binding).strip! -%>
|
3
3
|
<% else -%>
|
4
|
-
<%= ERB.new(File.read(File.expand_path('./partials/mobile_steps.tt', __dir__))).result(binding).strip! -%>
|
5
|
-
<% end -%>
|
4
|
+
<%= ERB.new(File.read(File.expand_path('./partials/mobile_steps.tt', __dir__)), trim_mode: '-').result(binding).strip! -%>
|
5
|
+
<% end -%>
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
<%- if automation == 'watir' -%>
|
2
|
+
<%=- ERB.new(File.read(File.expand_path('./partials/watir_world.tt', __dir__)), trim_mode: '-').result(binding).strip! -%>
|
3
|
+
<%- else -%>
|
4
|
+
<%=- ERB.new(File.read(File.expand_path('./partials/driver_world.tt', __dir__)), trim_mode: '-').result(binding).strip! -%>
|
5
|
+
<%- end -%>
|
data/lib/generators/generator.rb
CHANGED
@@ -19,15 +19,36 @@ class Generator < Thor::Group
|
|
19
19
|
initializer.first
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
23
|
-
|
22
|
+
def cucumber?
|
23
|
+
args.include?('cucumber')
|
24
|
+
end
|
25
|
+
|
26
|
+
# The framework is cross platform when it supports Android and iOS
|
27
|
+
def cross_platform?
|
28
|
+
args.include?('cross_platform')
|
24
29
|
end
|
25
30
|
|
26
|
-
def
|
31
|
+
def mobile?
|
27
32
|
(args & %w[android ios cross_platform]).count.positive?
|
28
33
|
end
|
29
34
|
|
30
|
-
def
|
35
|
+
def rspec?
|
36
|
+
args.include?('rspec')
|
37
|
+
end
|
38
|
+
|
39
|
+
def selenium?
|
40
|
+
args.include?('selenium')
|
41
|
+
end
|
42
|
+
|
43
|
+
def visual?
|
44
|
+
initializer.first.last
|
45
|
+
end
|
46
|
+
|
47
|
+
def watir?
|
48
|
+
args.include?('watir')
|
49
|
+
end
|
50
|
+
|
51
|
+
def web?
|
31
52
|
args.include?(%w[selenium watir])
|
32
53
|
end
|
33
54
|
|
@@ -8,12 +8,12 @@ class HelpersGenerator < Generator
|
|
8
8
|
generate_browser_helper
|
9
9
|
generate_driver_helper
|
10
10
|
generate_appium_helper
|
11
|
+
generate_allure_helper
|
11
12
|
|
12
|
-
if
|
13
|
+
if visual?
|
13
14
|
generate_visual_helper
|
14
15
|
generate_visual_spec_helper
|
15
16
|
else
|
16
|
-
generate_allure_helper
|
17
17
|
generate_spec_helper
|
18
18
|
end
|
19
19
|
end
|
@@ -29,21 +29,25 @@ class HelpersGenerator < Generator
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def generate_browser_helper
|
32
|
-
|
32
|
+
return if selenium?
|
33
|
+
|
34
|
+
template('helpers/browser_helper.tt', "#{name}/helpers/browser_helper.rb")
|
33
35
|
end
|
34
36
|
|
35
37
|
def generate_spec_helper
|
36
|
-
|
38
|
+
return if cucumber?
|
39
|
+
|
40
|
+
template('helpers/spec_helper.tt', "#{name}/helpers/spec_helper.rb")
|
37
41
|
end
|
38
42
|
|
39
43
|
def generate_driver_helper
|
40
|
-
return if
|
44
|
+
return if watir?
|
41
45
|
|
42
46
|
template('helpers/driver_helper.tt', "#{name}/helpers/driver_helper.rb")
|
43
47
|
end
|
44
48
|
|
45
49
|
def generate_appium_helper
|
46
|
-
return unless
|
50
|
+
return unless cross_platform?
|
47
51
|
|
48
52
|
template('helpers/appium_helper.tt', "#{name}/helpers/appium_helper.rb")
|
49
53
|
end
|
@@ -53,6 +57,8 @@ class HelpersGenerator < Generator
|
|
53
57
|
end
|
54
58
|
|
55
59
|
def generate_visual_spec_helper
|
60
|
+
return if cucumber?
|
61
|
+
|
56
62
|
template('helpers/visual_spec_helper.tt', "#{name}/helpers/spec_helper.rb")
|
57
63
|
end
|
58
64
|
end
|
@@ -80,14 +80,14 @@ class MenuGenerator
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def framework_with_examples(framework, automation_type)
|
83
|
-
visual_automation = choose_visual_automation if %w[selenium
|
83
|
+
visual_automation = choose_visual_automation if %w[selenium].include?(automation_type)
|
84
84
|
options = create_framework_options(automation: automation_type, framework: framework.downcase, visual_automation: visual_automation, with_examples: true)
|
85
85
|
set_up_framework(options)
|
86
86
|
prompt.say("You have chosen to use #{framework} with #{automation_type}")
|
87
87
|
end
|
88
88
|
|
89
89
|
def framework_without_examples(framework, automation_type)
|
90
|
-
visual_automation = choose_visual_automation if %w[selenium
|
90
|
+
visual_automation = choose_visual_automation if %w[selenium].include?(automation_type)
|
91
91
|
options = create_framework_options(automation: automation_type, framework: framework.downcase, visual_automation: visual_automation, with_examples: false)
|
92
92
|
set_up_framework(options)
|
93
93
|
prompt.say("You have chosen to use #{framework} with #{automation_type}")
|
@@ -4,13 +4,13 @@ require_relative '../generator'
|
|
4
4
|
|
5
5
|
class RspecExamplesGenerator < Generator
|
6
6
|
def generate_login_spec
|
7
|
-
return if
|
7
|
+
return if mobile?
|
8
8
|
|
9
9
|
template('spec.tt', "#{name}/spec/login_page_spec.rb")
|
10
10
|
end
|
11
11
|
|
12
12
|
def generate_pdp_spec
|
13
|
-
return unless
|
13
|
+
return unless mobile?
|
14
14
|
|
15
15
|
template('spec.tt', "#{name}/spec/pdp_page_spec.rb")
|
16
16
|
end
|
@@ -1,40 +1,17 @@
|
|
1
|
-
|
1
|
+
<%- if %w[selenium watir].include? automation -%>
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require_relative 'base_spec'
|
5
5
|
require_relative '../models/model_factory'
|
6
|
+
require_relative '../page_objects/pages/account_page'
|
6
7
|
require_relative '../page_objects/pages/login_page'
|
7
8
|
|
8
9
|
describe 'Login' do
|
9
|
-
subject(:header) {
|
10
|
-
|
11
|
-
let(:user) { ModelFactory.for('users')['registered user'] }
|
12
|
-
let(:login_page) { LoginPage.new(<% if automation == 'watir' -%>browser<% else -%>driver<% end -%>) }
|
13
|
-
|
14
|
-
before do
|
15
|
-
login_page.visit
|
16
|
-
end
|
17
|
-
|
18
|
-
context 'with right credentials' do
|
19
|
-
let(:password) { user['password'] }
|
20
|
-
|
21
|
-
it 'cannot see unexpected changes on the login page' do
|
22
|
-
check_page login_page
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
<%- elsif %w[selenium watir].include? automation -%>
|
27
|
-
# frozen_string_literal: true
|
28
|
-
|
29
|
-
require_relative 'base_spec'
|
30
|
-
require_relative '../models/model_factory'
|
31
|
-
require_relative '../page_objects/pages/login_page'
|
32
|
-
|
33
|
-
describe 'Login' do
|
34
|
-
subject(:header) { login_page.header.customer_name }
|
10
|
+
subject(:header) { account_page.header.customer_name }
|
35
11
|
|
36
12
|
let(:user) { ModelFactory.for('users')['registered user'] }
|
37
13
|
let(:login_page) { LoginPage.new(<% if automation == 'watir' -%>browser<% else -%>driver<% end -%>) }
|
14
|
+
let(:account_page) { AccountPage.new(<% if automation == 'watir' -%>browser<% else -%>driver<% end -%>) }
|
38
15
|
|
39
16
|
before do
|
40
17
|
login_page.visit
|
@@ -45,15 +22,23 @@ describe 'Login' do
|
|
45
22
|
let(:password) { user['password'] }
|
46
23
|
|
47
24
|
it 'can successfully log in' do
|
25
|
+
<%- if visual_automation == true -%>
|
26
|
+
check_page account_page
|
27
|
+
<%- else -%>
|
48
28
|
expect(header).to eq "Welcome back #{user['name']}"
|
29
|
+
<%- end -%>
|
49
30
|
end
|
50
31
|
end
|
51
32
|
|
52
33
|
context 'with wrong credentials' do
|
53
34
|
let(:password) { 'wrongPassword' }
|
54
35
|
|
55
|
-
it 'cannot
|
36
|
+
it 'cannot log in' do
|
37
|
+
<%- if visual_automation == true -%>
|
38
|
+
check_page login_page
|
39
|
+
<%- else -%>
|
56
40
|
expect(header).to be_empty
|
41
|
+
<%- end -%>
|
57
42
|
end
|
58
43
|
end
|
59
44
|
end
|
@@ -1,12 +1,11 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
gem 'activesupport'
|
4
|
-
<% unless visual_automation -%>
|
5
|
-
gem 'allure-rspec'
|
6
|
-
gem 'allure-ruby-commons'
|
7
|
-
<% end -%>
|
8
4
|
<% if framework == 'cucumber' -%>
|
9
5
|
gem 'allure-cucumber'
|
6
|
+
<% else -%>
|
7
|
+
gem 'allure-rspec'
|
8
|
+
gem 'allure-ruby-commons'
|
10
9
|
<% end -%>
|
11
10
|
<% if visual_automation -%>
|
12
11
|
gem 'eyes_selenium', '~> 4.6', '>= 4.6.1'
|
@@ -50,7 +50,7 @@ Ruby Raider is a generator and scaffolding gem to make UI test automation easier
|
|
50
50
|
|
51
51
|
* Generating a visual testing framework with Rspec, Applitools and Selenium
|
52
52
|
|
53
|
-
* Generating a visual testing framework with
|
53
|
+
* Generating a visual testing framework with Cucumber, Applitools and Selenium
|
54
54
|
|
55
55
|
***In order to run the Appium tests, download the example [app](https://github.com/saucelabs/my-demo-app-rn).***
|
56
56
|
|
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
<%=- ERB.new(File.read(File.expand_path('./partials/allure_requirements.tt', __dir__))).result(binding).strip! -%>
|
4
|
+
<%- allure = ERB.new(File.read(File.expand_path('./partials/allure_imports.tt', __dir__))).result(binding).strip! -%>
|
5
|
+
|
5
6
|
|
6
7
|
module Raider
|
7
8
|
module AllureHelper
|
@@ -22,11 +23,11 @@ module Raider
|
|
22
23
|
)
|
23
24
|
end
|
24
25
|
|
25
|
-
|
26
|
+
<%- if framework == 'rspec' -%>
|
26
27
|
def formatter
|
27
28
|
AllureRspecFormatter
|
28
29
|
end
|
29
|
-
|
30
|
+
<%- end -%>
|
30
31
|
end
|
31
32
|
end
|
32
33
|
end
|
@@ -11,7 +11,7 @@ module Raider
|
|
11
11
|
module DriverHelper
|
12
12
|
attr_reader :driver
|
13
13
|
|
14
|
-
|
14
|
+
<%= ERB.new(File.read(File.expand_path('./partials/driver_and_options.tt', __dir__)), trim_mode: '-').result(binding).strip! %>
|
15
15
|
|
16
16
|
<% if automation == 'cross_platform' -%>
|
17
17
|
private
|
@@ -20,11 +20,11 @@ module Raider
|
|
20
20
|
YAML.load_file('config/config.yml')
|
21
21
|
end
|
22
22
|
<% end -%>
|
23
|
-
|
23
|
+
<%- if automation != 'selenium' -%>
|
24
24
|
# :reek:UtilityFunction
|
25
25
|
def caps
|
26
26
|
YAML.load_file('config/capabilities.yml')
|
27
27
|
end
|
28
|
-
|
29
|
-
|
28
|
+
<%- end -%>
|
29
|
+
end
|
30
30
|
end
|
@@ -1,8 +1,5 @@
|
|
1
|
-
|
2
|
-
when 'selenium' %>
|
1
|
+
<%- if automation == 'selenium' -%>
|
3
2
|
driver.save_screenshot("allure-results/screenshots/#{example_name}.png")
|
4
|
-
|
3
|
+
<%- else -%>
|
5
4
|
browser.screenshot.save("allure-results/screenshots/#{example_name}.png")
|
6
|
-
|
7
|
-
driver.screenshot("allure-results/screenshots/#{example_name}.png")
|
8
|
-
<% end %>
|
5
|
+
<%- end -%>
|
@@ -9,9 +9,7 @@ module Raider
|
|
9
9
|
<%- else -%>
|
10
10
|
require_relative 'driver_helper'
|
11
11
|
<%- end -%>
|
12
|
-
<%- unless visual_automation -%>
|
13
12
|
require_relative 'allure_helper'
|
14
|
-
<%- end -%>
|
15
13
|
<%- if automation == 'cross_platform' -%>
|
16
14
|
require_relative 'appium_helper'
|
17
15
|
<%- end -%>
|
@@ -21,9 +21,9 @@ module Raider
|
|
21
21
|
|
22
22
|
config.after(:each) do
|
23
23
|
example_name = self.class.descendant_filtered_examples.first.description
|
24
|
-
<%= ERB.new(File.read(File.expand_path('./partials/screenshot.tt', __dir__))).result(binding).strip! %>
|
24
|
+
<%= ERB.new(File.read(File.expand_path('./partials/screenshot.tt', __dir__)), trim_mode: '-').result(binding).strip! %>
|
25
25
|
AllureHelper.add_screenshot example_name
|
26
|
-
<%= ERB.new(File.read(File.expand_path('./partials/quit_driver.tt', __dir__))).result(binding).strip! %>
|
26
|
+
<%= ERB.new(File.read(File.expand_path('./partials/quit_driver.tt', __dir__)), trim_mode: '-').result(binding).strip! %>
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -2,34 +2,30 @@
|
|
2
2
|
|
3
3
|
require 'rspec'
|
4
4
|
require 'eyes_selenium'
|
5
|
-
|
5
|
+
require_relative 'allure_helper'
|
6
6
|
require_relative 'driver_helper'
|
7
|
-
<%- else -%>
|
8
|
-
require_relative 'browser_helper'
|
9
|
-
<%- end -%>
|
10
7
|
require_relative 'visual_helper'
|
11
8
|
|
12
9
|
module Raider
|
13
10
|
module SpecHelper
|
14
11
|
RSpec.configure do |config|
|
15
|
-
config.include(
|
12
|
+
config.include(DriverHelper)
|
16
13
|
config.include(VisualHelper)
|
17
14
|
config.before(:each) do
|
18
15
|
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
|
19
16
|
@grid_runner = create_grid_runner
|
20
17
|
@eyes = create_eyes(@grid_runner)
|
21
18
|
configure_eyes @eyes
|
22
|
-
<%- if automation == 'selenium' -%>
|
23
19
|
@driver = @eyes.open(driver: new_driver)
|
24
|
-
<%- else -%>
|
25
|
-
@driver = @eyes.open(driver: new_browser.driver)
|
26
|
-
<%- end -%>
|
27
20
|
end
|
28
21
|
|
29
22
|
config.after(:each) do
|
23
|
+
example_name = self.class.descendant_filtered_examples.first.description
|
24
|
+
driver.save_screenshot("allure-results/screenshots/#{example_name}.png")
|
30
25
|
@eyes.close
|
31
26
|
@driver.quit
|
32
27
|
@eyes.abort_async
|
28
|
+
AllureHelper.add_screenshot example_name
|
33
29
|
results = @grid_runner.get_all_test_results
|
34
30
|
puts results
|
35
31
|
end
|
data/ruby_raider.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'ruby_raider'
|
5
|
-
s.version = '0.7.
|
5
|
+
s.version = '0.7.2'
|
6
6
|
s.summary = 'A gem to make setup and start of UI automation projects easier'
|
7
7
|
s.description = 'This gem has everything you need to start working with test automation'
|
8
8
|
s.authors = ['Agustin Pequeno']
|
@@ -22,7 +22,6 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.add_development_dependency 'rubocop-rspec', '~> 2.9.0'
|
23
23
|
|
24
24
|
s.add_runtime_dependency 'faraday', '~> 1.2.0'
|
25
|
-
s.add_runtime_dependency 'faraday-multipart', '~> 1.0.4'
|
26
25
|
s.add_runtime_dependency 'glimmer-dsl-libui', '~> 0.7.3'
|
27
26
|
s.add_runtime_dependency 'ruby-openai', '~> 3.5'
|
28
27
|
s.add_runtime_dependency 'thor', '~> 1.2.1'
|
@@ -45,10 +45,6 @@ describe HelpersGenerator do
|
|
45
45
|
end
|
46
46
|
|
47
47
|
shared_examples 'creates common visual helpers' do |name|
|
48
|
-
it 'does not create an allure helper file' do
|
49
|
-
expect(File).not_to exist("#{name}/helpers/allure_helper.rb")
|
50
|
-
end
|
51
|
-
|
52
48
|
it 'creates a raider file' do
|
53
49
|
expect(File).to exist("#{name}/helpers/raider.rb")
|
54
50
|
end
|
@@ -76,12 +72,6 @@ describe HelpersGenerator do
|
|
76
72
|
include_examples 'creates rspec helpers', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[2]}_visual"
|
77
73
|
end
|
78
74
|
|
79
|
-
context 'with rspec, watir and applitools' do
|
80
|
-
include_examples 'creates common visual helpers', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[3]}_visual"
|
81
|
-
include_examples 'creates watir helpers', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[3]}_visual"
|
82
|
-
include_examples 'creates rspec helpers', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[3]}_visual"
|
83
|
-
end
|
84
|
-
|
85
75
|
context 'with cucumber and selenium' do
|
86
76
|
include_examples 'creates common helpers', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[2]}"
|
87
77
|
include_examples 'creates selenium helpers', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[2]}"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_raider
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Agustin Pequeno
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -122,20 +122,6 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 1.2.0
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: faraday-multipart
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - "~>"
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: 1.0.4
|
132
|
-
type: :runtime
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - "~>"
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: 1.0.4
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
126
|
name: glimmer-dsl-libui
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -226,6 +212,7 @@ files:
|
|
226
212
|
- lib/generators/automation/automation_generator.rb
|
227
213
|
- lib/generators/automation/templates/abstract_component.tt
|
228
214
|
- lib/generators/automation/templates/abstract_page.tt
|
215
|
+
- lib/generators/automation/templates/account_page.tt
|
229
216
|
- lib/generators/automation/templates/appium_caps.tt
|
230
217
|
- lib/generators/automation/templates/component.tt
|
231
218
|
- lib/generators/automation/templates/home_page.tt
|
@@ -238,9 +225,11 @@ files:
|
|
238
225
|
- lib/generators/automation/templates/partials/ios_caps.tt
|
239
226
|
- lib/generators/automation/templates/partials/pdp_page_selector.tt
|
240
227
|
- lib/generators/automation/templates/partials/require_raider.tt
|
228
|
+
- lib/generators/automation/templates/partials/selenium_account.tt
|
241
229
|
- lib/generators/automation/templates/partials/selenium_login.tt
|
242
230
|
- lib/generators/automation/templates/partials/url_methods.tt
|
243
231
|
- lib/generators/automation/templates/partials/visit_method.tt
|
232
|
+
- lib/generators/automation/templates/partials/watir_account.tt
|
244
233
|
- lib/generators/automation/templates/partials/watir_login.tt
|
245
234
|
- lib/generators/automation/templates/pdp_page.tt
|
246
235
|
- lib/generators/automation/templates/visual_options.tt
|
@@ -253,7 +242,7 @@ files:
|
|
253
242
|
- lib/generators/cucumber/templates/partials/appium_env.tt
|
254
243
|
- lib/generators/cucumber/templates/partials/driver_world.tt
|
255
244
|
- lib/generators/cucumber/templates/partials/mobile_steps.tt
|
256
|
-
- lib/generators/cucumber/templates/partials/
|
245
|
+
- lib/generators/cucumber/templates/partials/selenium_env.tt
|
257
246
|
- lib/generators/cucumber/templates/partials/watir_env.tt
|
258
247
|
- lib/generators/cucumber/templates/partials/watir_world.tt
|
259
248
|
- lib/generators/cucumber/templates/partials/web_steps.tt
|
@@ -332,7 +321,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
332
321
|
- !ruby/object:Gem::Version
|
333
322
|
version: '0'
|
334
323
|
requirements: []
|
335
|
-
rubygems_version: 3.4.
|
324
|
+
rubygems_version: 3.4.13
|
336
325
|
signing_key:
|
337
326
|
specification_version: 4
|
338
327
|
summary: A gem to make setup and start of UI automation projects easier
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require_relative '../../helpers/driver_helper'
|
2
|
-
|
3
|
-
include Raider::DriverHelper
|
4
|
-
|
5
|
-
Before do
|
6
|
-
new_driver
|
7
|
-
end
|
8
|
-
|
9
|
-
After do |scenario|
|
10
|
-
driver.save_screenshot("allure-results/screenshots/#{scenario.name}.png")
|
11
|
-
Raider::AllureHelper.add_screenshot(scenario.name)
|
12
|
-
driver.quit
|
13
|
-
end
|