ruby_raider 3.13.0 → 4.0.1

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 (239) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ffmpeg/build.sh +208 -0
  3. data/.github/ffmpeg/check.sh +72 -0
  4. data/.github/ffmpeg/frames.rb +34 -0
  5. data/.github/ffmpeg/probe.sh +17 -0
  6. data/.github/workflows/ffmpeg.yml +160 -0
  7. data/.github/workflows/runtime.yml +38 -0
  8. data/.github/workflows/system_tests.yml +1 -23
  9. data/.reek.yml +1 -0
  10. data/.rspec +1 -0
  11. data/Gemfile +2 -0
  12. data/README.md +172 -70
  13. data/RELEASE.md +29 -0
  14. data/bin/raider +5 -0
  15. data/lib/commands/scaffolding_commands.rb +2 -25
  16. data/lib/commands/utility_commands.rb +23 -3
  17. data/lib/generators/automation/automation_generator.rb +0 -5
  18. data/lib/generators/automation/templates/component.tt +1 -0
  19. data/lib/generators/automation/templates/home.tt +2 -2
  20. data/lib/generators/automation/templates/login.tt +6 -26
  21. data/lib/generators/automation/templates/page.tt +23 -18
  22. data/lib/generators/automation/templates/partials/home_page_selector.tt +1 -2
  23. data/lib/generators/automation/templates/partials/initialize_selector.tt +0 -8
  24. data/lib/generators/automation/templates/partials/pdp_page_selector.tt +1 -2
  25. data/lib/generators/automation/templates/partials/url_methods.tt +8 -2
  26. data/lib/generators/automation/templates/partials/visit_method.tt +0 -5
  27. data/lib/generators/automation/templates/pdp.tt +1 -9
  28. data/lib/generators/common_generator.rb +0 -2
  29. data/lib/generators/generator.rb +12 -19
  30. data/lib/generators/helper_generator.rb +21 -19
  31. data/lib/generators/infrastructure/templates/azure_pipelines.tt +1 -1
  32. data/lib/generators/infrastructure/templates/github.tt +2 -3
  33. data/lib/generators/infrastructure/templates/github_appium.tt +0 -8
  34. data/lib/generators/invoke_generators.rb +4 -23
  35. data/lib/generators/menu_generator.rb +1 -9
  36. data/lib/generators/rspec/templates/accessibility_spec.tt +1 -9
  37. data/lib/generators/rspec/templates/spec.tt +8 -24
  38. data/lib/generators/template_renderer/partial_cache.rb +3 -1
  39. data/lib/generators/template_renderer.rb +1 -1
  40. data/lib/generators/templates/common/gemfile.tt +3 -10
  41. data/lib/generators/templates/common/git_ignore.tt +0 -5
  42. data/lib/generators/templates/common/partials/mobile_config.tt +3 -1
  43. data/lib/generators/templates/common/partials/web_config.tt +10 -1
  44. data/lib/generators/templates/common/rakefile.tt +0 -15
  45. data/lib/generators/templates/common/read_me.tt +363 -257
  46. data/lib/generators/templates/common/rubocop.tt +0 -2
  47. data/lib/generators/templates/helpers/driver_helper.tt +8 -0
  48. data/lib/generators/templates/helpers/gesture_helper.tt +78 -0
  49. data/lib/generators/templates/helpers/network_helper.tt +521 -0
  50. data/lib/generators/templates/helpers/partials/quit_driver.tt +0 -2
  51. data/lib/generators/templates/helpers/partials/screenshot.tt +0 -2
  52. data/lib/generators/templates/helpers/partials/selenium_driver.tt +5 -2
  53. data/lib/generators/templates/helpers/screenshot_helper.tt +490 -0
  54. data/lib/generators/templates/helpers/spec_helper.tt +39 -29
  55. data/lib/generators/templates/helpers/trace_helper.tt +240 -95
  56. data/lib/generators/templates/helpers/video_helper.tt +4 -10
  57. data/lib/ruby_raider/ffmpeg.rb +38 -11
  58. data/lib/ruby_raider/runtime/actionability.rb +129 -0
  59. data/lib/ruby_raider/runtime/actionable.rb +49 -0
  60. data/lib/ruby_raider/runtime/by_role.rb +55 -0
  61. data/lib/ruby_raider/runtime/config.rb +79 -0
  62. data/lib/ruby_raider/runtime/context.rb +38 -0
  63. data/lib/ruby_raider/runtime/errors.rb +69 -0
  64. data/lib/ruby_raider/runtime/finders.rb +73 -0
  65. data/lib/ruby_raider/runtime/js/actionability.js +134 -0
  66. data/lib/ruby_raider/runtime/js/role_engine.js +315 -0
  67. data/lib/ruby_raider/runtime/locator_converter.rb +72 -0
  68. data/lib/ruby_raider/runtime/matchers/base.rb +222 -0
  69. data/lib/ruby_raider/runtime/matchers/element.rb +183 -0
  70. data/lib/ruby_raider/runtime/matchers/page.rb +71 -0
  71. data/lib/ruby_raider/runtime/matchers/presence.rb +41 -0
  72. data/lib/ruby_raider/runtime/matchers/retrying_block.rb +104 -0
  73. data/lib/ruby_raider/runtime/observer.rb +170 -0
  74. data/lib/ruby_raider/runtime/role_finder.rb +83 -0
  75. data/lib/ruby_raider/runtime/rspec.rb +78 -0
  76. data/lib/ruby_raider/runtime/selectors.rb +60 -0
  77. data/lib/ruby_raider/runtime/strict.rb +142 -0
  78. data/lib/ruby_raider/runtime/wait.rb +84 -0
  79. data/lib/ruby_raider/runtime.rb +20 -0
  80. data/lib/scaffolding/name_normalizer.rb +1 -1
  81. data/lib/scaffolding/project_detector.rb +2 -28
  82. data/lib/scaffolding/scaffolding.rb +0 -20
  83. data/lib/scaffolding/templates/component.tt +0 -14
  84. data/lib/scaffolding/templates/page_object.tt +2 -14
  85. data/lib/scaffolding/templates/spec.tt +1 -9
  86. data/lib/utilities/utilities.rb +10 -8
  87. data/lib/version +1 -1
  88. data/ruby_raider.gemspec +2 -1
  89. data/sig/commands/scaffolding_commands.rbs +0 -2
  90. data/sig/commands/utility_commands.rbs +6 -0
  91. data/sig/generators/generator.rbs +0 -4
  92. data/sig/generators/helper_generator.rbs +0 -1
  93. data/sig/generators/menu_generator.rbs +0 -1
  94. data/sig/ruby_raider/ffmpeg.rbs +1 -0
  95. data/sig/ruby_raider/runtime/actionability.rbs +25 -0
  96. data/sig/ruby_raider/runtime/actionable.rbs +13 -0
  97. data/sig/ruby_raider/runtime/by_role.rbs +15 -0
  98. data/sig/ruby_raider/runtime/config.rbs +26 -0
  99. data/sig/ruby_raider/runtime/context.rbs +12 -0
  100. data/sig/ruby_raider/runtime/errors.rbs +36 -0
  101. data/sig/ruby_raider/runtime/finders.rbs +26 -0
  102. data/sig/ruby_raider/runtime/locator_converter.rbs +21 -0
  103. data/sig/ruby_raider/runtime/matchers/base.rbs +64 -0
  104. data/sig/ruby_raider/runtime/matchers/element.rbs +78 -0
  105. data/sig/ruby_raider/runtime/matchers/page.rbs +38 -0
  106. data/sig/ruby_raider/runtime/matchers/presence.rbs +21 -0
  107. data/sig/ruby_raider/runtime/matchers/retrying_block.rbs +27 -0
  108. data/sig/ruby_raider/runtime/observer.rbs +46 -0
  109. data/sig/ruby_raider/runtime/role_finder.rbs +18 -0
  110. data/sig/ruby_raider/runtime/selectors.rbs +21 -0
  111. data/sig/ruby_raider/runtime/strict.rbs +35 -0
  112. data/sig/ruby_raider/runtime/wait.rbs +17 -0
  113. data/sig/ruby_raider/runtime.rbs +2 -0
  114. data/sig/scaffolding/project_detector.rbs +0 -4
  115. data/sig/scaffolding/scaffolding.rbs +0 -5
  116. data/sig/utilities/utilities.rbs +2 -1
  117. data/sig/vendor/selenium_webdriver.rbs +71 -0
  118. data/spec/commands/raider_commands_spec.rb +38 -3
  119. data/spec/commands/scaffolding_commands_spec.rb +27 -0
  120. data/spec/commands/utility_commands_spec.rb +53 -0
  121. data/spec/generators/gesture_helper_spec.rb +123 -0
  122. data/spec/generators/network_helper_spec.rb +634 -0
  123. data/spec/generators/screenshot_helper_spec.rb +776 -0
  124. data/spec/generators/template_renderer_spec.rb +0 -4
  125. data/spec/generators/trace_helper_spec.rb +489 -97
  126. data/spec/generators/video_helper_spec.rb +21 -13
  127. data/spec/integration/commands/browser_update_after_creation_spec.rb +0 -8
  128. data/spec/integration/commands/scaffolding_commands_spec.rb +12 -70
  129. data/spec/integration/commands/utility_commands_spec.rb +19 -41
  130. data/spec/integration/content/azure_content_spec.rb +2 -6
  131. data/spec/integration/content/ci_content_spec.rb +1 -55
  132. data/spec/integration/content/common_content_spec.rb +1 -118
  133. data/spec/integration/content/config_content_spec.rb +34 -31
  134. data/spec/integration/content/gemfile_content_spec.rb +7 -72
  135. data/spec/integration/content/helper_content_spec.rb +105 -99
  136. data/spec/integration/content/page_content_spec.rb +85 -87
  137. data/spec/integration/content/readme_content_spec.rb +141 -77
  138. data/spec/integration/content/rspec_reporter_content_spec.rb +2 -2
  139. data/spec/integration/content/rubocop_content_spec.rb +1 -1
  140. data/spec/integration/content/syntax_validation_spec.rb +2 -2
  141. data/spec/integration/content/test_content_spec.rb +23 -147
  142. data/spec/integration/end_to_end_features_spec.rb +1 -43
  143. data/spec/integration/end_to_end_spec.rb +334 -329
  144. data/spec/integration/generators/automation_generator_spec.rb +3 -37
  145. data/spec/integration/generators/axe_addon_spec.rb +2 -35
  146. data/spec/integration/generators/azure_generator_spec.rb +1 -1
  147. data/spec/integration/generators/common_generator_spec.rb +1 -40
  148. data/spec/integration/generators/config_features_spec.rb +1 -24
  149. data/spec/integration/generators/github_generator_spec.rb +0 -12
  150. data/spec/integration/generators/helpers_generator_spec.rb +74 -80
  151. data/spec/integration/generators/invoke_generators_spec.rb +54 -45
  152. data/spec/integration/generators/rspec_generator_spec.rb +0 -6
  153. data/spec/integration/scaffolding_e2e_spec.rb +17 -179
  154. data/spec/integration/spec_helper.rb +4 -6
  155. data/spec/integration/trace_format_checker.rb +11 -2
  156. data/spec/integration/trace_page_server.rb +72 -5
  157. data/spec/menus/menu_generator_spec.rb +14 -39
  158. data/spec/runtime/actionability_spec.rb +207 -0
  159. data/spec/runtime/actionable_spec.rb +125 -0
  160. data/spec/runtime/browser/actionability_script_browser_spec.rb +150 -0
  161. data/spec/runtime/browser/actionable_browser_spec.rb +98 -0
  162. data/spec/runtime/browser/finders_browser_spec.rb +148 -0
  163. data/spec/runtime/browser/matchers_browser_spec.rb +67 -0
  164. data/spec/runtime/browser/retrying_block_browser_spec.rb +37 -0
  165. data/spec/runtime/browser/role_engine_browser_spec.rb +184 -0
  166. data/spec/runtime/browser/strict_browser_spec.rb +38 -0
  167. data/spec/runtime/by_role_spec.rb +52 -0
  168. data/spec/runtime/config_spec.rb +79 -0
  169. data/spec/runtime/context_spec.rb +73 -0
  170. data/spec/runtime/errors_spec.rb +89 -0
  171. data/spec/runtime/finders_spec.rb +165 -0
  172. data/spec/runtime/fixtures/actionability.html +70 -0
  173. data/spec/runtime/fixtures/locators.html +46 -0
  174. data/spec/runtime/fixtures/matchers.html +33 -0
  175. data/spec/runtime/fixtures/roles.html +162 -0
  176. data/spec/runtime/matchers/base_spec.rb +165 -0
  177. data/spec/runtime/matchers/element_spec.rb +277 -0
  178. data/spec/runtime/matchers/page_spec.rb +102 -0
  179. data/spec/runtime/matchers/presence_spec.rb +59 -0
  180. data/spec/runtime/matchers/retrying_block_spec.rb +165 -0
  181. data/spec/runtime/observer_spec.rb +341 -0
  182. data/spec/runtime/role_finder_spec.rb +156 -0
  183. data/spec/runtime/role_query_spec.rb +75 -0
  184. data/spec/runtime/selectors_spec.rb +135 -0
  185. data/spec/runtime/strict_spec.rb +257 -0
  186. data/spec/runtime/support/browser.rb +48 -0
  187. data/spec/runtime/support/fake_bridge.rb +117 -0
  188. data/spec/runtime/wait_spec.rb +71 -0
  189. data/spec/scaffolding/name_normalizer_spec.rb +3 -2
  190. data/spec/scaffolding/scaffold_project_detector_spec.rb +4 -43
  191. data/spec/system/selenium_spec.rb +1 -5
  192. data/spec/system/support/system_test_helper.rb +2 -5
  193. data/spec/utilities/ffmpeg_spec.rb +80 -7
  194. data/spec/utilities/headless_config_spec.rb +0 -7
  195. data/spec/utilities/utilities_spec.rb +24 -0
  196. data/spec/utilities/video_command_spec.rb +13 -0
  197. metadata +118 -53
  198. data/docs/superpowers/plans/2026-10-25-failure-video-replay.md +0 -400
  199. data/docs/superpowers/plans/2026-10-26-parity-cleanup.md +0 -233
  200. data/docs/superpowers/plans/2026-10-28-failure-card.md +0 -295
  201. data/docs/superpowers/specs/2026-10-25-failure-video-replay-design.md +0 -214
  202. data/docs/superpowers/specs/2026-10-28-failure-card-design.md +0 -210
  203. data/lib/generators/automation/templates/header.tt +0 -9
  204. data/lib/generators/cucumber/cucumber_generator.rb +0 -58
  205. data/lib/generators/cucumber/templates/accessibility_feature.tt +0 -5
  206. data/lib/generators/cucumber/templates/accessibility_steps.tt +0 -17
  207. data/lib/generators/cucumber/templates/cucumber.tt +0 -1
  208. data/lib/generators/cucumber/templates/env.tt +0 -7
  209. data/lib/generators/cucumber/templates/feature.tt +0 -21
  210. data/lib/generators/cucumber/templates/partials/appium_env.tt +0 -26
  211. data/lib/generators/cucumber/templates/partials/driver_world.tt +0 -18
  212. data/lib/generators/cucumber/templates/partials/mobile_steps.tt +0 -20
  213. data/lib/generators/cucumber/templates/partials/selenium_env.tt +0 -120
  214. data/lib/generators/cucumber/templates/partials/watir_env.tt +0 -48
  215. data/lib/generators/cucumber/templates/partials/watir_world.tt +0 -4
  216. data/lib/generators/cucumber/templates/partials/web_steps.tt +0 -28
  217. data/lib/generators/cucumber/templates/steps.tt +0 -5
  218. data/lib/generators/cucumber/templates/user_factory.tt +0 -15
  219. data/lib/generators/cucumber/templates/world.tt +0 -7
  220. data/lib/generators/templates/helpers/browser_helper.tt +0 -31
  221. data/lib/generators/templates/helpers/raider_element.tt +0 -159
  222. data/lib/generators/templates/helpers/wait_helper.tt +0 -611
  223. data/lib/scaffolding/templates/feature.tt +0 -6
  224. data/lib/scaffolding/templates/steps.tt +0 -19
  225. data/sig/generators/cucumber/cucumber_generator.rbs +0 -12
  226. data/spec/fixtures/watir_master/cucumber_watir/Readme.md.snapshot +0 -175
  227. data/spec/fixtures/watir_master/cucumber_watir/features/step_definitions/login_steps.rb.snapshot +0 -24
  228. data/spec/fixtures/watir_master/cucumber_watir/page_objects/abstract/page.rb.snapshot +0 -37
  229. data/spec/fixtures/watir_master/cucumber_watir/page_objects/pages/login.rb.snapshot +0 -33
  230. data/spec/fixtures/watir_master/rspec_watir/Readme.md.snapshot +0 -174
  231. data/spec/fixtures/watir_master/rspec_watir/page_objects/abstract/page.rb.snapshot +0 -37
  232. data/spec/fixtures/watir_master/rspec_watir/page_objects/pages/login.rb.snapshot +0 -33
  233. data/spec/fixtures/watir_master/rspec_watir/spec/login_page_spec.rb.snapshot +0 -49
  234. data/spec/integration/content/cucumber_reporter_content_spec.rb +0 -161
  235. data/spec/integration/generators/cucumber_generator_spec.rb +0 -100
  236. data/spec/integration/helpers/wait_helper_mobile_spec.rb +0 -281
  237. data/spec/integration/helpers/wait_helper_spec.rb +0 -679
  238. data/spec/integration/helpers/wait_helper_support.rb +0 -183
  239. data/spec/system/watir_spec.rb +0 -38
data/README.md CHANGED
@@ -31,63 +31,186 @@ Ruby Raider is a CLI gem for scaffolding and generating UI test automation frame
31
31
 
32
32
  ## Supported Frameworks
33
33
 
34
+ Ruby Raider works on Mac OS, Linux and Windows.
35
+
34
36
  ### Web Testing
35
37
 
36
- | Test Framework | Selenium | Watir (deprecated) |
37
- |----------------|----------|--------------------|
38
- | RSpec | ✅ | ✅ |
39
- | Cucumber | ✅ | ✅ |
38
+ Web projects use **Selenium and RSpec**. They get:
39
+
40
+ - Locators people see on the page (`label:`, `text:`, `by_role(...)` and more), with strict matching
41
+ - Automatic waiting for elements and actions: no implicit wait, no `sleep`
42
+ - Retrying RSpec matchers
43
+ - Login reuse, failure video, failure trace, network mocking and screenshot comparison
44
+ - Optional accessibility tests (axe) and a choice of GitHub Actions or Azure Pipelines
40
45
 
41
- Watir is deprecated and will be removed in the next major version of ruby_raider (4.0); new projects should use Selenium. It is no longer offered in the interactive menu and is available only through `-p automation:watir` until 4.0. See [Migrating from Watir](#migrating-from-watir).
46
+ See [What's Included](#whats-included) for each one.
42
47
 
43
- ### Mobile Testing (Appium)
48
+ ### Mobile Testing
49
+
50
+ Mobile projects use **Appium and RSpec**:
44
51
 
45
52
  | Test Framework | iOS | Android | Cross-Platform |
46
53
  |----------------|-----|---------|----------------|
47
54
  | RSpec | ✅ | ✅ | ✅ |
48
- | Cucumber | ✅ | ✅ | ✅ |
49
55
 
50
- ### Optional Add-on (Web Only)
56
+ They get:
57
+
58
+ - Appium locators: `accessibility_id:`, `id:`, `xpath:` and `class_name:`
59
+ - Automatic waiting: `find_element` waits for a match, and `click`, `send_keys` and `clear` wait until the element is displayed and enabled
60
+ - Retrying RSpec matchers
61
+ - Gestures: `swipe`, `scroll` and `scroll_to`, on iOS and Android
62
+ - Failure video from Appium's screen recording
63
+ - Raider reporting and a GitHub Actions workflow that starts a simulator or emulator and Appium
64
+
65
+ On native app screens, `find_element` returns the first match (strict matching is web only) and `submit` is not checked.
66
+
67
+ To run the examples, download the example [app](https://github.com/RaiderHQ/raider_test_app) and start the server:
68
+
69
+ ```bash
70
+ raider u start_appium
71
+ ```
72
+
73
+ ### Optional Add-ons
51
74
 
52
75
  | Add-on | Flag | Description |
53
76
  |--------|------|-------------|
54
- | Accessibility | `--accessibility` | Adds axe gem + example accessibility tests |
55
- | CI provider | `-p ci:azure` | Generates `azure-pipelines.yml` instead of the GitHub Actions workflow (default `ci:github`) |
56
-
57
- This works on all platforms (Mac OS, Linux and Windows).
77
+ | Accessibility (web) | `--accessibility` | Adds the axe gem and example accessibility tests |
78
+ | CI provider (web) | `-p ci:azure` | Generates `azure-pipelines.yml` instead of the GitHub Actions workflow (default `ci:github`) |
58
79
 
59
80
  ## What's Included
60
81
 
61
- Every generated project comes with:
62
-
63
- - **Page Object Model** — Base page and component classes with example pages
64
- - **Test examples** — Working login tests against the [Raider Test Store](https://raider-test-site.onrender.com/)
65
- - **Raider reporting** — RSpec and Cucumber projects include [raider_reporter](https://github.com/RaiderHQ/raider_reporter), which writes results to `raider-results/` and uploads runs to your Raider Hideout server when `RAIDER_TOKEN` and `RAIDER_ENDPOINT` are set; generated CI runs the suite through `raider-reporter exec` with `RAIDER_QUARANTINE`, so quarantined tests do not fail the build; an opt-in `raider-gate` job (`RAIDER_GATE=1`) fails CI when the Raider quality gate fails
66
- - **Waiting** — generated Selenium and Appium projects wait for elements by themselves (`WaitHelper` and `RaiderElement`): `click`, `send_keys`, `text` and the rest poll until the element is ready, and `eventually { … }` retries assertions, so there is no implicit wait and no `sleep`; `timeout` in `config.yml` sets how long to wait
67
- - **Example tests or a skeleton (`examples:false`)** — start from the working login examples, or pass `examples:false` for an empty skeleton with the helpers, config, CI and README (see [Getting Started](#getting-started))
68
- - **Login reuse** — generated web projects (Selenium or Watir) log in once and restore the saved session for examples tagged `:logged_in` (RSpec) or `@logged_in` (Cucumber); `RAIDER_LOGIN_STATE=off|refresh` and `login_state: max_age:` control it, and the state stays in git-ignored `.raider/auth/`
69
- - **Failure video replay** — Every test is recorded and the video is kept only for failing tests, attached to the report as `video` (WebM from page screenshots for Selenium and Watir, Appium's own MP4 for mobile, which needs `ffmpeg` on the Appium server host for iOS and for Android recordings over 180 s). Turn it off per run with `VIDEO=off`, or per project with `raider u video off`; ffmpeg is downloaded once, SHA-256 checked and cached in `~/.cache/raider`. The RaiderHQ `ffmpeg-7.1` build that the download uses is not published yet, so for now set `RAIDER_FFMPEG_PATH` to an ffmpeg with libvpx to get web videos
70
- - **Failure trace replay** (Selenium with RSpec or Cucumber) — Failing tests keep a step-by-step trace: each action with its locator and wait time, a screenshot and the page HTML after every step that changes the page, plus network requests and console messages on Chrome, Edge and Firefox. It is saved as `raider-results/attachments/<n>-trace.zip`, attached to the report as `trace` and opened in Raider Desktop or on Hideout. `TRACE=on` keeps passing tests too, `TRACE=off` captures nothing, and `raider u trace on|off` sets it for the project. Typed values in password fields and `RAIDER_SECRET_*` values are hidden; other typed values, page text and URLs are kept, so treat a trace like the video. Request headers, cookies and bodies are never captured
71
- - **GitHub Actions CI** — Ready-to-use test pipeline that caches ffmpeg for failure videos
72
- - **Rake tasks** — Default, smoke, and regression tasks with tag-based filtering
73
- - **Retry support** — RSpec retry with configurable retry count via `RETRY_COUNT` env var
74
- - **Re-run failed tests** — RSpec keeps `spec/examples.txt` for `--only-failures`; Cucumber projects write failed scenarios to `rerun.txt`
75
- - **Parallel execution** — parallel_tests and parallel_split_test gems included
76
- - **Configurable browser** — Chrome/Firefox with customizable arguments, viewport, timeout, and headless mode
77
- - **Linting** — RuboCop and Reek configs included
78
-
79
- > **Upgrading from 3.9 or earlier:** existing projects are not changed automatically. To get failure videos, generate a
80
- > new project with the same options and copy `helpers/video_helper.rb`, the video lines in `helpers/spec_helper.rb`
81
- > (RSpec) or `features/support/env.rb` (Cucumber), the `listener:` in the driver or browser helper, the `video:` block
82
- > in `config/config.yml`, and the ffmpeg cache and install steps in your CI pipeline. raider_reporter 0.10 or later
83
- > adds the inline video player in `raider-results/index.html` and a larger size limit for video attachments.
84
-
85
- For Appium projects, download the example [app](https://github.com/RaiderHQ/raider_test_app) and start the server:
82
+ Every generated project loads the Raider runtime (`ruby_raider/runtime`). It adds locators, waiting and assertions to Selenium and Appium themselves.
86
83
 
87
- ```bash
88
- raider u start_appium
84
+ ### Locators
85
+
86
+ Find elements the way a person sees them, on top of Selenium's `id:`, `css:`, `xpath:`, `name:`, `class:` and `link_text:`:
87
+
88
+ | Key | Finds |
89
+ |-----|-------|
90
+ | `label:` | the field with that label, `aria-label` or `aria-labelledby` |
91
+ | `placeholder:` | the field with that placeholder |
92
+ | `alt:` | the element with that `alt` text |
93
+ | `title:` | the element with that `title` |
94
+ | `text:` | the innermost element whose text contains it |
95
+ | `test_id:` | the element whose `data-testid` equals it |
96
+ | `by_role(...)` | the element with that ARIA role and name |
97
+
98
+ ```ruby
99
+ driver.find_element(label: 'Email')
100
+ driver.find_element(label: ['Email', { exact: true }]) # whole text only
101
+ driver.find_element(by_role('button', name: 'Save'))
102
+ driver.find_element(by_role('heading', level: 1))
103
+ ```
104
+
105
+ - Text keys match part of the text and ignore extra spaces. Pass `{ exact: true }` for the whole text.
106
+ - `test_id:` reads another attribute with `Raider.test_id_attribute = 'data-qa'` or `RAIDER_TEST_ID_ATTRIBUTE`.
107
+ - **Strict matching:** `find_element` fails with `Raider::AmbiguousMatch` when a locator matches more than one element. `find_elements` never does. Turn it off with `raider u strict off`.
108
+
109
+ These keys are for web pages. Mobile projects use Appium's locators (see [Mobile Testing](#mobile-testing)).
110
+
111
+ ### Waiting and actionability
112
+
113
+ - `find_element` and `find_elements` wait for a match. There is no implicit wait and no `sleep`.
114
+ - Before an action, the runtime waits until the element is ready:
115
+
116
+ | Action | Waits until the element is |
117
+ |--------|----------------------------|
118
+ | `click` | visible, enabled, not inert, stable and not covered |
119
+ | `send_keys`, `clear` | visible, enabled, editable and not inert |
120
+ | `submit` | visible, enabled and not inert |
121
+
122
+ - `force: true` skips the checks for one call: `button.click(force: true)`.
123
+ - Set the rules with `timeout`, `strict` and `actionability` in `config/config.yml`, or `RAIDER_TIMEOUT`, `RAIDER_STRICT` and `RAIDER_ACTIONABILITY`.
124
+
125
+ ### Assertions
126
+
127
+ RSpec matchers retry until the page matches or `timeout` runs out:
128
+
129
+ `have_text`, `have_value`, `have_attribute`, `have_css`, `have_xpath`, `have_element`, `have_count`, `have_title`, `have_url`, `be_visible`, `be_hidden`, `be_enabled`, `be_disabled`, `be_checked`
130
+
131
+ ```ruby
132
+ expect { account_page.welcome_message }.to have_text('Welcome')
133
+ expect { driver.find_element(id: 'status').text }.to eq('done') # any value matcher retries in a block
134
+ ```
135
+
136
+ ### Raider reporting
137
+
138
+ Projects include [raider_reporter](https://github.com/RaiderHQ/raider_reporter).
139
+
140
+ - Results go to `raider-results/`.
141
+ - Runs upload to your Raider Hideout server when `RAIDER_TOKEN` and `RAIDER_ENDPOINT` are set.
142
+ - CI runs the suite through `raider-reporter exec` with `RAIDER_QUARANTINE`, so quarantined tests do not fail the build.
143
+ - Set the CI variable `RAIDER_GATE` to `1` to add a `raider-gate` job that fails CI when the Raider quality gate fails.
144
+
145
+ ### Failure video replay
146
+
147
+ Each test is recorded. The video is kept only when the test fails and attached to the report as `video`.
148
+
149
+ - **Web:** WebM built from page screenshots. ffmpeg is downloaded once, SHA-256 checked and cached in `~/.cache/raider`: an LGPL ffmpeg 7.1 build with libvpx for macOS (Apple silicon and Intel), Linux x64 and Windows x64, built by [`.github/workflows/ffmpeg.yml`](.github/workflows/ffmpeg.yml). On other platforms set `RAIDER_FFMPEG_PATH` to an ffmpeg with libvpx.
150
+ - **Mobile:** Appium's own MP4. iOS needs `ffmpeg` on the Appium server host. Android stops at 180 s by default, so it needs no ffmpeg; a longer `video.time_limit` needs ffmpeg too.
151
+ - Turn it off per run with `VIDEO=off`, or per project with `raider u video off`.
152
+
153
+ ### Failure trace replay (web)
154
+
155
+ Failing tests keep a step-by-step trace:
156
+
157
+ - each action with its locator and wait time
158
+ - a screenshot and the page HTML after every step that changes the page
159
+ - network requests and console messages on Chrome, Edge and Firefox
160
+
161
+ It is saved as `raider-results/attachments/<n>-trace.zip`, attached to the report as `trace`, and opens in [Raider Desktop](https://ruby-raider.com) or on Hideout.
162
+
163
+ - `TRACE=on` keeps passing tests too. `TRACE=off` captures nothing. `raider u trace on|off` sets it for the project.
164
+ - Password fields and `RAIDER_SECRET_*` values are hidden. Other typed values, page text and URLs are kept, so treat a trace like the video.
165
+ - Request headers, cookies and bodies are never captured.
166
+
167
+ ### Network mocking (web)
168
+
169
+ Answer a request with your own response, or block it:
170
+
171
+ ```ruby
172
+ mock_request('**/api/users', json: { users: [] })
173
+ mock_request(url, status: 500)
174
+ block_request('**/*.png')
175
+ ```
176
+
177
+ - `mock_request` returns the mock; `mock.calls` lists the requests it answered.
178
+ - Works through WebDriver BiDi on Chrome, Edge and Firefox. Safari and `BIDI=off` raise `NetworkHelper::Unavailable`.
179
+ - Handles CORS for cross-origin mocks, clears mocks after each test, and marks mocked requests in the trace.
180
+
181
+ ### Screenshot comparison (web)
182
+
183
+ ```ruby
184
+ match_screenshot('home')
89
185
  ```
90
186
 
187
+ - Compares the page, or one element with `element:`, with a baseline in `screenshots/baselines/<browser>/`.
188
+ - The first run saves the baseline. Later runs fail on a difference and attach the expected, actual and diff pictures to the report and the trace.
189
+ - `SCREENSHOTS=update` rewrites baselines. A missing baseline fails on CI.
190
+ - Tolerances (`threshold`, `max_diff_pixels`, `max_diff_ratio`) go in `config/config.yml` under `screenshots:`.
191
+ - Generate baselines where CI runs: a Retina laptop makes 2x pictures.
192
+
193
+ ### Login reuse (web)
194
+
195
+ Example projects log in once and restore the saved session for examples tagged `:logged_in`.
196
+
197
+ - `RAIDER_LOGIN_STATE=off|refresh` and `login_state: max_age:` control it.
198
+ - The state stays in git-ignored `.raider/auth/`.
199
+ - Skeletons (`examples:false`) get `SessionState#reuse` to wire your own login.
200
+
201
+ ### Also included
202
+
203
+ - **Page Object Model:** base page and component classes with example pages
204
+ - **Example tests:** working tests against the [Raider Test Store](https://raider-test-site.onrender.com/) (web) or the [Raider test app](https://github.com/RaiderHQ/raider_test_app) (mobile), or an empty skeleton with `examples:false` (see [Getting Started](#getting-started))
205
+ - **CI:** GitHub Actions, or Azure Pipelines for web. It caches ffmpeg and comments results on pull requests
206
+ - **Failure screenshots:** each failing test attaches a screenshot to the report
207
+ - **Rake tasks:** default, smoke and regression, filtered by tag
208
+ - **Retries:** RSpec retry, with the count set by `RETRY_COUNT`
209
+ - **Re-run failed tests:** RSpec keeps `spec/examples.txt` for `--only-failures`
210
+ - **Parallel execution:** `parallel_tests` and `parallel_split_test`
211
+ - **Configurable browser:** Chrome or Firefox, with arguments, viewport, timeout and headless mode
212
+ - **Linting:** RuboCop and Reek configs
213
+
91
214
  ## Getting Started
92
215
 
93
216
  Install the gem:
@@ -108,6 +231,12 @@ Or skip the menu with parameters:
108
231
  raider new [project_name] -p framework:rspec automation:selenium
109
232
  ```
110
233
 
234
+ Create a mobile project (`automation:ios`, `automation:android` or `automation:cross_platform`):
235
+
236
+ ```bash
237
+ raider new my_app -p framework:rspec automation:android
238
+ ```
239
+
111
240
  Add accessibility testing:
112
241
 
113
242
  ```bash
@@ -129,34 +258,7 @@ Generate an empty skeleton, without the example pages and tests (the menu asks `
129
258
  raider new my_project -p framework:rspec automation:selenium examples:false
130
259
  ```
131
260
 
132
- The skeleton keeps the helpers, config, CI and README, and its empty suite passes; grow it with `raider g`. Watir projects always include the examples.
133
-
134
- ## Migrating from Watir
135
-
136
- Watir is deprecated; to move a Watir project to Selenium, generate a Selenium project and port your pages. The common mappings:
137
-
138
- | Watir | Selenium project (waiting layer) |
139
- |-------|----------------------------------|
140
- | `browser.goto(url)` | `driver.navigate.to(url)` |
141
- | `browser.text_field(id: 'x').set(v)` | `clear({ id: 'x' })` and `send_keys({ id: 'x' }, v)` |
142
- | `browser.button(id: 'x').click` | `click({ id: 'x' })` |
143
- | `Watir.default_timeout = n` | `timeout: n` in `config/config.yml` |
144
-
145
- ## Adopting waiting in an existing project
146
-
147
- Gem upgrades do not rewrite generated code, so existing projects keep their implicit wait until you opt in:
148
-
149
- 1. Copy both `helpers/wait_helper.rb` and `helpers/raider_element.rb` from a freshly generated project into your
150
- `helpers/` folder. Keep them side by side: `wait_helper.rb` loads the other with `require_relative 'raider_element'`.
151
- 2. Include it in `Page`, the spec helper, or the World, after loading it with `require_relative`, for example
152
- `require_relative '../../helpers/wait_helper'` at the top of `page_objects/abstract/page.rb`.
153
- 3. Set how long it waits: add `timeout: 10` to `config/config.yml`. Single-platform mobile projects (iOS or Android
154
- only) have no `config/config.yml`, so pass `timeout:` to a call, or create `config/config.yml` with that line;
155
- without either, it waits 10 seconds.
156
- 4. Remove the `implicit_wait` line.
157
- 5. Move flaky spots to `click`, `send_keys` and `eventually` first.
158
-
159
- Keep in mind that keeping the implicit wait while using the layer makes every `find` miss cost up to `timeout` seconds per poll cycle, so remove it once you have moved over.
261
+ The skeleton keeps the helpers, config, CI and README, and its empty suite passes; grow it with `raider g`.
160
262
 
161
263
  ## Commands
162
264
 
@@ -179,11 +281,9 @@ Shortcuts: `n` (new), `g` (generate), `u` (utility), `v` (version)
179
281
  ```
180
282
  raider g page [NAME] # Create a page object
181
283
  raider g spec [NAME] # Create an RSpec test
182
- raider g feature [NAME] # Create a Cucumber feature
183
- raider g steps [NAME] # Create step definitions
184
284
  raider g helper [NAME] # Create a helper class
185
285
  raider g component [NAME] # Create a component class
186
- raider g scaffold [NAME(S)] # Create page + test + steps
286
+ raider g scaffold [NAME(S)] # Create page + spec
187
287
  ```
188
288
 
189
289
  Options:
@@ -198,6 +298,8 @@ raider u url [URL] # Set default project URL
198
298
  raider u browser [BROWSER] # Set default browser
199
299
  raider u browser_options [OPTS] # Set browser arguments (e.g., no-sandbox, headless)
200
300
  raider u headless [on/off] # Toggle headless mode
301
+ raider u strict [on/off] # Toggle strict find_element (fail on multiple matches)
302
+ raider u actionability [on/off] # Toggle the actionability wait before element actions
201
303
  raider u raid # Run all tests (-p for parallel)
202
304
  raider u timeout [SECONDS] # Set test timeout
203
305
  raider u viewport [DIMENSIONS] # Set viewport size (e.g., 1920x1080)
data/RELEASE.md CHANGED
@@ -2,6 +2,35 @@
2
2
 
3
3
  ## Release Notes
4
4
 
5
+ ### 4.0.1
6
+
7
+ - Failure video works for web projects without `RAIDER_FFMPEG_PATH`: the RaiderHQ `ffmpeg-7.1` release is published and `RubyRaider::Ffmpeg::MANIFEST` pins the SHA-256 of its four binaries (macOS arm64 and x64, Linux x64, Windows x64). The first failing test, or `raider u video install`, downloads the one for your platform, checks it and caches it in `~/.cache/raider` (`%LOCALAPPDATA%\raider` on Windows).
8
+ - The binaries are FFmpeg 7.1.5 built from source by `.github/workflows/ffmpeg.yml` (`.github/ffmpeg/build.sh`): LGPL (no `--enable-gpl`, no `--enable-nonfree`), statically linked with libvpx 1.15.2 and zlib 1.3.1, with only the PNG input, scaling, VP8/VP9 encoding and WebM output that the video helper uses. The release carries the license texts, the source tarballs and the exact configure line. macOS binaries are ad-hoc signed, not notarized (`spctl` rejects them). Gatekeeper only checks files carrying the quarantine attribute, which a browser download gets and the gem's Net::HTTP download does not, so the gem's copy runs; a copy downloaded with a browser would be blocked.
9
+ - On other platforms (Linux arm64, for example) `RAIDER_FFMPEG_PATH` is still the way to get web videos; the `[video]` line now says so.
10
+ - Existing 4.0.0 projects need no change beyond `bundle update ruby_raider`.
11
+
12
+ ### 4.0.0
13
+
14
+ - Watir is removed: `automation:watir` is no longer a valid automation value.
15
+ - Cucumber is removed: `raider new` generates RSpec projects only and `framework:cucumber` is no longer a valid framework value.
16
+ - `raider g feature`, `raider g steps` and `raider u path --feature` are removed; `raider g scaffold` always writes a spec and a page.
17
+ - Generated projects no longer emit `cucumber_step` trace groups.
18
+ - ruby_raider now depends on selenium-webdriver >= 4.30.
19
+ - Every generated project loads `require 'ruby_raider/runtime'`, which adds waiting and actionability to Selenium and Appium themselves.
20
+ - `WaitHelper`, `RaiderElement`, `helpers/wait_helper.rb` and `helpers/raider_element.rb` are removed. Page objects call Selenium and Appium directly (`driver.find_element(...)`, `element.click`, `element.send_keys`).
21
+ - New locator keys `label`, `placeholder`, `alt`, `title`, `text` and `test_id`, and `by_role(role, name:, exact:, include_hidden:, level:)`.
22
+ - `find_element` is strict: it fails with `Raider::AmbiguousMatch` when a locator matches more than one element. `find_elements` never does.
23
+ - `find_element` and `find_elements` wait for a match (`find_elements` returns `[]` at the deadline). A missing element fails with `no such element: { id: "x" } (waited 10s)`.
24
+ - `eventually` is removed. Block-form expectations retry: `expect { value }.to eq(...)` works with any value matcher. RSpec's block matchers (`raise_error`, `change`, `output`, `throw_symbol`, `yield_*`) keep their stock behaviour, and `expect(value)` without a block does not retry.
25
+ - New RSpec matchers `have_text`, `have_value`, `have_attribute`, `be_visible`, `be_hidden`, `be_enabled`, `be_disabled`, `be_checked`, `have_count`, `have_title`, `have_url`, `have_element`, `have_css` and `have_xpath`, each with `wait:`.
26
+ - `click`, `send_keys`, `clear` and `submit` wait until the element is actionable (visible, enabled, not inert, stable, receives events). `force: true` skips the checks for one call.
27
+ - Native Appium actions wait for the element to be displayed and enabled. On XCUITest an element reported as not displayed waits the full `timeout` and then raises `Raider::NotActionable`; use `force: true` or `Raider.actionability = false` as the way out.
28
+ - `config/config.yml` gets `strict` and `actionability` next to `timeout`. `raider u strict on|off` and `raider u actionability on|off` set them, and `RAIDER_TIMEOUT`, `RAIDER_STRICT`, `RAIDER_ACTIONABILITY` and `RAIDER_QUIET` apply to every project, including single-platform mobile projects, which have no `config.yml`.
29
+ - Mobile gestures (`swipe`, `scroll`, `scroll_to`) move to `helpers/gesture_helper.rb`.
30
+ - Traces record element actions from the runtime: `click`, `send_keys`, `clear` and `submit` with their locators, `within` and `waited_ms`. `text`, `find_element` and other reads are no longer steps, and there are no `eventually` groups.
31
+ - The generated Gemfile pins `raider_reporter` `~> 1.0` (1.0.0 drops the Cucumber plugin).
32
+ - Existing projects pin `gem 'ruby_raider', '~> 3.15'` (or an older `~> 3.x`) in their Gemfile, so `bundle update` never moves them to 4.0; to upgrade, change the pin to `~> 4.0` and run `bundle update ruby_raider`.
33
+
5
34
  ### 3.7.0
6
35
 
7
36
  - Generated RSpec projects no longer include Allure: the `allure-rspec` and `allure-ruby-commons` gems, `helpers/allure_helper.rb`, the `allure-results` folder and `.gitignore` entry, and the Allure report and gh-pages steps in the GitHub Actions workflow are gone. `raider_reporter` is now the only reporter.
data/bin/raider CHANGED
@@ -1,6 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
+ # Read and write UTF-8 whatever the locale: a shell with no LANG (macOS GUI apps) defaults Ruby to US-ASCII,
5
+ # which broke the generator templates and any command that edits a generated file.
6
+ Encoding.default_external = Encoding::UTF_8
7
+ Encoding.default_internal = Encoding::UTF_8
8
+
4
9
  require_relative '../lib/ruby_raider'
5
10
 
6
11
  RubyRaider::Raider.start
@@ -20,14 +20,6 @@ class ScaffoldingCommands < Thor
20
20
  generate_scaffolding(name, 'page', options[:path])
21
21
  end
22
22
 
23
- desc 'feature [NAME]', 'Creates a new feature'
24
- option :path, type: :string, required: false,
25
- desc: 'The path where your feature will be created', aliases: '-p'
26
-
27
- def feature(name)
28
- generate_scaffolding(name, 'feature', options[:path])
29
- end
30
-
31
23
  desc 'spec [SPEC_NAME]', 'Creates a new spec'
32
24
  option :path, type: :string, required: false,
33
25
  desc: 'The path where your spec will be created', aliases: '-p'
@@ -44,14 +36,6 @@ class ScaffoldingCommands < Thor
44
36
  generate_scaffolding(name, 'helper', options[:path])
45
37
  end
46
38
 
47
- desc 'steps [STEPS_NAME]', 'Creates a new steps definition'
48
- option :path, type: :string, required: false,
49
- desc: 'The path where your steps will be created', aliases: '-p'
50
-
51
- def steps(name)
52
- generate_scaffolding(name, 'steps', options[:path])
53
- end
54
-
55
39
  desc 'component [NAME]', 'Creates a component inheriting from Component'
56
40
  option :path, type: :string, required: false,
57
41
  desc: 'The path where your component will be created', aliases: '-p'
@@ -60,7 +44,7 @@ class ScaffoldingCommands < Thor
60
44
  generate_scaffolding(name, 'component', options[:path])
61
45
  end
62
46
 
63
- desc 'scaffold [NAMES...]', 'Generates pages, specs/features, and helpers for one or more names'
47
+ desc 'scaffold [NAMES...]', 'Generates pages, specs, and helpers for one or more names'
64
48
 
65
49
  def scaffold(*names)
66
50
  names.each { |name| generate_default_scaffold(name) }
@@ -83,9 +67,7 @@ class ScaffoldingCommands < Thor
83
67
  say 'Warning: No Gemfile found, defaulting to selenium + rspec templates.', :yellow
84
68
  else
85
69
  automation = ScaffoldProjectDetector.detect_automation(gemfile)
86
- framework = ScaffoldProjectDetector.detect_framework(gemfile)
87
70
  say 'Warning: Could not detect automation library from Gemfile, defaulting to selenium.', :yellow if automation.nil?
88
- say 'Warning: Could not detect test framework from Gemfile, defaulting to rspec.', :yellow if framework.nil?
89
71
  end
90
72
  end
91
73
 
@@ -97,12 +79,7 @@ class ScaffoldingCommands < Thor
97
79
 
98
80
  def generate_default_scaffold(name)
99
81
  validate_project!
100
- if Pathname.new('spec').exist? && !Pathname.new('features').exist?
101
- generate_scaffolding(name, 'spec', load_config_path('spec'))
102
- else
103
- generate_scaffolding(name, 'feature', load_config_path('feature'))
104
- generate_scaffolding(name, 'steps', load_config_path('steps'))
105
- end
82
+ generate_scaffolding(name, 'spec', load_config_path('spec'))
106
83
  generate_scaffolding(name, 'page', load_config_path('page'))
107
84
  end
108
85
  end
@@ -7,8 +7,6 @@ class UtilityCommands < Thor
7
7
  def self.exit_on_failure? = true
8
8
 
9
9
  desc 'path [PATH]', 'Sets the default path for scaffolding'
10
- option :feature,
11
- type: :boolean, required: false, desc: 'The default path for your features', aliases: '-f'
12
10
  option :helper,
13
11
  type: :boolean, required: false, desc: 'The default path for your helpers', aliases: '-h'
14
12
  option :spec,
@@ -49,12 +47,28 @@ class UtilityCommands < Thor
49
47
  desc 'headless [on/off]', 'Toggles headless mode for browser tests'
50
48
 
51
49
  def headless(toggle)
52
- enabled = %w[on true 1 yes].include?(toggle.downcase)
50
+ enabled = on?(toggle)
53
51
  Utilities.headless = enabled
54
52
  state = enabled ? 'enabled' : 'disabled'
55
53
  say "Headless mode #{state}", :green
56
54
  end
57
55
 
56
+ desc 'strict [on/off]', 'Toggles strict find_element (fails when a locator matches more than one element)'
57
+
58
+ def strict(toggle)
59
+ enabled = on?(toggle)
60
+ Utilities.strict = enabled
61
+ say "Strict mode #{enabled ? 'enabled' : 'disabled'}", :green
62
+ end
63
+
64
+ desc 'actionability [on/off]', 'Toggles the actionability wait before element actions'
65
+
66
+ def actionability(toggle)
67
+ enabled = on?(toggle)
68
+ Utilities.actionability = enabled
69
+ say "Actionability #{enabled ? 'enabled' : 'disabled'}", :green
70
+ end
71
+
58
72
  desc 'raid', 'It runs all the tests in a project'
59
73
  option :parallel,
60
74
  type: :boolean, required: false, desc: 'It runs the tests in parallel', aliases: '-p'
@@ -160,4 +174,10 @@ class UtilityCommands < Thor
160
174
  say "Failure video #{enabled ? 'enabled' : 'disabled'}", :green
161
175
  end
162
176
  end
177
+
178
+ private
179
+
180
+ def on?(toggle)
181
+ %w[on true 1 yes].include?(toggle.downcase)
182
+ end
163
183
  end
@@ -17,7 +17,6 @@ class AutomationGenerator < Generator
17
17
  generate_home_page
18
18
  generate_pdp_page
19
19
  else
20
- generate_header_component
21
20
  generate_model_files
22
21
  generate_pages
23
22
  end
@@ -67,10 +66,6 @@ class AutomationGenerator < Generator
67
66
  template('pdp.tt', "#{name}/page_objects/pages/pdp.rb")
68
67
  end
69
68
 
70
- def generate_header_component
71
- template('header.tt', "#{name}/page_objects/components/header.rb")
72
- end
73
-
74
69
  def generate_model_factory
75
70
  template('factory.tt', "#{name}/models/model_factory.rb")
76
71
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Component
4
+ # `component` is a Selenium element: `component.find_element(...)` searches inside it.
4
5
  attr_reader :component
5
6
 
6
7
  def initialize(component)
@@ -6,7 +6,7 @@ class Home < Page
6
6
  # Actions
7
7
 
8
8
  def go_to_product_detail
9
- tap(first_product)
9
+ first_product.click
10
10
  end
11
11
 
12
12
  private
@@ -14,6 +14,6 @@ class Home < Page
14
14
  # Elements
15
15
 
16
16
  def first_product
17
- <%= partial('home_page_selector') -%>
17
+ <%= cross_platform? ? 'element(' : 'driver.find_element(' -%><%= partial('home_page_selector').strip -%>)
18
18
  end
19
19
  end
@@ -9,46 +9,26 @@ class Login < Page
9
9
 
10
10
  # Actions
11
11
 
12
- <%- if selenium_based? -%>
13
12
  def login(username, password)
14
- send_keys(username_field, username)
15
- send_keys(password_field, password)
16
- click(login_button)
17
- end
18
- alias log_as login
19
- <%- else -%>
20
- def login(username, password)
21
- username_field.set username
22
- password_field.set password
13
+ username_field.send_keys(username)
14
+ password_field.send_keys(password)
23
15
  login_button.click
24
16
  end
25
- <%- end -%>
17
+ alias log_as login
26
18
 
27
19
  private
28
20
 
29
21
  # Elements
30
22
 
31
23
  def username_field
32
- <%- if selenium_based? -%>
33
- { id: 'loginFrm_loginname' }
34
- <%- else -%>
35
- browser.text_field(id: 'loginFrm_loginname')
36
- <%- end -%>
24
+ driver.find_element(id: 'loginFrm_loginname')
37
25
  end
38
26
 
39
27
  def password_field
40
- <%- if selenium_based? -%>
41
- { id: 'loginFrm_password' }
42
- <%- else -%>
43
- browser.text_field(id: 'loginFrm_password')
44
- <%- end -%>
28
+ driver.find_element(id: 'loginFrm_password')
45
29
  end
46
30
 
47
31
  def login_button
48
- <%- if selenium_based? -%>
49
- { xpath: "//button[@title='Login']" }
50
- <%- else -%>
51
- browser.button(xpath: "//button[@title='Login']")
52
- <%- end -%>
32
+ driver.find_element(by_role('button', name: 'Login'))
53
33
  end
54
34
  end
@@ -1,22 +1,34 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- <%- if web? && examples? -%>
4
- require_relative '../components/header'
3
+ require 'ruby_raider/runtime'
4
+ <%- if cross_platform? -%>
5
+ require_relative '../../helpers/appium_helper'
6
+ <%- end -%>
7
+ <%- if mobile? -%>
8
+ require_relative '../../helpers/gesture_helper'
9
+ <%- end -%>
10
+ <%- if network_helper? -%>
11
+ require_relative '../../helpers/network_helper'
5
12
  <%- end -%>
6
- <%- if wait_helper? -%>
7
- require_relative '../../helpers/wait_helper'
13
+ <%- if screenshot_helper? -%>
14
+ require_relative '../../helpers/screenshot_helper'
8
15
  <%- end -%>
9
16
 
10
17
  class Page
11
18
  <%- if cross_platform? -%>
12
19
  include AppiumHelper
13
20
  <%- end -%>
14
- <%- if wait_helper? -%>
15
- include WaitHelper
21
+ include Raider::Helpers
22
+ <%- if mobile? -%>
23
+ include GestureHelper
16
24
  <%- end -%>
17
- <%- if cross_platform? || wait_helper? -%>
18
-
25
+ <%- if network_helper? -%>
26
+ include NetworkHelper
27
+ <%- end -%>
28
+ <%- if screenshot_helper? -%>
29
+ include ScreenshotHelper
19
30
  <%- end -%>
31
+
20
32
  <%= partial('initialize_selector') -%>
21
33
  <%= partial('visit_method') -%>
22
34
  <%= partial('url_methods') -%>
@@ -26,17 +38,10 @@ class Page
26
38
  end
27
39
  <%- if selenium_based? && examples? -%>
28
40
 
29
- # Components
30
-
31
- def header
32
- Header.new(find_element(css: '.welcome-msg'))
33
- end
34
- <%- elsif watir? -%>
35
-
36
- # Components
41
+ # Elements
37
42
 
38
- def header
39
- Header.new(browser.element(css: '.welcome-msg'))
43
+ def welcome_message
44
+ driver.find_element(css: '.welcome-msg')
40
45
  end
41
46
  <%- end -%>
42
47
  end
@@ -1,6 +1,5 @@
1
1
  <%- if cross_platform? -%>
2
- { ios: { accessibility_id: 'product-item-1' },
3
- android: { accessibility_id: 'product-item-1' } }
2
+ { ios: { accessibility_id: 'product-item-1' }, android: { accessibility_id: 'product-item-1' } }
4
3
  <%- else -%>
5
4
  { accessibility_id: 'product-item-1' }
6
5
  <%- end -%>
@@ -1,13 +1,5 @@
1
- <%- if watir? -%>
2
- attr_reader :browser
3
-
4
- def initialize(browser)
5
- @browser = browser
6
- end
7
- <%- else -%>
8
1
  attr_reader :driver
9
2
 
10
3
  def initialize(driver)
11
4
  @driver = driver
12
5
  end
13
- <%- end -%>
@@ -1,6 +1,5 @@
1
1
  <%- if cross_platform? -%>
2
- { ios: { accessibility_id: 'add-to-cart-button' },
3
- android: { accessibility_id: 'add-to-cart-button' } }
2
+ { ios: { accessibility_id: 'add-to-cart-button' }, android: { accessibility_id: 'add-to-cart-button' } }
4
3
  <%- else -%>
5
4
  { accessibility_id: 'add-to-cart-button' }
6
5
  <%- end -%>