ruby_raider 0.7.4 → 0.7.6
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 -0
- data/lib/generators/automation/templates/abstract_page.tt +17 -0
- data/lib/generators/automation/templates/appium_caps.tt +1 -1
- data/lib/generators/automation/templates/home_page.tt +18 -0
- data/lib/generators/automation/templates/partials/android_caps.tt +6 -4
- data/lib/generators/automation/templates/partials/cross_platform_caps.tt +11 -10
- data/lib/generators/automation/templates/partials/ios_caps.tt +7 -5
- data/lib/generators/automation/templates/pdp_page.tt +19 -0
- data/lib/generators/common_generator.rb +1 -1
- data/lib/generators/cucumber/templates/partials/appium_env.tt +18 -1
- data/lib/generators/cucumber/templates/partials/mobile_steps.tt +20 -0
- data/lib/generators/generator.rb +5 -1
- data/lib/generators/menu_generator.rb +9 -0
- data/lib/generators/rspec/templates/spec.tt +18 -1
- data/lib/generators/templates/common/gemfile.tt +3 -0
- data/lib/generators/templates/common/read_me.tt +1 -0
- data/lib/generators/templates/helpers/driver_helper.tt +23 -0
- data/lib/generators/templates/helpers/spec_helper.tt +29 -1
- data/ruby_raider.gemspec +1 -1
- data/spec/common_generator_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3c7392870379f23c003129b0c892eeb60cfd87fe7d0479e42670cfd9b20fc13
|
4
|
+
data.tar.gz: b09e4169504207c2af34d0a0a0f5846ab370c9df62cd1e350daf747c4980e1c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc2e7a690f3ba2c6f23d2344ad7e634e4046bdfb7da082f4522f0a3736650f32767ac5ad8484649c26df8499624ba522e8f8b2f58122f42debcd54dae87c90bf
|
7
|
+
data.tar.gz: 2e12ed98a785fcee9f22310d4ead6b8de730eea67c092d319c183c5a1051c1317345186b14669e0f417cbe0ab4827390b2e49729704b779e1cb7e04e16305a3a
|
data/README.md
CHANGED
@@ -57,6 +57,7 @@ Ruby Raider is a generator and scaffolding gem to make UI test automation easier
|
|
57
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
|
+
***Remember to use the full path of the app that you download in the capabilities file***
|
60
61
|
|
61
62
|
***In order to run the visual tests with applitools, you need to create an account and get your api key, you can read
|
62
63
|
more [here](https://applitools.com/docs/topics/overview/obtain-api-key.html#:~:text=If%20you%20already%20have%20an,Your%20key%20will%20be%20displayed.)
|
@@ -1,3 +1,19 @@
|
|
1
|
+
<%- if automation == 'sparkling_ios' -%>
|
2
|
+
require 'sparkling_watir/element'
|
3
|
+
|
4
|
+
class AbstractPage
|
5
|
+
|
6
|
+
attr_reader :app
|
7
|
+
|
8
|
+
def initialize(app)
|
9
|
+
@app = app
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_s
|
13
|
+
self.class.to_s.sub('Page', ' Page')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
<%- else -%>
|
1
17
|
class AbstractPage
|
2
18
|
<% if automation == 'cross_platform' -%>
|
3
19
|
include AppiumHelper
|
@@ -10,3 +26,4 @@ class AbstractPage
|
|
10
26
|
self.class.to_s.sub('Page', ' Page')
|
11
27
|
end
|
12
28
|
end
|
29
|
+
<%- end -%>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<% if automation
|
1
|
+
<% if automation.include?('ios') %>
|
2
2
|
<%= ERB.new(File.read(File.expand_path('./partials/ios_caps.tt', __dir__))).result(binding) -%>
|
3
3
|
<% elsif automation == 'android' %>
|
4
4
|
<%= ERB.new(File.read(File.expand_path('./partials/android_caps.tt', __dir__))).result(binding) -%>
|
@@ -1,7 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative '../abstract/abstract_page'
|
4
|
+
<%- if automation == 'sparkling_ios' -%>
|
5
|
+
class HomePage < AbstractPage
|
6
|
+
|
7
|
+
# Actions
|
4
8
|
|
9
|
+
def go_to_backpack_pdp
|
10
|
+
app.tap on: backpack_image.wait_until(&:present?)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
# Elements
|
16
|
+
|
17
|
+
def backpack_image
|
18
|
+
app.element(predicate: 'label == "Sauce Labs Backpack"')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
<%- else -%>
|
5
22
|
class HomePage < AbstractPage
|
6
23
|
|
7
24
|
# Actions
|
@@ -18,3 +35,4 @@ class HomePage < AbstractPage
|
|
18
35
|
<%= ERB.new(File.read(File.expand_path('./partials/home_page_selector.tt', __dir__)), trim_mode: '-').result(binding) %>
|
19
36
|
end
|
20
37
|
end
|
38
|
+
<%- end -%>
|
@@ -1,5 +1,7 @@
|
|
1
|
-
automationName: UiAutomator2
|
2
1
|
platformName: Android
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
appium:options:
|
3
|
+
url: http://localhost:4723/wd/hub
|
4
|
+
platformVersion: '12'
|
5
|
+
automationName: UiAutomator2
|
6
|
+
deviceName: Pixel 3 API 32
|
7
|
+
app: "Android-MyDemoAppRN.1.3.0.build-244.apk"
|
@@ -1,14 +1,15 @@
|
|
1
1
|
android:
|
2
|
-
automationName: UiAutomator2
|
3
2
|
platformName: Android
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
appium:options:
|
4
|
+
platformVersion: '12'
|
5
|
+
automationName: UiAutomator2
|
6
|
+
deviceName: Pixel 3 API 32
|
7
|
+
app: "Android-MyDemoAppRN.1.3.0.build-244.apk"
|
8
8
|
ios:
|
9
|
-
automationName: XCUITest
|
10
9
|
platformName: iOS
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
appium:options:
|
11
|
+
platformVersion: "14.0"
|
12
|
+
deviceName: iPhone 11
|
13
|
+
automationName: XCUITest
|
14
|
+
app: "MyRNDemoApp.app"
|
15
|
+
autoDismissAlerts: true
|
@@ -1,6 +1,8 @@
|
|
1
|
-
automationName: XCUITest
|
2
1
|
platformName: iOS
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
appium:options:
|
3
|
+
url: http://localhost:4723/wd/hub
|
4
|
+
platformVersion: "14.0"
|
5
|
+
deviceName: iPhone 11
|
6
|
+
automationName: XCUITest
|
7
|
+
app: "MyRNDemoApp.app"
|
8
|
+
autoDismissAlerts: true
|
@@ -1,4 +1,22 @@
|
|
1
1
|
require_relative '../abstract/abstract_page'
|
2
|
+
<%- if automation == 'sparkling_ios' -%>
|
3
|
+
class PdpPage < AbstractPage
|
4
|
+
|
5
|
+
# Actions
|
6
|
+
|
7
|
+
def add_to_cart_text
|
8
|
+
add_to_cart_button.wait_until(&:present?).text
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
# Elements
|
14
|
+
|
15
|
+
def add_to_cart_button
|
16
|
+
app.element(accessibility_id: 'Add To Cart button')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
<%- else -%>
|
2
20
|
|
3
21
|
class PdpPage < AbstractPage
|
4
22
|
|
@@ -16,3 +34,4 @@ class PdpPage < AbstractPage
|
|
16
34
|
<%= ERB.new(File.read(File.expand_path('./partials/pdp_page_selector.tt', __dir__)), trim_mode: '-').result(binding) %>
|
17
35
|
end
|
18
36
|
end
|
37
|
+
<%- end -%>
|
@@ -1,3 +1,19 @@
|
|
1
|
+
<%- if automation == 'sparkling_ios' -%>
|
2
|
+
require_relative '../../helpers/driver_helper'
|
3
|
+
|
4
|
+
include DriverHelper
|
5
|
+
|
6
|
+
Before do
|
7
|
+
AllureHelper.configure
|
8
|
+
app
|
9
|
+
end
|
10
|
+
|
11
|
+
After do |scenario|
|
12
|
+
app.screenshot.save("allure-results/screenshots/#{scenario.name}.png")
|
13
|
+
AllureHelper.add_screenshot(scenario.name)
|
14
|
+
app.close
|
15
|
+
end
|
16
|
+
<%- else -%>
|
1
17
|
require_relative '../../helpers/driver_helper'
|
2
18
|
|
3
19
|
include DriverHelper
|
@@ -11,4 +27,5 @@ After do |scenario|
|
|
11
27
|
driver.screenshot("allure-results/screenshots/#{scenario.name}.png")
|
12
28
|
AllureHelper.add_screenshot(scenario.name)
|
13
29
|
driver.quit_driver
|
14
|
-
end
|
30
|
+
end
|
31
|
+
<%- end -%>
|
@@ -1,3 +1,22 @@
|
|
1
|
+
<%- if automation == 'sparkling_ios' -%>
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative '../../page_objects/pages/home_page'
|
5
|
+
require_relative '../../page_objects/pages/pdp_page'
|
6
|
+
|
7
|
+
Given("I'm an anonymous user on the home page") do
|
8
|
+
@home_page = HomePage.new(app)
|
9
|
+
end
|
10
|
+
|
11
|
+
When('I select one of the products') do
|
12
|
+
@home_page.go_to_backpack_pdp
|
13
|
+
end
|
14
|
+
|
15
|
+
When("I'm redirected to the product details page") do
|
16
|
+
pdp_page = PdpPage.new(app)
|
17
|
+
expect(pdp_page.add_to_cart_text).to eq 'Add To Cart'
|
18
|
+
end
|
19
|
+
<%- else -%>
|
1
20
|
# frozen_string_literal: true
|
2
21
|
|
3
22
|
require_relative '../../page_objects/pages/home_page'
|
@@ -15,3 +34,4 @@ When("I'm redirected to the product details page") do
|
|
15
34
|
pdp_page = PdpPage.new(driver)
|
16
35
|
expect(pdp_page.add_to_cart_text).to eq 'Add To Cart'
|
17
36
|
end
|
37
|
+
<%- end -%>
|
data/lib/generators/generator.rb
CHANGED
@@ -29,7 +29,11 @@ class Generator < Thor::Group
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def mobile?
|
32
|
-
(args & %w[android ios cross_platform]).count.positive?
|
32
|
+
(args & %w[android ios cross_platform sparkling_ios]).count.positive?
|
33
|
+
end
|
34
|
+
|
35
|
+
def single_platform?
|
36
|
+
(args & %w[android ios sparkling_ios]).count.positive?
|
33
37
|
end
|
34
38
|
|
35
39
|
def rspec?
|
@@ -19,6 +19,7 @@ class MenuGenerator
|
|
19
19
|
prompt.select('Please select your automation framework') do |menu|
|
20
20
|
menu.choice :Appium, -> { choose_test_framework('appium') }
|
21
21
|
menu.choice :Selenium, -> { choose_test_framework('selenium') }
|
22
|
+
menu.choice 'Sparkling Watir', -> { choose_test_framework('sparkling') }
|
22
23
|
menu.choice :Watir, -> { choose_test_framework('watir') }
|
23
24
|
menu.choice :Quit, -> { exit }
|
24
25
|
end
|
@@ -30,6 +31,7 @@ class MenuGenerator
|
|
30
31
|
|
31
32
|
def choose_test_framework(automation)
|
32
33
|
return choose_mobile_platform if automation == 'appium'
|
34
|
+
return choose_sparkling_platform if automation == 'sparkling'
|
33
35
|
|
34
36
|
select_test_framework(automation)
|
35
37
|
end
|
@@ -45,6 +47,13 @@ class MenuGenerator
|
|
45
47
|
system "cd #{name} && gem install bundler && bundle install"
|
46
48
|
end
|
47
49
|
|
50
|
+
def choose_sparkling_platform
|
51
|
+
prompt.select('Please select your mobile platform') do |menu|
|
52
|
+
menu.choice :iOS, -> { choose_test_framework 'sparkling_ios' }
|
53
|
+
menu.choice :Quit, -> { exit }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
48
57
|
def choose_mobile_platform
|
49
58
|
prompt.select('Please select your mobile platform') do |menu|
|
50
59
|
menu.choice :iOS, -> { choose_test_framework 'ios' }
|
@@ -42,12 +42,29 @@ describe 'Login' do
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
45
|
+
<%- elsif automation == 'sparkling_ios' -%>
|
46
|
+
require_relative '../helpers/spec_helper'
|
47
|
+
require_relative '../page_objects/pages/home_page'
|
48
|
+
require_relative '../page_objects/pages/pdp_page'
|
49
|
+
|
50
|
+
class PdpSpec
|
51
|
+
describe 'PDP page' do
|
52
|
+
|
53
|
+
let(:home_page) { HomePage.new(app) }
|
54
|
+
let(:pdp_page) { PdpPage.new(app) }
|
55
|
+
|
56
|
+
it 'shows add to cart button' do
|
57
|
+
home_page.go_to_backpack_pdp
|
58
|
+
expect(pdp_page.add_to_cart_text).to eq 'Add To Cart'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
45
62
|
<%- else -%>
|
46
63
|
require_relative '../helpers/spec_helper'
|
47
64
|
require_relative '../page_objects/pages/home_page'
|
48
65
|
require_relative '../page_objects/pages/pdp_page'
|
49
66
|
|
50
|
-
class PdpSpec
|
67
|
+
class PdpSpec
|
51
68
|
describe 'PDP page' do
|
52
69
|
|
53
70
|
let(:home_page) { HomePage.new(driver) }
|
@@ -53,6 +53,7 @@ Ruby Raider is a generator and scaffolding gem to make UI test automation easier
|
|
53
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
|
+
***Remember to use the full path of the app that you download in the capabilities file***
|
56
57
|
|
57
58
|
***In order to run the visual tests with applitools, you need to create an account and get your api key, you can read
|
58
59
|
more [here](https://applitools.com/docs/topics/overview/obtain-api-key.html#:~:text=If%20you%20already%20have%20an,Your%20key%20will%20be%20displayed.)
|
@@ -1,3 +1,25 @@
|
|
1
|
+
<%- if automation == 'sparkling_ios' -%>
|
2
|
+
# frozen_string_literal: true
|
3
|
+
require 'yaml'
|
4
|
+
require 'sparkling_watir'
|
5
|
+
|
6
|
+
module DriverHelper
|
7
|
+
def app
|
8
|
+
@app ||= create_app
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def create_app
|
14
|
+
@app = SparklingWatir::App.new(caps: caps)
|
15
|
+
end
|
16
|
+
|
17
|
+
# :reek:UtilityFunction
|
18
|
+
def caps
|
19
|
+
YAML.load_file('config/capabilities.yml')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
<%- else -%>
|
1
23
|
# frozen_string_literal: true
|
2
24
|
require 'yaml'
|
3
25
|
<% if automation == 'selenium' -%>
|
@@ -29,3 +51,4 @@ module DriverHelper
|
|
29
51
|
end
|
30
52
|
<%- end -%>
|
31
53
|
end
|
54
|
+
<%- end -%>
|
@@ -1,3 +1,30 @@
|
|
1
|
+
<%- if automation == 'sparkling_ios' -%>
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'rspec'
|
5
|
+
require_relative 'allure_helper'
|
6
|
+
require_relative 'driver_helper'
|
7
|
+
require 'sparkling_watir'
|
8
|
+
|
9
|
+
module SpecHelper
|
10
|
+
|
11
|
+
AllureHelper.configure
|
12
|
+
RSpec.configure do |config|
|
13
|
+
config.formatter = AllureHelper.formatter
|
14
|
+
config.include(DriverHelper)
|
15
|
+
config.before(:each) do
|
16
|
+
app
|
17
|
+
end
|
18
|
+
|
19
|
+
config.after(:each) do
|
20
|
+
example_name = self.class.descendant_filtered_examples.first.description
|
21
|
+
app.screenshot.save("allure-results/screenshots/#{example_name}.png")
|
22
|
+
AllureHelper.add_screenshot example_name
|
23
|
+
app.close
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
<%- else -%>
|
1
28
|
# frozen_string_literal: true
|
2
29
|
|
3
30
|
require 'rspec'
|
@@ -27,4 +54,5 @@ module SpecHelper
|
|
27
54
|
<%= ERB.new(File.read(File.expand_path('./partials/quit_driver.tt', __dir__)), trim_mode: '-').result(binding).strip! %>
|
28
55
|
end
|
29
56
|
end
|
30
|
-
end
|
57
|
+
end
|
58
|
+
<%- 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.6'
|
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']
|
@@ -107,12 +107,12 @@ describe CommonGenerator do
|
|
107
107
|
context 'with cucumber and appium cross platform' do
|
108
108
|
include_examples 'creates common files', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES.last}"
|
109
109
|
include_examples 'creates a capabilities file', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES.last}"
|
110
|
-
include_examples
|
110
|
+
include_examples 'creates a config file', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES.last}"
|
111
111
|
end
|
112
112
|
|
113
113
|
context 'with rspec and appium cross platform' do
|
114
114
|
include_examples 'creates common files', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES.last}"
|
115
115
|
include_examples 'creates a capabilities file', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES.last}"
|
116
|
-
include_examples
|
116
|
+
include_examples 'creates a config file', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES.last}"
|
117
117
|
end
|
118
118
|
end
|
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.6
|
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-
|
11
|
+
date: 2023-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|