ruby_raider 0.9.2 → 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +0 -4
- data/lib/generators/automation/templates/account.tt +2 -2
- data/lib/generators/automation/templates/appium_caps.tt +2 -2
- data/lib/generators/automation/templates/home.tt +1 -19
- data/lib/generators/automation/templates/login.tt +2 -2
- data/lib/generators/automation/templates/page.tt +3 -20
- data/lib/generators/automation/templates/partials/element.tt +1 -1
- data/lib/generators/automation/templates/partials/home_page_selector.tt +2 -2
- data/lib/generators/automation/templates/partials/initialize_selector.tt +1 -1
- data/lib/generators/automation/templates/partials/pdp_page_selector.tt +2 -2
- data/lib/generators/automation/templates/partials/selenium_login.tt +1 -1
- data/lib/generators/automation/templates/partials/url_methods.tt +1 -1
- data/lib/generators/automation/templates/partials/visit_method.tt +2 -2
- data/lib/generators/automation/templates/pdp.tt +1 -20
- data/lib/generators/cucumber/templates/env.tt +6 -7
- data/lib/generators/cucumber/templates/feature.tt +7 -3
- data/lib/generators/cucumber/templates/partials/appium_env.tt +1 -25
- data/lib/generators/cucumber/templates/partials/driver_world.tt +4 -3
- data/lib/generators/cucumber/templates/partials/mobile_steps.tt +6 -26
- data/lib/generators/cucumber/templates/partials/selenium_env.tt +6 -6
- data/lib/generators/cucumber/templates/partials/watir_env.tt +1 -4
- data/lib/generators/cucumber/templates/partials/web_steps.tt +10 -3
- data/lib/generators/cucumber/templates/steps.tt +3 -3
- data/lib/generators/cucumber/templates/world.tt +1 -1
- data/lib/generators/generator.rb +17 -7
- data/lib/generators/helper_generator.rb +1 -1
- data/lib/generators/invoke_generators.rb +2 -6
- data/lib/generators/menu_generator.rb +7 -30
- data/lib/generators/rspec/rspec_generator.rb +1 -1
- data/lib/generators/rspec/templates/spec.tt +7 -24
- data/lib/generators/templates/common/config.tt +1 -1
- data/lib/generators/templates/common/gemfile.tt +13 -16
- data/lib/generators/templates/common/partials/automation_gems.tt +1 -1
- data/lib/generators/templates/common/partials/web_config.tt +1 -1
- data/lib/generators/templates/common/read_me.tt +0 -4
- data/lib/generators/templates/common/rubocop.tt +1 -1
- data/lib/generators/templates/helpers/allure_helper.tt +2 -2
- data/lib/generators/templates/helpers/driver_helper.tt +9 -30
- data/lib/generators/templates/helpers/partials/allure_imports.tt +1 -1
- data/lib/generators/templates/helpers/partials/allure_requirements.tt +1 -1
- data/lib/generators/templates/helpers/partials/driver_and_options.tt +3 -3
- data/lib/generators/templates/helpers/partials/quit_driver.tt +5 -6
- data/lib/generators/templates/helpers/partials/screenshot.tt +6 -7
- data/lib/generators/templates/helpers/spec_helper.tt +5 -36
- data/lib/version +1 -1
- metadata +2 -3
- data/spec/system/ruby_raider_spec.rb +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8f98b7b75772a1d20015806b95e8194b357031dc4828181b0d3db2ed3bf9a65
|
4
|
+
data.tar.gz: 6ef9b9c02c12d85fc2da88706c92051fc19fd3da4788613038771b4ecbdbe5b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85ab371da3692e9559efaff063b8403716c8f947b93d9504c65cd9ae7531c791c7545c82473661879b35a5896de664d103ca0d41cf526408a66dfc6e18d52700
|
7
|
+
data.tar.gz: 417edbb4b68ab62d0eba0d8c6eea8e60ef6df077f168d2d2fafb7019cc7a50b5528c086256b3d3a03c01ccf20abcc0e6018c572cd019c99c964bb5205c5ab4fe
|
data/README.md
CHANGED
@@ -41,10 +41,6 @@ Ruby Raider is a generator and scaffolding gem to make UI test automation easier
|
|
41
41
|
| Rspec and Watir | | Rspec and Appium for Android |
|
42
42
|
| | | Cucumber and Appium Cross-platform |
|
43
43
|
| | | Rspec and Appium Cross-platform |
|
44
|
-
| | | Cucumber and Sparkling Watir for IOS |
|
45
|
-
| | | Rspec and Sparkling Watir for IOS |
|
46
|
-
|
47
|
-
|
48
44
|
|
49
45
|
***In order to run the Appium tests, download the example [app](https://github.com/saucelabs/my-demo-app-rn).***
|
50
46
|
***Remember to use the full path of the app that you download in the capabilities file and start the server using one of the commands below:***
|
@@ -1,5 +1,5 @@
|
|
1
|
-
<%- if
|
1
|
+
<%- if selenium_based? -%>
|
2
2
|
<%=- ERB.new(File.read(File.expand_path('./partials/selenium_account.tt', __dir__)), trim_mode: '-').result(binding) -%>
|
3
|
-
<%- elsif
|
3
|
+
<%- elsif watir? -%>
|
4
4
|
<%=- ERB.new(File.read(File.expand_path('./partials/watir_account.tt', __dir__)), trim_mode: '-').result(binding) -%>
|
5
5
|
<%- end -%>
|
@@ -1,6 +1,6 @@
|
|
1
|
-
<% if
|
1
|
+
<% if ios? %>
|
2
2
|
<%= ERB.new(File.read(File.expand_path('./partials/ios_caps.tt', __dir__))).result(binding) -%>
|
3
|
-
<% elsif
|
3
|
+
<% elsif android? %>
|
4
4
|
<%= ERB.new(File.read(File.expand_path('./partials/android_caps.tt', __dir__))).result(binding) -%>
|
5
5
|
<% else %>
|
6
6
|
<%= ERB.new(File.read(File.expand_path('./partials/cross_platform_caps.tt', __dir__))).result(binding) -%>
|
@@ -1,24 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative '../abstract/page'
|
4
|
-
<%- if automation == 'sparkling_ios' -%>
|
5
|
-
class Home < Page
|
6
|
-
|
7
|
-
# Actions
|
8
4
|
|
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 -%>
|
22
5
|
class Home < Page
|
23
6
|
|
24
7
|
# Actions
|
@@ -32,7 +15,6 @@ class Home < Page
|
|
32
15
|
# Elements
|
33
16
|
|
34
17
|
def backpack_image
|
35
|
-
<%= ERB.new(File.read(File.expand_path('./partials/home_page_selector.tt', __dir__)), trim_mode: '-').result(binding)
|
18
|
+
<%= ERB.new(File.read(File.expand_path('./partials/home_page_selector.tt', __dir__)), trim_mode: '-').result(binding) -%>
|
36
19
|
end
|
37
20
|
end
|
38
|
-
<%- end -%>
|
@@ -1,5 +1,5 @@
|
|
1
|
-
<%- if
|
1
|
+
<%- if selenium_based? -%>
|
2
2
|
<%=- ERB.new(File.read(File.expand_path('./partials/selenium_login.tt', __dir__)), trim_mode: '-').result(binding) -%>
|
3
|
-
<%- elsif
|
3
|
+
<%- elsif watir? -%>
|
4
4
|
<%=- ERB.new(File.read(File.expand_path('./partials/watir_login.tt', __dir__)), trim_mode: '-').result(binding) -%>
|
5
5
|
<%- end -%>
|
@@ -1,25 +1,9 @@
|
|
1
|
-
<%- if automation == 'sparkling_ios' -%>
|
2
|
-
require 'sparkling_watir/element'
|
3
|
-
|
4
|
-
class Page
|
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 -%>
|
17
1
|
<%- if web? -%>
|
18
2
|
require_relative '../components/header'
|
19
3
|
<%- end -%>
|
20
4
|
|
21
5
|
class Page
|
22
|
-
<%- if
|
6
|
+
<%- if cross_platform? -%>
|
23
7
|
include AppiumHelper
|
24
8
|
<%- end -%>
|
25
9
|
<%=- ERB.new(File.read(File.expand_path('./partials/initialize_selector.tt', __dir__))).result(binding) -%>
|
@@ -30,13 +14,13 @@ class Page
|
|
30
14
|
self.class.to_s.sub('Page', ' Page')
|
31
15
|
end
|
32
16
|
|
33
|
-
<%- if
|
17
|
+
<%- if selenium_based? -%>
|
34
18
|
# Components
|
35
19
|
|
36
20
|
def header
|
37
21
|
Header.new(driver.find_element(id: 'customer_menu_top'))
|
38
22
|
end
|
39
|
-
<%- elsif
|
23
|
+
<%- elsif watir? -%>
|
40
24
|
# Components
|
41
25
|
|
42
26
|
def header
|
@@ -44,4 +28,3 @@ class Page
|
|
44
28
|
end
|
45
29
|
<%- end -%>
|
46
30
|
end
|
47
|
-
<%- end -%>
|
@@ -1,6 +1,6 @@
|
|
1
|
-
<%- if
|
1
|
+
<%- if ios? -%>
|
2
2
|
driver.find_element(predicate: 'label == "Sauce Labs Backpack"')
|
3
|
-
<%- elsif
|
3
|
+
<%- elsif android? -%>
|
4
4
|
driver.find_element(xpath: '(//android.view.ViewGroup[@content-desc="store item"])[1]/android.view.ViewGroup[1]')
|
5
5
|
<%- else -%>
|
6
6
|
element(ios: { predicate: 'label == "Sauce Labs Backpack"' },
|
@@ -1,6 +1,6 @@
|
|
1
|
-
<%- if
|
1
|
+
<%- if ios? -%>
|
2
2
|
driver.find_element(accessibility_id: 'Add To Cart button')
|
3
|
-
<%- elsif
|
3
|
+
<%- elsif android? -%>
|
4
4
|
driver.find_element(xpath: '//android.view.ViewGroup[@content-desc="Add To Cart button"]/android.widget.TextView')
|
5
5
|
<%- else -%>
|
6
6
|
element(ios: { accessibility_id: 'Add To Cart button' },
|
@@ -1,5 +1,5 @@
|
|
1
|
-
<% if
|
1
|
+
<% if web? %>
|
2
2
|
def visit(*page)
|
3
|
-
<% if
|
3
|
+
<% if selenium_based? %>@driver.navigate.to full_url(page.first) <% else %>@browser.goto full_url(page.first)<% end %>
|
4
4
|
end
|
5
5
|
<% end %>
|
@@ -1,22 +1,4 @@
|
|
1
1
|
require_relative '../abstract/page'
|
2
|
-
<%- if automation == 'sparkling_ios' -%>
|
3
|
-
class Pdp < Page
|
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 -%>
|
20
2
|
|
21
3
|
class Pdp < Page
|
22
4
|
|
@@ -31,7 +13,6 @@ class Pdp < Page
|
|
31
13
|
# Elements
|
32
14
|
|
33
15
|
def add_to_cart_button
|
34
|
-
<%= ERB.new(File.read(File.expand_path('./partials/pdp_page_selector.tt', __dir__)), trim_mode: '-').result(binding)
|
16
|
+
<%= ERB.new(File.read(File.expand_path('./partials/pdp_page_selector.tt', __dir__)), trim_mode: '-').result(binding) -%>
|
35
17
|
end
|
36
18
|
end
|
37
|
-
<%- end -%>
|
@@ -1,8 +1,7 @@
|
|
1
|
-
<%-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
<%=- ERB.new(File.read(File.expand_path('./partials/watir_env.tt', __dir__)), trim_mode: '-').result(binding) -%>
|
1
|
+
<%- if selenium_based? -%>
|
2
|
+
<%= ERB.new(File.read(File.expand_path('./partials/selenium_env.tt', __dir__)), trim_mode: '-').result(binding) -%>
|
3
|
+
<%- elsif mobile? -%>
|
4
|
+
<%= ERB.new(File.read(File.expand_path('./partials/appium_env.tt', __dir__)), trim_mode: '-').result(binding) -%>
|
6
5
|
<%- else -%>
|
7
|
-
|
8
|
-
<%- end -%>
|
6
|
+
<%= ERB.new(File.read(File.expand_path('./partials/watir_env.tt', __dir__)), trim_mode: '-').result(binding) -%>
|
7
|
+
<%- end -%>
|
@@ -1,16 +1,20 @@
|
|
1
|
-
|
1
|
+
<%- if web? -%>
|
2
2
|
Feature: Login Page
|
3
3
|
|
4
4
|
Scenario: A user can login
|
5
5
|
Given I'm a registered user on the login page
|
6
6
|
When I login with my credentials
|
7
|
+
<%- if axe? -%>
|
8
|
+
Then the page should be axe clean
|
9
|
+
<%- else -%>
|
7
10
|
Then I'm logged in
|
11
|
+
<% end -%>
|
8
12
|
|
9
|
-
|
13
|
+
<%- else -%>
|
10
14
|
Feature: Home Page
|
11
15
|
|
12
16
|
Scenario: A user can go to the product details page
|
13
17
|
Given I'm an anonymous user on the home page
|
14
18
|
When I select one of the products
|
15
19
|
Then I'm redirected to the product details page
|
16
|
-
|
20
|
+
<%- end %>
|
@@ -1,28 +1,5 @@
|
|
1
|
-
<%- if automation == 'sparkling_ios' -%>
|
2
1
|
require 'tmpdir'
|
3
2
|
require_relative '../../helpers/allure_helper'
|
4
|
-
require_relative '../../helpers/driver_helper'
|
5
|
-
|
6
|
-
include DriverHelper
|
7
|
-
|
8
|
-
Before do
|
9
|
-
AllureHelper.configure
|
10
|
-
app
|
11
|
-
end
|
12
|
-
|
13
|
-
After do |scenario|
|
14
|
-
Dir.mktmpdir do |temp_folder|
|
15
|
-
screenshot = app.screenshot.save("#{temp_folder}/#{scenario.name}.png")
|
16
|
-
AllureHelper.add_screenshot(scenario.name, screenshot)
|
17
|
-
end
|
18
|
-
app.close
|
19
|
-
end
|
20
|
-
<%- else -%>
|
21
|
-
require 'tmpdir'
|
22
|
-
require_relative '../../helpers/allure_helper'
|
23
|
-
require_relative '../../helpers/driver_helper'
|
24
|
-
|
25
|
-
include DriverHelper
|
26
3
|
|
27
4
|
Before do
|
28
5
|
AllureHelper.configure
|
@@ -35,5 +12,4 @@ After do |scenario|
|
|
35
12
|
AllureHelper.add_screenshot(scenario.name, screenshot)
|
36
13
|
end
|
37
14
|
driver.quit_driver
|
38
|
-
end
|
39
|
-
<%- end -%>
|
15
|
+
end
|
@@ -1,11 +1,12 @@
|
|
1
1
|
require_relative '../../helpers/driver_helper'
|
2
|
-
<%- if
|
2
|
+
<%- if visual? -%>
|
3
3
|
require_relative '../../helpers/visual_helper'
|
4
4
|
<%- end -%>
|
5
|
-
<%- if
|
5
|
+
<%- if selenium_based? -%>
|
6
6
|
require_relative '../../models/user_factory'
|
7
7
|
|
8
|
-
World(DriverHelper<%- if
|
8
|
+
World(DriverHelper<%- if visual? -%>, VisualHelper<%- end -%>)
|
9
9
|
<%- else -%>
|
10
|
+
|
10
11
|
World(DriverHelper)
|
11
12
|
<%- end -%>
|
@@ -1,40 +1,20 @@
|
|
1
|
-
<%- if automation == 'sparkling_ios' -%>
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
5
|
-
require_relative '../../page_objects/pages/pdp'
|
6
|
-
|
7
|
-
Given("I'm an anonymous user on the home page") do
|
8
|
-
@home_page = Home.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 = Pdp.new(app)
|
17
|
-
expect(pdp_page.add_to_cart_text).to eq 'Add To Cart'
|
18
|
-
end
|
19
|
-
<%- else -%>
|
20
|
-
# frozen_string_literal: true
|
21
|
-
|
22
|
-
<% if automation == 'cross_platform' -%>
|
3
|
+
<%- if cross_platform? -%>
|
23
4
|
require_relative '../../helpers/appium_helper'
|
24
5
|
<%- end -%>
|
25
6
|
require_relative '../../page_objects/pages/home'
|
26
7
|
require_relative '../../page_objects/pages/pdp'
|
27
8
|
|
28
9
|
Given("I'm an anonymous user on the home page") do
|
29
|
-
|
10
|
+
@home_page = Home.new(driver)
|
30
11
|
end
|
31
12
|
|
32
13
|
When('I select one of the products') do
|
33
|
-
|
14
|
+
@home_page.go_to_backpack_pdp
|
34
15
|
end
|
35
16
|
|
36
|
-
|
37
|
-
|
38
|
-
|
17
|
+
Then("I'm redirected to the product details page") do
|
18
|
+
pdp_page = Pdp.new(driver)
|
19
|
+
expect(pdp_page.add_to_cart_text).to eq 'Add To Cart'
|
39
20
|
end
|
40
|
-
<%- end -%>
|
@@ -1,5 +1,5 @@
|
|
1
|
-
<%- if visual_automation -%>
|
2
1
|
# frozen_string_literal: true
|
2
|
+
<%- if visual? -%>
|
3
3
|
|
4
4
|
require 'tmpdir'
|
5
5
|
require_relative '../../helpers/allure_helper'
|
@@ -30,14 +30,14 @@ After do |scenario|
|
|
30
30
|
end
|
31
31
|
|
32
32
|
<%- else -%>
|
33
|
-
# frozen_string_literal: true
|
34
33
|
|
34
|
+
<%- if axe? && cucumber? -%>
|
35
|
+
require 'axe-rspec'
|
36
|
+
<%- end -%>
|
37
|
+
require 'rspec'
|
35
38
|
require 'tmpdir'
|
36
|
-
require_relative '../../helpers/driver_helper'
|
37
39
|
require_relative '../../helpers/allure_helper'
|
38
40
|
|
39
|
-
include DriverHelper
|
40
|
-
|
41
41
|
Before do
|
42
42
|
driver.manage.window.maximize
|
43
43
|
end
|
@@ -49,4 +49,4 @@ After do |scenario|
|
|
49
49
|
end
|
50
50
|
driver.quit
|
51
51
|
end
|
52
|
-
<%- end -%>
|
52
|
+
<%- end -%>
|
@@ -2,9 +2,6 @@
|
|
2
2
|
|
3
3
|
require 'tmpdir'
|
4
4
|
require_relative '../../helpers/allure_helper'
|
5
|
-
require_relative '../../helpers/browser_helper'
|
6
|
-
|
7
|
-
include BrowserHelper
|
8
5
|
|
9
6
|
Before do
|
10
7
|
browser.window.maximize
|
@@ -16,4 +13,4 @@ After do |scenario|
|
|
16
13
|
AllureHelper.add_screenshot(scenario.name, screenshot)
|
17
14
|
end
|
18
15
|
browser.quit
|
19
|
-
end
|
16
|
+
end
|
@@ -5,7 +5,7 @@ require_relative '../../page_objects/pages/login'
|
|
5
5
|
|
6
6
|
Given("I'm a {user} on the login page") do |user|
|
7
7
|
@user = user
|
8
|
-
@login_page = Login.new(<% if
|
8
|
+
@login_page = Login.new(<% if watir? %>browser<% else %>driver<% end %>)
|
9
9
|
@login_page.visit
|
10
10
|
end
|
11
11
|
|
@@ -13,11 +13,18 @@ When('I login with my credentials') do
|
|
13
13
|
@login_page.login(@user['username'], @user['password'])
|
14
14
|
end
|
15
15
|
|
16
|
+
<%- if axe? -%>
|
17
|
+
Then('the page should be axe clean') do
|
18
|
+
account = Account.new(driver)
|
19
|
+
expect(account.page).to be_axe_clean
|
20
|
+
end
|
21
|
+
<%- else -%>
|
16
22
|
Then("I'm logged in") do
|
17
|
-
account_page = Account.new(<% if
|
18
|
-
<%- if
|
23
|
+
account_page = Account.new(<% if watir? %>browser<% else %>driver<% end %>)
|
24
|
+
<%- if visual? -%>
|
19
25
|
check_page account_page
|
20
26
|
<%- else -%>
|
21
27
|
expect(account_page.header.customer_name).to eq "Welcome back #{@user['name']}"
|
22
28
|
<%- end -%>
|
23
29
|
end
|
30
|
+
<%- end -%>
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
1
|
+
<%- if web? -%>
|
2
2
|
<%= ERB.new(File.read(File.expand_path('./partials/web_steps.tt', __dir__)), trim_mode: '-').result(binding).strip! -%>
|
3
|
-
|
3
|
+
<%- else -%>
|
4
4
|
<%= ERB.new(File.read(File.expand_path('./partials/mobile_steps.tt', __dir__)), trim_mode: '-').result(binding).strip! -%>
|
5
|
-
|
5
|
+
<%- end -%>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%- if
|
1
|
+
<%- if watir? -%>
|
2
2
|
<%=- ERB.new(File.read(File.expand_path('./partials/watir_world.tt', __dir__)), trim_mode: '-').result(binding).strip! -%>
|
3
3
|
<%- else -%>
|
4
4
|
<%=- ERB.new(File.read(File.expand_path('./partials/driver_world.tt', __dir__)), trim_mode: '-').result(binding).strip! -%>
|
data/lib/generators/generator.rb
CHANGED
@@ -8,8 +8,6 @@ class Generator < Thor::Group
|
|
8
8
|
argument :automation
|
9
9
|
argument :framework
|
10
10
|
argument :name
|
11
|
-
argument :visual_automation, optional: true
|
12
|
-
argument :axe_support, optional: true
|
13
11
|
|
14
12
|
def self.source_paths
|
15
13
|
base_path = File.dirname(__FILE__)
|
@@ -31,11 +29,19 @@ class Generator < Thor::Group
|
|
31
29
|
end
|
32
30
|
|
33
31
|
def mobile?
|
34
|
-
(args & %w[android ios cross_platform
|
32
|
+
(args & %w[android ios cross_platform]).count.positive?
|
35
33
|
end
|
36
34
|
|
37
35
|
def single_platform?
|
38
|
-
(args & %w[android ios
|
36
|
+
(args & %w[android ios]).count.positive?
|
37
|
+
end
|
38
|
+
|
39
|
+
def ios?
|
40
|
+
args.include?('ios')
|
41
|
+
end
|
42
|
+
|
43
|
+
def android?
|
44
|
+
args.include?('android')
|
39
45
|
end
|
40
46
|
|
41
47
|
def rspec?
|
@@ -47,7 +53,7 @@ class Generator < Thor::Group
|
|
47
53
|
end
|
48
54
|
|
49
55
|
def visual?
|
50
|
-
args
|
56
|
+
args.include?('applitools')
|
51
57
|
end
|
52
58
|
|
53
59
|
def watir?
|
@@ -55,11 +61,15 @@ class Generator < Thor::Group
|
|
55
61
|
end
|
56
62
|
|
57
63
|
def web?
|
58
|
-
(args & (%w[selenium watir])).count.positive?
|
64
|
+
(args & (%w[selenium watir axe applitools])).count.positive?
|
59
65
|
end
|
60
66
|
|
61
67
|
def axe?
|
62
|
-
args.
|
68
|
+
args.include?('axe')
|
69
|
+
end
|
70
|
+
|
71
|
+
def selenium_based?
|
72
|
+
(args & %w[selenium axe applitools]).count.positive?
|
63
73
|
end
|
64
74
|
|
65
75
|
private
|
@@ -19,9 +19,7 @@ module InvokeGenerators
|
|
19
19
|
automation: structure[:automation],
|
20
20
|
framework:,
|
21
21
|
generator:,
|
22
|
-
name: structure[:name]
|
23
|
-
visual: to_bool(structure[:visual]),
|
24
|
-
axe_support: to_bool(structure[:axe_support])
|
22
|
+
name: structure[:name]
|
25
23
|
})
|
26
24
|
end
|
27
25
|
end
|
@@ -34,9 +32,7 @@ module InvokeGenerators
|
|
34
32
|
Object.const_get("#{structure[:generator]}Generator")
|
35
33
|
.new([structure[:automation],
|
36
34
|
structure[:framework],
|
37
|
-
structure[:name]
|
38
|
-
structure[:visual],
|
39
|
-
structure[:axe_support]]).invoke_all
|
35
|
+
structure[:name]]).invoke_all
|
40
36
|
end
|
41
37
|
|
42
38
|
def to_bool(string)
|
@@ -21,17 +21,8 @@ class MenuGenerator
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
def choose_visual_automation
|
25
|
-
prompt.select('Do you want to add visual automation with Applitools?', yes_no_menu_choices)
|
26
|
-
end
|
27
|
-
|
28
|
-
def choose_axe_support
|
29
|
-
prompt.select('Do you want to add Axe accessibility testing tool?', yes_no_menu_choices)
|
30
|
-
end
|
31
|
-
|
32
24
|
def choose_test_framework(automation)
|
33
25
|
return choose_mobile_platform if automation == 'appium'
|
34
|
-
return choose_sparkling_platform if automation == 'sparkling'
|
35
26
|
|
36
27
|
select_test_framework(automation)
|
37
28
|
end
|
@@ -40,21 +31,12 @@ class MenuGenerator
|
|
40
31
|
structure = {
|
41
32
|
automation: options[:automation],
|
42
33
|
framework: options[:framework],
|
43
|
-
name: @name
|
44
|
-
visual: options[:visual_automation],
|
45
|
-
axe_support: options[:axe_support]
|
34
|
+
name: @name
|
46
35
|
}
|
47
36
|
generate_framework(structure)
|
48
37
|
system "cd #{name} && gem install bundler && bundle install"
|
49
38
|
end
|
50
39
|
|
51
|
-
def choose_sparkling_platform
|
52
|
-
prompt.select('Please select your mobile platform') do |menu|
|
53
|
-
menu.choice :iOS, -> { choose_test_framework 'sparkling_ios' }
|
54
|
-
menu.choice :Quit, -> { exit }
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
40
|
def choose_mobile_platform
|
59
41
|
prompt.select('Please select your mobile platform') do |menu|
|
60
42
|
menu.choice :iOS, -> { choose_test_framework 'ios' }
|
@@ -74,26 +56,20 @@ class MenuGenerator
|
|
74
56
|
end
|
75
57
|
end
|
76
58
|
|
77
|
-
FrameworkOptions = Struct.new(:automation, :framework
|
59
|
+
FrameworkOptions = Struct.new(:automation, :framework)
|
78
60
|
|
79
61
|
def create_framework_options(params)
|
80
|
-
FrameworkOptions.new(params[:automation], params[:framework]
|
62
|
+
FrameworkOptions.new(params[:automation], params[:framework])
|
81
63
|
end
|
82
64
|
|
83
65
|
def create_framework(framework, automation_type)
|
84
|
-
visual_automation = choose_visual_automation if %w[selenium].include?(automation_type)
|
85
|
-
axe = choose_axe_support if automation_type == 'selenium' && framework == 'Rspec' && visual_automation == false
|
86
66
|
options = create_framework_options(automation: automation_type,
|
87
|
-
framework: framework.downcase
|
88
|
-
visual_automation:,
|
89
|
-
axe_support: axe)
|
67
|
+
framework: framework.downcase)
|
90
68
|
|
91
69
|
# Print the chosen options
|
92
70
|
puts 'Chosen Options:'
|
93
71
|
puts " Automation Type: #{options[:automation]}"
|
94
72
|
puts " Framework: #{options[:framework]}"
|
95
|
-
puts " Visual Automation: #{options[:visual_automation]}"
|
96
|
-
puts " Axe Support: #{options[:axe_support]}"
|
97
73
|
|
98
74
|
set_up_framework(options)
|
99
75
|
prompt.say("You have chosen to use #{framework} with #{automation_type}")
|
@@ -108,10 +84,11 @@ class MenuGenerator
|
|
108
84
|
end
|
109
85
|
|
110
86
|
def select_automation_framework(menu)
|
111
|
-
menu.choice :Appium, -> { choose_test_framework('appium') }
|
112
87
|
menu.choice :Selenium, -> { choose_test_framework('selenium') }
|
113
|
-
menu.choice
|
88
|
+
menu.choice :Appium, -> { choose_test_framework('appium') }
|
114
89
|
menu.choice :Watir, -> { choose_test_framework('watir') }
|
90
|
+
menu.choice :Applitools, -> { choose_test_framework('applitools') }
|
91
|
+
menu.choice :Axe, -> { choose_test_framework('axe') }
|
115
92
|
menu.choice :Quit, -> { exit }
|
116
93
|
end
|
117
94
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%- if
|
1
|
+
<%- if selenium_based? || watir? -%>
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require_relative '../helpers/spec_helper'
|
@@ -33,13 +33,13 @@ describe 'Login' do
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
36
|
-
<%- elsif
|
36
|
+
<%- elsif selenium_based? || watir? -%>
|
37
37
|
describe 'Login' do
|
38
38
|
subject(:header) { account_page.header.customer_name }
|
39
39
|
|
40
40
|
let(:user) { ModelFactory.for('users')['registered user'] }
|
41
|
-
let(:login_page) { Login.new(<% if
|
42
|
-
let(:account_page) { Account.new(<% if
|
41
|
+
let(:login_page) { Login.new(<% if watir? -%>browser<% else -%>driver<% end -%>) }
|
42
|
+
let(:account_page) { Account.new(<% if watir? -%>browser<% else -%>driver<% end -%>) }
|
43
43
|
|
44
44
|
before do
|
45
45
|
login_page.visit
|
@@ -50,7 +50,7 @@ describe 'Login' do
|
|
50
50
|
let(:password) { user['password'] }
|
51
51
|
|
52
52
|
it 'can successfully log in' do
|
53
|
-
<%- if
|
53
|
+
<%- if visual? -%>
|
54
54
|
check_page account_page
|
55
55
|
<%- else -%>
|
56
56
|
expect(header).to eq "Welcome back #{user['name']}"
|
@@ -62,7 +62,7 @@ describe 'Login' do
|
|
62
62
|
let(:password) { 'wrongPassword' }
|
63
63
|
|
64
64
|
it 'cannot log in' do
|
65
|
-
<%- if
|
65
|
+
<%- if visual? -%>
|
66
66
|
check_page login_page
|
67
67
|
<%- else -%>
|
68
68
|
expect(header).to eq 'Login or register'
|
@@ -71,25 +71,8 @@ describe 'Login' do
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
<%- end -%>
|
74
|
-
<%- elsif automation == 'sparkling_ios' -%>
|
75
|
-
require_relative '../helpers/spec_helper'
|
76
|
-
require_relative '../page_objects/pages/home'
|
77
|
-
require_relative '../page_objects/pages/pdp'
|
78
|
-
|
79
|
-
class PdpSpec
|
80
|
-
describe 'PDP page' do
|
81
|
-
|
82
|
-
let(:home_page) { Home.new(app) }
|
83
|
-
let(:pdp_page) { Pdp.new(app) }
|
84
|
-
|
85
|
-
it 'shows add to cart button' do
|
86
|
-
home_page.go_to_backpack_pdp
|
87
|
-
expect(pdp_page.add_to_cart_text).to eq 'Add To Cart'
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
74
|
<%- else -%>
|
92
|
-
<% if
|
75
|
+
<% if cross_platform? -%>
|
93
76
|
require_relative '../helpers/appium_helper'
|
94
77
|
<%- end -%>
|
95
78
|
require_relative '../helpers/spec_helper'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<% if
|
1
|
+
<% if mobile? -%>
|
2
2
|
<%= ERB.new(File.read(File.expand_path('./partials/mobile_config.tt', __dir__))).result(binding) %>
|
3
3
|
<% else -%>
|
4
4
|
<%= ERB.new(File.read(File.expand_path('./partials/web_config.tt', __dir__)), trim_mode: '-').result(binding) %>
|
@@ -1,36 +1,33 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
gem 'activesupport'
|
4
|
-
|
4
|
+
<%- if cucumber? -%>
|
5
5
|
gem 'allure-cucumber'
|
6
|
-
|
6
|
+
<%- else -%>
|
7
7
|
gem 'allure-rspec'
|
8
8
|
gem 'allure-ruby-commons'
|
9
|
-
|
10
|
-
|
9
|
+
<%- end -%>
|
10
|
+
<%- if axe? -%>
|
11
11
|
gem 'axe-core-rspec'
|
12
12
|
gem 'axe-core-selenium'
|
13
|
-
|
14
|
-
|
13
|
+
<%- end -%>
|
14
|
+
<%- if visual? -%>
|
15
15
|
gem 'eyes_selenium', '~> 4.6', '>= 4.6.1'
|
16
16
|
gem 'eyes_universal', '~> 3.3', '>= 3.3.1'
|
17
|
-
|
18
|
-
|
17
|
+
<%- end -%>
|
18
|
+
<%- unless visual? -%>
|
19
19
|
gem 'parallel_split_test'
|
20
20
|
gem 'parallel_tests'
|
21
|
-
|
21
|
+
<%- end -%>
|
22
22
|
gem 'rake'
|
23
23
|
gem 'reek'
|
24
24
|
gem '<%= framework %>'
|
25
|
-
|
25
|
+
<%- if cucumber? -%>
|
26
26
|
gem 'rspec'
|
27
|
-
|
27
|
+
<%- end -%>
|
28
28
|
gem 'rubocop'
|
29
|
-
|
29
|
+
<%- if rspec? -%>
|
30
30
|
gem 'rubocop-rspec'
|
31
|
-
|
31
|
+
<%- end -%>
|
32
32
|
gem 'ruby_raider', '~> 0.9.0'
|
33
33
|
<%= ERB.new(File.read(File.expand_path('./partials/automation_gems.tt', __dir__))).result(binding).strip! %>
|
34
|
-
<% if automation == 'sparkling_ios' -%>
|
35
|
-
gem 'sparkling_watir'
|
36
|
-
<% end -%>
|
@@ -35,10 +35,6 @@ Ruby Raider is a generator and scaffolding gem to make UI test automation easier
|
|
35
35
|
| Rspec and Watir | | Rspec and Appium for Android |
|
36
36
|
| | | Cucumber and Appium Cross-platform |
|
37
37
|
| | | Rspec and Appium Cross-platform |
|
38
|
-
| | | Cucumber and Sparkling Watir for IOS |
|
39
|
-
| | | Rspec and Sparkling Watir for IOS |
|
40
|
-
|
41
|
-
|
42
38
|
|
43
39
|
***In order to run the Appium tests, download the example [app](https://github.com/saucelabs/my-demo-app-rn).***
|
44
40
|
***Remember to use the full path of the app that you download in the capabilities file and start the server using one of the commands below:***
|
@@ -1,48 +1,28 @@
|
|
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 -%>
|
23
1
|
# frozen_string_literal: true
|
24
2
|
<% if axe? -%>
|
25
3
|
require 'axe-selenium'
|
26
4
|
<% end -%>
|
27
5
|
require 'yaml'
|
28
|
-
|
6
|
+
<%- unless axe? %>
|
7
|
+
<%- if selenium_based? -%>
|
29
8
|
require 'active_support/inflector'
|
30
9
|
require 'selenium-webdriver'
|
31
|
-
|
10
|
+
<%- else -%>
|
32
11
|
require 'appium_lib'
|
33
|
-
|
12
|
+
<%- end -%>
|
13
|
+
<%- end -%>
|
34
14
|
|
35
15
|
module DriverHelper
|
36
|
-
|
16
|
+
<%- if selenium_based? && !axe? -%>
|
37
17
|
def driver(*opts)
|
38
18
|
@driver ||= create_driver(*opts)
|
39
19
|
end
|
40
|
-
|
20
|
+
<%- elsif axe? -%>
|
41
21
|
def driver(browser = :chrome, js_path = nil, skip_iframes = nil)
|
42
22
|
@driver ||= create_driver(browser, js_path, skip_iframes)
|
43
23
|
end
|
44
|
-
|
45
|
-
def driver
|
24
|
+
<%- else -%>
|
25
|
+
def driver
|
46
26
|
@driver ||= create_driver
|
47
27
|
end
|
48
28
|
<%- end -%>
|
@@ -51,4 +31,3 @@ def driver
|
|
51
31
|
|
52
32
|
<%= ERB.new(File.read(File.expand_path('./partials/driver_and_options.tt', __dir__)), trim_mode: '-').result(binding).strip! %>
|
53
33
|
end
|
54
|
-
<%- end -%>
|
@@ -1,11 +1,11 @@
|
|
1
|
-
<% if
|
1
|
+
<% if axe? -%>
|
2
2
|
def create_driver(browser, js_path, skip_iframes)
|
3
3
|
AxeSelenium.configure(browser) do |config|
|
4
4
|
config.jslib_path = js_path if js_path
|
5
5
|
config.skip_iframes = skip_iframes if skip_iframes
|
6
6
|
end.page
|
7
7
|
end
|
8
|
-
<% elsif
|
8
|
+
<% elsif selenium_based? -%>
|
9
9
|
def create_driver(*opts)
|
10
10
|
@config = YAML.load_file('config/config.yml')
|
11
11
|
browser = @config['browser'].to_sym
|
@@ -29,7 +29,7 @@
|
|
29
29
|
driver_options.each { |opt| options.add_option(opt.first, opt.last) }
|
30
30
|
options
|
31
31
|
end
|
32
|
-
<% elsif
|
32
|
+
<% elsif cross_platform? -%>
|
33
33
|
def create_driver
|
34
34
|
@driver = Appium::Driver.new({ caps: parsed_caps })
|
35
35
|
end
|
@@ -1,8 +1,7 @@
|
|
1
|
-
<%
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
screenshot = browser.screenshot.save("#{temp_folder}/#{example_name}.png")
|
1
|
+
<% if selenium_based? %>
|
2
|
+
screenshot = driver.save_screenshot("#{temp_folder}/#{example_name}.png")
|
3
|
+
<% elsif watir? %>
|
4
|
+
screenshot = browser.screenshot.save("#{temp_folder}/#{example_name}.png")
|
6
5
|
<% else %>
|
7
|
-
screenshot = driver.screenshot("#{temp_folder}/#{example_name}.png")
|
8
|
-
<% end %>
|
6
|
+
screenshot = driver.screenshot("#{temp_folder}/#{example_name}.png")
|
7
|
+
<% end %>
|
@@ -1,33 +1,3 @@
|
|
1
|
-
<%- if automation == 'sparkling_ios' -%>
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'rspec'
|
5
|
-
require 'tmpdir'
|
6
|
-
require_relative 'allure_helper'
|
7
|
-
require_relative 'driver_helper'
|
8
|
-
require 'sparkling_watir'
|
9
|
-
|
10
|
-
module SpecHelper
|
11
|
-
|
12
|
-
AllureHelper.configure
|
13
|
-
RSpec.configure do |config|
|
14
|
-
config.formatter = AllureHelper.formatter
|
15
|
-
config.include(DriverHelper)
|
16
|
-
config.before(:each) do
|
17
|
-
app
|
18
|
-
end
|
19
|
-
|
20
|
-
config.after(:each) do |example|
|
21
|
-
example_name = example.description
|
22
|
-
Dir.mktmpdir do |temp_folder|
|
23
|
-
screenshot = app.screenshot.save("#{temp_folder}/#{example_name}.png")
|
24
|
-
AllureHelper.add_screenshot(example_name, screenshot)
|
25
|
-
end
|
26
|
-
app.close
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
<%- else -%>
|
31
1
|
# frozen_string_literal: true
|
32
2
|
|
33
3
|
<%- if axe? %>
|
@@ -36,7 +6,7 @@ require 'axe-rspec'
|
|
36
6
|
require 'rspec'
|
37
7
|
require 'tmpdir'
|
38
8
|
require_relative 'allure_helper'
|
39
|
-
<%- if
|
9
|
+
<%- if watir? -%>
|
40
10
|
require_relative 'browser_helper'
|
41
11
|
<%- else -%>
|
42
12
|
require_relative 'driver_helper'
|
@@ -47,16 +17,16 @@ module SpecHelper
|
|
47
17
|
AllureHelper.configure
|
48
18
|
RSpec.configure do |config|
|
49
19
|
config.formatter = AllureHelper.formatter
|
50
|
-
<% if
|
51
|
-
<%- if
|
20
|
+
<% if watir? %>config.include(BrowserHelper)<% else %>config.include(DriverHelper)<% end %>
|
21
|
+
<%- if mobile? -%>
|
52
22
|
config.before(:each) do
|
53
23
|
driver.start_driver
|
54
24
|
end
|
55
|
-
<%- elsif
|
25
|
+
<%- elsif selenium_based? -%>
|
56
26
|
config.before(:each) do
|
57
27
|
driver.manage.window.maximize
|
58
28
|
end
|
59
|
-
<%- elsif
|
29
|
+
<%- elsif watir? -%>
|
60
30
|
config.before(:each) do
|
61
31
|
browser.window.maximize
|
62
32
|
end
|
@@ -72,4 +42,3 @@ module SpecHelper
|
|
72
42
|
end
|
73
43
|
end
|
74
44
|
end
|
75
|
-
<%- end -%>
|
data/lib/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.4
|
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.9.
|
4
|
+
version: 0.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Agustin Pequeno
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-07-
|
11
|
+
date: 2024-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -242,7 +242,6 @@ files:
|
|
242
242
|
- spec/integration/generators/rspec_generator_spec.rb
|
243
243
|
- spec/spec_helper.rb
|
244
244
|
- spec/support/settings_helper.rb
|
245
|
-
- spec/system/ruby_raider_spec.rb
|
246
245
|
homepage: https://github.com/RubyRaider/ruby_raider
|
247
246
|
licenses:
|
248
247
|
- MIT
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
require_relative '../spec_helper'
|
3
|
-
require_relative '../../lib/ruby_raider'
|
4
|
-
|
5
|
-
describe RubyRaider do
|
6
|
-
shared_examples 'execute web frameworks' do |name|
|
7
|
-
it 'runs the tests' do
|
8
|
-
if ENV['CI']
|
9
|
-
Dir.chdir(name) { system('gem install bundler && bundle install && raider u raid') }
|
10
|
-
else
|
11
|
-
Bundler.with_unbundled_env { Dir.chdir(name) { system('bundle exec raider u raid') } }
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
context 'with a Rspec and Selenium project' do
|
17
|
-
include_examples 'execute web frameworks', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[2]}"
|
18
|
-
end
|
19
|
-
|
20
|
-
context 'with a Rspec and Watir project' do
|
21
|
-
include_examples 'execute web frameworks', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[3]}"
|
22
|
-
end
|
23
|
-
|
24
|
-
context 'with a Cucumber and Selenium project' do
|
25
|
-
include_examples 'execute web frameworks', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[2]}"
|
26
|
-
end
|
27
|
-
|
28
|
-
context 'with a Cucumber and Watir project' do
|
29
|
-
include_examples 'execute web frameworks', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[3]}"
|
30
|
-
end
|
31
|
-
end
|