ruby_raider 3.12.1 → 4.0.0

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.
Files changed (227) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/runtime.yml +38 -0
  3. data/.github/workflows/system_tests.yml +1 -23
  4. data/.reek.yml +1 -0
  5. data/.rspec +1 -0
  6. data/Gemfile +2 -0
  7. data/README.md +17 -48
  8. data/RELEASE.md +22 -0
  9. data/bin/raider +5 -0
  10. data/lib/commands/scaffolding_commands.rb +2 -25
  11. data/lib/commands/utility_commands.rb +39 -3
  12. data/lib/generators/automation/automation_generator.rb +0 -5
  13. data/lib/generators/automation/templates/component.tt +1 -0
  14. data/lib/generators/automation/templates/home.tt +2 -2
  15. data/lib/generators/automation/templates/login.tt +6 -26
  16. data/lib/generators/automation/templates/page.tt +23 -18
  17. data/lib/generators/automation/templates/partials/home_page_selector.tt +1 -2
  18. data/lib/generators/automation/templates/partials/initialize_selector.tt +0 -8
  19. data/lib/generators/automation/templates/partials/pdp_page_selector.tt +1 -2
  20. data/lib/generators/automation/templates/partials/url_methods.tt +8 -2
  21. data/lib/generators/automation/templates/partials/visit_method.tt +0 -5
  22. data/lib/generators/automation/templates/pdp.tt +1 -9
  23. data/lib/generators/common_generator.rb +0 -2
  24. data/lib/generators/generator.rb +19 -17
  25. data/lib/generators/helper_generator.rb +25 -16
  26. data/lib/generators/infrastructure/templates/azure_pipelines.tt +1 -1
  27. data/lib/generators/infrastructure/templates/github.tt +2 -3
  28. data/lib/generators/infrastructure/templates/github_appium.tt +0 -8
  29. data/lib/generators/invoke_generators.rb +4 -23
  30. data/lib/generators/menu_generator.rb +1 -9
  31. data/lib/generators/rspec/templates/accessibility_spec.tt +1 -9
  32. data/lib/generators/rspec/templates/spec.tt +8 -24
  33. data/lib/generators/template_renderer/partial_cache.rb +3 -1
  34. data/lib/generators/template_renderer.rb +1 -1
  35. data/lib/generators/templates/common/gemfile.tt +3 -10
  36. data/lib/generators/templates/common/git_ignore.tt +0 -5
  37. data/lib/generators/templates/common/partials/mobile_config.tt +3 -1
  38. data/lib/generators/templates/common/partials/web_config.tt +17 -1
  39. data/lib/generators/templates/common/rakefile.tt +0 -15
  40. data/lib/generators/templates/common/read_me.tt +394 -242
  41. data/lib/generators/templates/common/rubocop.tt +0 -2
  42. data/lib/generators/templates/helpers/driver_helper.tt +30 -0
  43. data/lib/generators/templates/helpers/gesture_helper.tt +78 -0
  44. data/lib/generators/templates/helpers/network_helper.tt +521 -0
  45. data/lib/generators/templates/helpers/partials/quit_driver.tt +0 -2
  46. data/lib/generators/templates/helpers/partials/screenshot.tt +0 -2
  47. data/lib/generators/templates/helpers/partials/selenium_driver.tt +14 -1
  48. data/lib/generators/templates/helpers/screenshot_helper.tt +490 -0
  49. data/lib/generators/templates/helpers/spec_helper.tt +56 -27
  50. data/lib/generators/templates/helpers/trace_helper.tt +1242 -0
  51. data/lib/generators/templates/helpers/video_helper.tt +3 -8
  52. data/lib/ruby_raider/runtime/actionability.rb +129 -0
  53. data/lib/ruby_raider/runtime/actionable.rb +49 -0
  54. data/lib/ruby_raider/runtime/by_role.rb +55 -0
  55. data/lib/ruby_raider/runtime/config.rb +79 -0
  56. data/lib/ruby_raider/runtime/context.rb +38 -0
  57. data/lib/ruby_raider/runtime/errors.rb +69 -0
  58. data/lib/ruby_raider/runtime/finders.rb +73 -0
  59. data/lib/ruby_raider/runtime/js/actionability.js +134 -0
  60. data/lib/ruby_raider/runtime/js/role_engine.js +315 -0
  61. data/lib/ruby_raider/runtime/locator_converter.rb +72 -0
  62. data/lib/ruby_raider/runtime/matchers/base.rb +222 -0
  63. data/lib/ruby_raider/runtime/matchers/element.rb +183 -0
  64. data/lib/ruby_raider/runtime/matchers/page.rb +71 -0
  65. data/lib/ruby_raider/runtime/matchers/presence.rb +41 -0
  66. data/lib/ruby_raider/runtime/matchers/retrying_block.rb +104 -0
  67. data/lib/ruby_raider/runtime/observer.rb +170 -0
  68. data/lib/ruby_raider/runtime/role_finder.rb +83 -0
  69. data/lib/ruby_raider/runtime/rspec.rb +78 -0
  70. data/lib/ruby_raider/runtime/selectors.rb +60 -0
  71. data/lib/ruby_raider/runtime/strict.rb +142 -0
  72. data/lib/ruby_raider/runtime/wait.rb +84 -0
  73. data/lib/ruby_raider/runtime.rb +20 -0
  74. data/lib/scaffolding/name_normalizer.rb +1 -1
  75. data/lib/scaffolding/project_detector.rb +2 -28
  76. data/lib/scaffolding/scaffolding.rb +0 -20
  77. data/lib/scaffolding/templates/component.tt +0 -14
  78. data/lib/scaffolding/templates/page_object.tt +2 -14
  79. data/lib/scaffolding/templates/spec.tt +1 -9
  80. data/lib/utilities/utilities.rb +17 -8
  81. data/lib/version +1 -1
  82. data/ruby_raider.gemspec +3 -1
  83. data/sig/commands/scaffolding_commands.rbs +0 -2
  84. data/sig/commands/utility_commands.rbs +8 -0
  85. data/sig/generators/generator.rbs +4 -4
  86. data/sig/generators/helper_generator.rbs +1 -1
  87. data/sig/generators/menu_generator.rbs +0 -1
  88. data/sig/ruby_raider/runtime/actionability.rbs +25 -0
  89. data/sig/ruby_raider/runtime/actionable.rbs +13 -0
  90. data/sig/ruby_raider/runtime/by_role.rbs +15 -0
  91. data/sig/ruby_raider/runtime/config.rbs +26 -0
  92. data/sig/ruby_raider/runtime/context.rbs +12 -0
  93. data/sig/ruby_raider/runtime/errors.rbs +36 -0
  94. data/sig/ruby_raider/runtime/finders.rbs +26 -0
  95. data/sig/ruby_raider/runtime/locator_converter.rbs +21 -0
  96. data/sig/ruby_raider/runtime/matchers/base.rbs +64 -0
  97. data/sig/ruby_raider/runtime/matchers/element.rbs +78 -0
  98. data/sig/ruby_raider/runtime/matchers/page.rbs +38 -0
  99. data/sig/ruby_raider/runtime/matchers/presence.rbs +21 -0
  100. data/sig/ruby_raider/runtime/matchers/retrying_block.rbs +27 -0
  101. data/sig/ruby_raider/runtime/observer.rbs +46 -0
  102. data/sig/ruby_raider/runtime/role_finder.rbs +18 -0
  103. data/sig/ruby_raider/runtime/selectors.rbs +21 -0
  104. data/sig/ruby_raider/runtime/strict.rbs +35 -0
  105. data/sig/ruby_raider/runtime/wait.rbs +17 -0
  106. data/sig/ruby_raider/runtime.rbs +2 -0
  107. data/sig/scaffolding/project_detector.rbs +0 -4
  108. data/sig/scaffolding/scaffolding.rbs +0 -5
  109. data/sig/utilities/utilities.rbs +3 -1
  110. data/sig/vendor/selenium_webdriver.rbs +71 -0
  111. data/spec/commands/raider_commands_spec.rb +38 -3
  112. data/spec/commands/scaffolding_commands_spec.rb +27 -0
  113. data/spec/commands/utility_commands_spec.rb +53 -0
  114. data/spec/generators/fixtures/video_helper_stubs/selenium-webdriver.rb +11 -2
  115. data/spec/generators/gesture_helper_spec.rb +123 -0
  116. data/spec/generators/network_helper_spec.rb +634 -0
  117. data/spec/generators/screenshot_helper_spec.rb +776 -0
  118. data/spec/generators/template_renderer_spec.rb +0 -4
  119. data/spec/generators/trace_helper_spec.rb +1337 -0
  120. data/spec/generators/video_helper_spec.rb +0 -9
  121. data/spec/integration/commands/browser_update_after_creation_spec.rb +0 -8
  122. data/spec/integration/commands/scaffolding_commands_spec.rb +12 -70
  123. data/spec/integration/commands/utility_commands_spec.rb +19 -41
  124. data/spec/integration/content/azure_content_spec.rb +2 -6
  125. data/spec/integration/content/ci_content_spec.rb +1 -55
  126. data/spec/integration/content/common_content_spec.rb +1 -118
  127. data/spec/integration/content/config_content_spec.rb +52 -29
  128. data/spec/integration/content/gemfile_content_spec.rb +7 -72
  129. data/spec/integration/content/helper_content_spec.rb +158 -93
  130. data/spec/integration/content/page_content_spec.rb +85 -87
  131. data/spec/integration/content/readme_content_spec.rb +176 -71
  132. data/spec/integration/content/rspec_reporter_content_spec.rb +2 -2
  133. data/spec/integration/content/rubocop_content_spec.rb +1 -1
  134. data/spec/integration/content/syntax_validation_spec.rb +2 -2
  135. data/spec/integration/content/test_content_spec.rb +23 -147
  136. data/spec/integration/end_to_end_features_spec.rb +1 -43
  137. data/spec/integration/end_to_end_spec.rb +648 -292
  138. data/spec/integration/generators/automation_generator_spec.rb +3 -37
  139. data/spec/integration/generators/axe_addon_spec.rb +2 -35
  140. data/spec/integration/generators/azure_generator_spec.rb +1 -1
  141. data/spec/integration/generators/common_generator_spec.rb +1 -40
  142. data/spec/integration/generators/config_features_spec.rb +1 -24
  143. data/spec/integration/generators/github_generator_spec.rb +0 -12
  144. data/spec/integration/generators/helpers_generator_spec.rb +91 -71
  145. data/spec/integration/generators/invoke_generators_spec.rb +54 -45
  146. data/spec/integration/generators/rspec_generator_spec.rb +0 -6
  147. data/spec/integration/scaffolding_e2e_spec.rb +17 -179
  148. data/spec/integration/spec_helper.rb +4 -6
  149. data/spec/integration/trace_format_checker.rb +150 -0
  150. data/spec/integration/trace_page_server.rb +147 -0
  151. data/spec/menus/menu_generator_spec.rb +14 -39
  152. data/spec/runtime/actionability_spec.rb +207 -0
  153. data/spec/runtime/actionable_spec.rb +125 -0
  154. data/spec/runtime/browser/actionability_script_browser_spec.rb +150 -0
  155. data/spec/runtime/browser/actionable_browser_spec.rb +98 -0
  156. data/spec/runtime/browser/finders_browser_spec.rb +148 -0
  157. data/spec/runtime/browser/matchers_browser_spec.rb +67 -0
  158. data/spec/runtime/browser/retrying_block_browser_spec.rb +37 -0
  159. data/spec/runtime/browser/role_engine_browser_spec.rb +184 -0
  160. data/spec/runtime/browser/strict_browser_spec.rb +38 -0
  161. data/spec/runtime/by_role_spec.rb +52 -0
  162. data/spec/runtime/config_spec.rb +79 -0
  163. data/spec/runtime/context_spec.rb +73 -0
  164. data/spec/runtime/errors_spec.rb +89 -0
  165. data/spec/runtime/finders_spec.rb +165 -0
  166. data/spec/runtime/fixtures/actionability.html +70 -0
  167. data/spec/runtime/fixtures/locators.html +46 -0
  168. data/spec/runtime/fixtures/matchers.html +33 -0
  169. data/spec/runtime/fixtures/roles.html +162 -0
  170. data/spec/runtime/matchers/base_spec.rb +165 -0
  171. data/spec/runtime/matchers/element_spec.rb +277 -0
  172. data/spec/runtime/matchers/page_spec.rb +102 -0
  173. data/spec/runtime/matchers/presence_spec.rb +59 -0
  174. data/spec/runtime/matchers/retrying_block_spec.rb +165 -0
  175. data/spec/runtime/observer_spec.rb +341 -0
  176. data/spec/runtime/role_finder_spec.rb +156 -0
  177. data/spec/runtime/role_query_spec.rb +75 -0
  178. data/spec/runtime/selectors_spec.rb +135 -0
  179. data/spec/runtime/strict_spec.rb +257 -0
  180. data/spec/runtime/support/browser.rb +48 -0
  181. data/spec/runtime/support/fake_bridge.rb +117 -0
  182. data/spec/runtime/wait_spec.rb +71 -0
  183. data/spec/scaffolding/name_normalizer_spec.rb +3 -2
  184. data/spec/scaffolding/scaffold_project_detector_spec.rb +4 -43
  185. data/spec/system/selenium_spec.rb +1 -5
  186. data/spec/system/support/system_test_helper.rb +2 -5
  187. data/spec/utilities/headless_config_spec.rb +0 -7
  188. data/spec/utilities/trace_command_spec.rb +66 -0
  189. data/spec/utilities/utilities_spec.rb +24 -0
  190. metadata +134 -44
  191. data/lib/generators/automation/templates/header.tt +0 -9
  192. data/lib/generators/cucumber/cucumber_generator.rb +0 -58
  193. data/lib/generators/cucumber/templates/accessibility_feature.tt +0 -5
  194. data/lib/generators/cucumber/templates/accessibility_steps.tt +0 -17
  195. data/lib/generators/cucumber/templates/cucumber.tt +0 -1
  196. data/lib/generators/cucumber/templates/env.tt +0 -7
  197. data/lib/generators/cucumber/templates/feature.tt +0 -21
  198. data/lib/generators/cucumber/templates/partials/appium_env.tt +0 -26
  199. data/lib/generators/cucumber/templates/partials/driver_world.tt +0 -18
  200. data/lib/generators/cucumber/templates/partials/mobile_steps.tt +0 -20
  201. data/lib/generators/cucumber/templates/partials/selenium_env.tt +0 -56
  202. data/lib/generators/cucumber/templates/partials/watir_env.tt +0 -48
  203. data/lib/generators/cucumber/templates/partials/watir_world.tt +0 -4
  204. data/lib/generators/cucumber/templates/partials/web_steps.tt +0 -28
  205. data/lib/generators/cucumber/templates/steps.tt +0 -5
  206. data/lib/generators/cucumber/templates/user_factory.tt +0 -15
  207. data/lib/generators/cucumber/templates/world.tt +0 -7
  208. data/lib/generators/templates/helpers/browser_helper.tt +0 -31
  209. data/lib/generators/templates/helpers/raider_element.tt +0 -159
  210. data/lib/generators/templates/helpers/wait_helper.tt +0 -470
  211. data/lib/scaffolding/templates/feature.tt +0 -6
  212. data/lib/scaffolding/templates/steps.tt +0 -19
  213. data/sig/generators/cucumber/cucumber_generator.rbs +0 -12
  214. data/spec/fixtures/watir_master/cucumber_watir/Readme.md.snapshot +0 -175
  215. data/spec/fixtures/watir_master/cucumber_watir/features/step_definitions/login_steps.rb.snapshot +0 -24
  216. data/spec/fixtures/watir_master/cucumber_watir/page_objects/abstract/page.rb.snapshot +0 -37
  217. data/spec/fixtures/watir_master/cucumber_watir/page_objects/pages/login.rb.snapshot +0 -33
  218. data/spec/fixtures/watir_master/rspec_watir/Readme.md.snapshot +0 -174
  219. data/spec/fixtures/watir_master/rspec_watir/page_objects/abstract/page.rb.snapshot +0 -37
  220. data/spec/fixtures/watir_master/rspec_watir/page_objects/pages/login.rb.snapshot +0 -33
  221. data/spec/fixtures/watir_master/rspec_watir/spec/login_page_spec.rb.snapshot +0 -49
  222. data/spec/integration/content/cucumber_reporter_content_spec.rb +0 -110
  223. data/spec/integration/generators/cucumber_generator_spec.rb +0 -100
  224. data/spec/integration/helpers/wait_helper_mobile_spec.rb +0 -281
  225. data/spec/integration/helpers/wait_helper_spec.rb +0 -496
  226. data/spec/integration/helpers/wait_helper_support.rb +0 -183
  227. data/spec/system/watir_spec.rb +0 -38
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../../page_objects/pages/account'
4
- require_relative '../../page_objects/pages/login'
5
-
6
- Given("I'm a {user} on the login page") do |user|
7
- @user = user
8
- @login_page = Login.new(browser)
9
- @login_page.visit
10
- end
11
-
12
- Given("I'm a {user}") do |user|
13
- @user = user
14
- end
15
-
16
- When('I login with my credentials') do
17
- @login_page.login(@user['username'], @user['password'])
18
- end
19
-
20
- Then("I'm logged in") do
21
- account_page = Account.new(browser)
22
- account_page.visit
23
- expect(account_page.header.customer_name).to eq "Welcome back #{@user['name']}"
24
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../components/header'
4
-
5
- class Page
6
- attr_reader :browser
7
-
8
- def initialize(browser)
9
- @browser = browser
10
- end
11
-
12
- def visit(*page)
13
- @browser.goto full_url(page.first)
14
- end
15
-
16
- def full_url(*page)
17
- "#{base_url}#{url(*page)}"
18
- end
19
-
20
- def base_url
21
- YAML.load_file('config/config.yml')['url']
22
- end
23
-
24
- def url(_page)
25
- raise 'Url must be defined on child pages'
26
- end
27
-
28
- def to_s
29
- self.class.to_s.sub('Page', ' Page')
30
- end
31
-
32
- # Components
33
-
34
- def header
35
- Header.new(browser.element(css: '.welcome-msg'))
36
- end
37
- end
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../abstract/page'
4
-
5
- class Login < Page
6
- def url(_page)
7
- 'index.php?rt=account/login'
8
- end
9
-
10
- # Actions
11
-
12
- def login(username, password)
13
- username_field.set username
14
- password_field.set password
15
- login_button.click
16
- end
17
-
18
- private
19
-
20
- # Elements
21
-
22
- def username_field
23
- browser.text_field(id: 'loginFrm_loginname')
24
- end
25
-
26
- def password_field
27
- browser.text_field(id: 'loginFrm_password')
28
- end
29
-
30
- def login_button
31
- browser.button(xpath: "//button[@title='Login']")
32
- end
33
- end
@@ -1,174 +0,0 @@
1
- # Ruby Raider
2
-
3
- <!-- PROJECT LOGO -->
4
- <br />
5
- <div align="center">
6
- <a href="https://github.com/RubyRaider/ruby_raider">
7
- <img src="https://www.ruby-raider.com/assets/icon-DYY74ofR.png" alt="Logo" style="width:200px;">
8
- </a>
9
- <p align="center">
10
- <a href="https://github.com/RubyRaider/ruby_raider#getting-started"><strong>Explore the docs</strong></a>
11
- <br />
12
- <br />
13
- <a href="https://rubygems.org/gems/ruby_raider">Rubygems</a>
14
- ·
15
- <a href="https://github.com/RubyRaider/ruby_raider/issues">Report Bug</a>
16
- ·
17
- <a href="https://github.com/RubyRaider/ruby_raider/issues">Request Feature</a>
18
- </p>
19
- <p align="center"> For more information and updates on releases, see <a href="https://ruby-raider.com">https://ruby-raider.com</a></p>
20
- </div>
21
-
22
- > **Deprecated:** Watir is deprecated and will be removed in the next major version of ruby_raider; new projects should use Selenium. Watir is only available through `-p automation:watir`. See [Migrating from Watir](https://github.com/RaiderHQ/ruby_raider#migrating-from-watir).
23
-
24
- ## What is Ruby Raider?
25
-
26
- Ruby Raider is a generator and scaffolding gem to make UI test automation easier.
27
-
28
- ### Supported Frameworks
29
-
30
- | Web Testing Framework | Mobile Testing Framework |
31
- |-----------------------|------------------------------------|
32
- | Cucumber and Selenium | Cucumber and Appium for iOS |
33
- | RSpec and Selenium | RSpec and Appium for iOS |
34
- | Cucumber and Watir | Cucumber and Appium for Android |
35
- | RSpec and Watir | RSpec and Appium for Android |
36
- | | Cucumber and Appium Cross-platform |
37
- | | RSpec and Appium Cross-platform |
38
-
39
- **Optional add-on for web projects:**
40
- - **Accessibility testing (axe)**: `--accessibility` flag
41
-
42
- ***The web tests run against the [Raider Test Store](https://raider-test-site.onrender.com/).***
43
-
44
- ***To run Appium tests, download the example [app](https://github.com/RaiderHQ/raider_test_app) and start the server:***
45
-
46
- ```bash
47
- raider u start_appium
48
- ```
49
-
50
- This works on all platforms (Mac OS, Linux and Windows).
51
-
52
- ## Getting Started
53
-
54
- ```bash
55
- gem install ruby_raider
56
- raider new [name_of_project]
57
- ```
58
-
59
- Or with parameters:
60
-
61
- ```bash
62
- raider new [name_of_project] -p framework:[framework] automation:[automation_type]
63
- ```
64
-
65
- ### Commands
66
-
67
- ```
68
- raider generate # Scaffolding commands
69
- raider utility # Utility commands
70
- raider new [NAME] # Create new project
71
- raider version # Show version
72
- raider help [COMMAND] # Describe commands
73
- ```
74
-
75
- Shortcuts: `g` (generate), `n` (new), `u` (utility), `v` (version)
76
-
77
- ### Scaffolding
78
-
79
- ```
80
- raider g page [NAME] # Create page object
81
- raider g spec [NAME] # Create RSpec test
82
- raider g feature [NAME] # Create Cucumber feature
83
- raider g steps [NAME] # Create step definitions
84
- raider g scaffold [NAME] # Create page + test + steps
85
- ```
86
-
87
- ## Reusing the login
88
-
89
- Tag an example `:logged_in` (RSpec) or a scenario `@logged_in` (Cucumber) and the suite logs in once, saves the
90
- session, and restores it for the next tagged example or run instead of filling in the login form again. The generated
91
- account example shows it. If the saved session no longer works, the real login runs again and the state is saved anew.
92
-
93
- For another role, call it yourself with its own name:
94
-
95
- ```ruby
96
- SessionState.new(driver, name: 'admin').reuse(valid: -> { dashboard.tap(&:visit).admin? }) do
97
- # the real login for the admin
98
- end
99
- ```
100
-
101
- With Watir, pass `browser.driver`, the Selenium driver underneath the browser.
102
-
103
- - `login_state: max_age:` in `config/config.yml` is how many seconds a saved login stays valid (default 3600).
104
- - `RAIDER_LOGIN_STATE=off` always does the real login and saves nothing; `RAIDER_LOGIN_STATE=refresh` ignores the saved
105
- file, logs in and saves again.
106
- - The state lives in `.raider/auth/` and is git-ignored. It holds live session tokens, so it must not be committed,
107
- cached or uploaded as a CI artifact. Nothing in it is ever printed.
108
-
109
- ## Reporting
110
-
111
- Every run writes machine-readable results to `raider-results/` (including `run.json`) and a browsable report,
112
- `raider-results/index.html`. Open it in a browser after a run; `bundle exec raider-reporter report` rebuilds it.
113
-
114
- To upload runs to Raider, set these environment variables before running the suite.
115
- `RAIDER_TOKEN` and `RAIDER_ENDPOINT` come from your Raider Hideout server (its setup page, or `bin/rails hideout:setup` /
116
- `hideout:token`):
117
-
118
- ```bash
119
- export RAIDER_TOKEN=your-token
120
- export RAIDER_ENDPOINT=https://hideout.example.com
121
- ```
122
-
123
- Without `RAIDER_TOKEN`, nothing is uploaded and the suite output is unchanged. Failure screenshots are attached to the
124
- report and to Raider. See the [raider_reporter README](https://github.com/RaiderHQ/raider_reporter) for details.
125
-
126
- ### Video replay
127
-
128
- Every test is recorded, and the video is kept only for failing tests (on the last retry attempt). It is attached
129
- to the report as `video` and saved under `raider-results/attachments/`, next to the failure screenshot.
130
- The video is a `video.webm` built from page screenshots with ffmpeg.
131
-
132
- - Video is on by default: `video:` in `config/config.yml` (`enabled: true`, `fps: 5`, `max_width: 1280`).
133
- - Turn it off for one run with `VIDEO=off bundle exec rspec`, or for the project with
134
- `raider u video off` (`raider u video on` turns it back on).
135
- - ffmpeg is downloaded on first use, checked against a pinned SHA-256 and cached in `~/.cache/raider`
136
- (`%LOCALAPPDATA%\raider` on Windows). `raider u video install` downloads it ahead of time (CI does this before the
137
- tests and caches the folder), and `raider u video status` prints the binary in use.
138
- - `RAIDER_FFMPEG_PATH` uses your own ffmpeg (it needs libvpx) instead of the download, and `RAIDER_CACHE_DIR` moves
139
- the cache.
140
- - The RaiderHQ `ffmpeg-7.1` release that the download comes from is not published yet. Until it is, set
141
- `RAIDER_FFMPEG_PATH` to get videos; without it the suite runs as usual and prints one `[video]` line.
142
- - If ffmpeg is missing or recording fails, the suite still runs and its exit code is unchanged; you get one `[video]`
143
- line on stderr and no video.
144
- - Known limits: a frame is taken after each page load, click and text change, plus one at the end of a failing test,
145
- so changes the page makes on its own between actions show up in the next frame. There is one recorded driver per
146
- process.
147
-
148
- ### Quarantine
149
-
150
- CI runs the suite through `bundle exec raider-reporter exec -- …` with `RAIDER_QUARANTINE` set. Tests quarantined in
151
- Raider still run and are still reported (as `quarantined`), and a build whose only failures are quarantined stays green.
152
- Local runs keep quarantine off. To turn it off in CI, remove `RAIDER_QUARANTINE` from the pipeline.
153
-
154
- ### Quality gate
155
-
156
- The `raider-gate` CI job runs `bundle exec raider-reporter gate` after the tests and
157
- fails the pipeline when the Raider quality gate fails. It is off until you turn it on:
158
-
159
- - set the CI variable `RAIDER_GATE=1` (a repository variable under Settings → Secrets and variables → Actions → Variables);
160
- - turn on rules under the project's Gate page in Raider: a minimum pass rate, no new failures against the default
161
- branch, no new flaky tests;
162
- - optionally require the `raider/gate` check in branch protection.
163
-
164
- `raider-reporter gate` exits 1 when the gate fails, naming the failed rules, and 2 when it gets no verdict (timeout,
165
- Raider unreachable, token rejected, build not found). `RAIDER_GATE_TIMEOUT` sets how long it waits, in seconds
166
- (default 600). The job stays off by default because a project without `RAIDER_TOKEN`, or a pull request from a fork,
167
- would exit 2 on every run.
168
-
169
- Parallel test jobs that upload to one build must each set `RAIDER_SHARD_TOTAL` (the number of jobs) and
170
- `RAIDER_SHARD_INDEX` (1 to that number), so the gate waits for all of them instead of judging the first one to finish.
171
-
172
- ### Sponsors
173
-
174
- This project is tested with BrowserStack.
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../components/header'
4
-
5
- class Page
6
- attr_reader :browser
7
-
8
- def initialize(browser)
9
- @browser = browser
10
- end
11
-
12
- def visit(*page)
13
- @browser.goto full_url(page.first)
14
- end
15
-
16
- def full_url(*page)
17
- "#{base_url}#{url(*page)}"
18
- end
19
-
20
- def base_url
21
- YAML.load_file('config/config.yml')['url']
22
- end
23
-
24
- def url(_page)
25
- raise 'Url must be defined on child pages'
26
- end
27
-
28
- def to_s
29
- self.class.to_s.sub('Page', ' Page')
30
- end
31
-
32
- # Components
33
-
34
- def header
35
- Header.new(browser.element(css: '.welcome-msg'))
36
- end
37
- end
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../abstract/page'
4
-
5
- class Login < Page
6
- def url(_page)
7
- 'index.php?rt=account/login'
8
- end
9
-
10
- # Actions
11
-
12
- def login(username, password)
13
- username_field.set username
14
- password_field.set password
15
- login_button.click
16
- end
17
-
18
- private
19
-
20
- # Elements
21
-
22
- def username_field
23
- browser.text_field(id: 'loginFrm_loginname')
24
- end
25
-
26
- def password_field
27
- browser.text_field(id: 'loginFrm_password')
28
- end
29
-
30
- def login_button
31
- browser.button(xpath: "//button[@title='Login']")
32
- end
33
- end
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../helpers/spec_helper'
4
- require_relative '../models/model_factory'
5
- require_relative '../page_objects/pages/account'
6
- require_relative '../page_objects/pages/login'
7
-
8
- # rubocop:disable RSpec/MultipleDescribes
9
- describe 'Login' do
10
- subject(:header) { account_page.header.customer_name }
11
-
12
- let(:user) { ModelFactory.for('users')['registered user'] }
13
- let(:login_page) { Login.new(browser) }
14
- let(:account_page) { Account.new(browser) }
15
-
16
- before do
17
- login_page.visit
18
- login_page.login(user['username'], password)
19
- end
20
-
21
- context 'with right credentials' do
22
- let(:password) { user['password'] }
23
-
24
- it 'can successfully log in' do
25
- account_page.visit
26
- expect(header).to eq "Welcome back #{user['name']}"
27
- end
28
- end
29
-
30
- context 'with wrong credentials' do
31
- let(:password) { 'wrongPassword' }
32
-
33
- it 'cannot log in' do
34
- login_page.visit
35
- expect(header).to eq 'Login or register'
36
- end
37
- end
38
- end
39
-
40
- describe 'Account', :logged_in do
41
- let(:user) { ModelFactory.for('users')['registered user'] }
42
- let(:account_page) { Account.new(browser) }
43
-
44
- it 'opens the account page with the saved login' do
45
- account_page.visit
46
- expect(account_page.header.customer_name).to eq "Welcome back #{user['name']}"
47
- end
48
- end
49
- # rubocop:enable RSpec/MultipleDescribes
@@ -1,110 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'content_helper'
4
-
5
- describe 'Cucumber raider_reporter wiring' do
6
- screenshot_calls = {
7
- 'selenium' => 'driver.save_screenshot(screenshot_path)',
8
- 'watir' => 'browser.screenshot.save(screenshot_path)'
9
- }
10
-
11
- AUTOMATION_TYPES.each do |automation|
12
- context "with cucumber and #{automation}" do
13
- let(:project_name) { "#{FrameworkIndex::CUCUMBER}_#{automation}" }
14
- let(:env) { read_generated(project_name, 'features/support/env.rb') }
15
- let(:screenshot_call) { screenshot_calls.fetch(automation, 'driver.screenshot(screenshot_path)') }
16
- let(:hook) { env[/^\s*After do.*\z/m] }
17
- let(:quit_call) { automation == 'watir' ? 'browser.quit' : 'driver.quit' }
18
-
19
- it 'activates the reporter by requiring raider_reporter/cucumber' do
20
- expect(env).to include("require 'raider_reporter/cucumber'")
21
- end
22
-
23
- it 'does not reference the allure helper' do
24
- expect(env).not_to match(/AllureHelper|allure_helper/)
25
- end
26
-
27
- it 'takes the screenshot only for failed scenarios, inside the guard block' do
28
- guarded = /if scenario\.failed\?\n\s+Dir\.mktmpdir do \|temp_folder\|\n(?<body>.*?)\n\s+end\n\s+end\nensure/m
29
- expect(hook.match(guarded)[:body]).to include(screenshot_call)
30
- end
31
-
32
- it 'uses a fixed file name in the tmpdir, never the scenario name' do
33
- expect(env).to include("screenshot_path = File.join(temp_folder, 'screenshot.png')")
34
- expect(hook).not_to include('scenario.name')
35
- end
36
-
37
- it 'quits the driver in an ensure of the After block, without a redundant begin' do
38
- quit = %w[android ios cross_platform].include?(automation) ? 'driver.quit_driver' : quit_call
39
- expect(hook).to match(/^\s*After do \|scenario\|\n.*\n^ensure\n.*\n\s+#{Regexp.escape(quit)}\nend/m)
40
- expect(hook).not_to match(/^\s+begin$/)
41
- end
42
-
43
- it 'attaches the screenshot path before quitting the driver' do
44
- attach = "RaiderReporter.attach('screenshot', screenshot_path, type: :png)"
45
- expect(env).to include(attach)
46
- expect(env.index(screenshot_call)).to be < env.index(attach)
47
- expect(env.index(attach)).to be < env.index(/driver\.quit|browser\.quit/, env.index(attach))
48
- end
49
-
50
- context 'with video recording' do
51
- target = automation == 'watir' ? 'browser' : 'driver'
52
- video_type = %w[selenium watir].include?(automation) ? ':webm' : ':mp4'
53
-
54
- it 'requires video_helper' do
55
- expect(env).to include("require_relative '../../helpers/video_helper'")
56
- end
57
-
58
- it 'starts the recorder in Before' do
59
- expect(env[/^Before do.*?^end$/m]).to include("@video_recorder = VideoHelper.recorder_for(#{target})", '@video_recorder.start')
60
- end
61
-
62
- it 'stops with keep: scenario.failed? before quitting, attaches the path and cleans up in the ensure' do
63
- expect(hook).to include('video_path = @video_recorder&.stop(keep: scenario.failed?)')
64
- expect(hook).to include("RaiderReporter.attach('video', video_path, type: #{video_type}) if video_path")
65
- expect(hook.index('@video_recorder&.stop')).to be < hook.index("RaiderReporter.attach('video'")
66
- expect(hook.index("RaiderReporter.attach('video'")).to be < hook.index(/^ensure/)
67
- expect(hook.index(/^ensure/)).to be < hook.index('@video_recorder&.cleanup')
68
- end
69
- end
70
-
71
- it 'does not generate the allure helper' do
72
- expect(File).not_to exist(File.join(project_name, 'helpers/allure_helper.rb'))
73
- end
74
-
75
- it 'does not mention Allure in any generated file' do
76
- files = Dir.glob("#{project_name}/**/*", File::FNM_DOTMATCH).select { |f| File.file?(f) }
77
- expect(files.select { |f| File.read(f).match?(/allure/i) }).to be_empty
78
- end
79
-
80
- it 'does not create an allure-results folder' do
81
- expect(File).not_to exist(File.join(project_name, 'allure-results'))
82
- end
83
- end
84
- end
85
- end
86
-
87
- describe 'Cucumber login reuse wiring' do
88
- { 'selenium' => 'driver', 'watir' => 'browser.driver' }.each do |automation, target|
89
- context "with cucumber and #{automation}" do
90
- let(:env) { read_generated("#{FrameworkIndex::CUCUMBER}_#{automation}", 'features/support/env.rb') }
91
-
92
- it 'requires session_state' do
93
- expect(env).to include("require_relative '../../helpers/session_state'")
94
- end
95
-
96
- it "reuses the saved login in Before('@logged_in'), defined after the plain Before" do
97
- expect(env).to include("Before('@logged_in') do", "SessionState.new(#{target}).reuse(",
98
- "UserFactory.for('registered user')")
99
- expect(env.index("Before('@logged_in')")).to be > env.index(/^Before do/)
100
- end
101
- end
102
- end
103
-
104
- %w[android ios cross_platform].each do |automation|
105
- it "does not mention session_state with cucumber and #{automation}" do
106
- env = read_generated("#{FrameworkIndex::CUCUMBER}_#{automation}", 'features/support/env.rb')
107
- expect(env).not_to include('session_state')
108
- end
109
- end
110
- end
@@ -1,100 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../../../lib/generators/cucumber/cucumber_generator'
4
- require_relative '../spec_helper'
5
-
6
- describe CucumberGenerator do
7
- shared_examples 'creates cucumber files' do |project_name, file_name|
8
- it 'creates a feature file' do
9
- expect(File).to exist("#{project_name}/features/#{file_name}.feature")
10
- end
11
-
12
- it 'creates a step definitions file' do
13
- expect(File).to exist("#{project_name}/features/step_definitions/#{file_name}_steps.rb")
14
- end
15
-
16
- it 'creates an env file' do
17
- expect(File).to exist("#{project_name}/features/support/env.rb")
18
- end
19
-
20
- it 'creates an cucumber.yml file' do
21
- expect(File).to exist("#{project_name}/cucumber.yml")
22
- end
23
-
24
- it 'does not create a spec file' do
25
- expect(File).not_to exist("#{project_name}/spec/home_spec.rb")
26
- end
27
- end
28
-
29
- shared_examples 'creates factories for web projects' do |project_name|
30
- it 'creates an data file' do
31
- expect(File).to exist("#{project_name}/models/data/users.yml")
32
- end
33
-
34
- it 'creates a model factory' do
35
- expect(File).to exist("#{project_name}/models/model_factory.rb")
36
- end
37
-
38
- it 'creates a user factory' do
39
- expect(File).to exist("#{project_name}/models/user_factory.rb")
40
- end
41
- end
42
-
43
- context 'with cucumber and appium android' do
44
- include_examples 'creates cucumber files', "#{FrameworkIndex::CUCUMBER}_#{AutomationIndex::ANDROID}", 'home'
45
- end
46
-
47
- context 'with cucumber and appium ios' do
48
- include_examples 'creates cucumber files', "#{FrameworkIndex::CUCUMBER}_#{AutomationIndex::IOS}", 'home'
49
- end
50
-
51
- context 'with cucumber and appium cross platform' do
52
- include_examples 'creates cucumber files', "#{FrameworkIndex::CUCUMBER}_#{AutomationIndex::CROSS_PLATFORM}", 'home'
53
- end
54
-
55
- context 'with cucumber and selenium' do
56
- include_examples 'creates cucumber files', "#{FrameworkIndex::CUCUMBER}_#{AutomationIndex::SELENIUM}", 'login'
57
- include_examples 'creates factories for web projects', "#{FrameworkIndex::CUCUMBER}_#{AutomationIndex::SELENIUM}", 'login'
58
- end
59
-
60
- context 'with cucumber and watir' do
61
- include_examples 'creates cucumber files', "#{FrameworkIndex::CUCUMBER}_#{AutomationIndex::WATIR}", 'login'
62
- include_examples 'creates factories for web projects', "#{FrameworkIndex::CUCUMBER}_#{AutomationIndex::WATIR}", 'login'
63
- end
64
-
65
- describe 'without example tests' do
66
- %w[selenium ios cross_platform].each do |automation|
67
- context "with cucumber and #{automation}" do
68
- let(:name) { ensure_project(framework: 'cucumber', automation:, examples: false) }
69
-
70
- it 'creates no feature files' do
71
- expect(Dir.glob("#{name}/features/**/*.feature")).to be_empty
72
- end
73
-
74
- it 'keeps an empty step_definitions folder' do
75
- expect(Dir.children("#{name}/features/step_definitions")).to eq(['.keep'])
76
- end
77
-
78
- it 'creates the support files' do
79
- expect(Dir.children("#{name}/features/support")).to contain_exactly('env.rb', 'world.rb')
80
- end
81
-
82
- it 'creates the cucumber.yml file' do
83
- expect(File).to exist("#{name}/cucumber.yml")
84
- end
85
-
86
- it 'creates no user factory' do
87
- expect(File).not_to exist("#{name}/models/user_factory.rb")
88
- end
89
- end
90
- end
91
-
92
- it 'creates no accessibility example' do
93
- InvokeGenerators.generate_framework(framework: 'cucumber', automation: 'selenium', name: 'skeleton_axe_cucumber',
94
- examples: false, accessibility: true)
95
- expect(Dir.glob('skeleton_axe_cucumber/features/**/accessibility*')).to be_empty
96
- ensure
97
- FileUtils.rm_rf('skeleton_axe_cucumber')
98
- end
99
- end
100
- end