Cuprite support#157
Conversation
| Capybara::Selenium::Driver.new(app, browser: :chrome, options:) | ||
| end | ||
| Capybara.register_driver(:cuprite_chrome_headless) do |app| | ||
| Capybara::Cuprite::Driver.new(app, browser_name: :chrome) |
There was a problem hiding this comment.
Options listed here: https://github.com/rubycdp/ferrum#customization
|
@seanpdoyle thanks for your feedback and apologies for dropping the ball! I'd still love to see Cuprite support. I'll see if I can address the various comments in the next week or so. |
58bb24e to
88d327c
Compare
There was a problem hiding this comment.
Pull request overview
Adds initial support for running this project’s Capybara accessible selectors against the Cuprite (Ferrum/CDP) driver by introducing Cuprite-based computed accessibility queries and wiring Cuprite into the test suite.
Changes:
- Add Cuprite driver registration in the RSpec spec helper and introduce driver-based skips for known-incompatible specs.
- Implement Cuprite-backed
accessible_name,accessible_description, androleresolution using a newAccessibilityComputedValuehelper. - Update rich text filling to avoid sending
nil/empty values, and add Cuprite to the bundle.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| spec/spec_helper.rb | Optionally requires Cuprite and registers a Cuprite headless driver for specs. |
| spec/selectors/rich_text_spec.rb | Skips specific rich-text behavior tests for Cuprite. |
| spec/selectors/disclosure_spec.rb | Skips specific disclosure toggle/select tests for Cuprite. |
| spec/capybara/node/element/accessible_description_spec.rb | Skips specific accessible-description expectations for Cuprite. |
| lib/capybara_accessible_selectors/selectors/rich_text.rb | Avoids sending nil text and removes Selenium platform dependency for modifier key detection. |
| lib/capybara_accessible_selectors/rspec/matchers/have_validation_errors.rb | Adjusts outerHTML retrieval to support drivers without attribute('outerHTML'). |
| lib/capybara_accessible_selectors/node/role.rb | Adds Cuprite-specific role resolution. |
| lib/capybara_accessible_selectors/node/accessible_name.rb | Adds Cuprite-specific accessible name resolution. |
| lib/capybara_accessible_selectors/node/accessible_description.rb | Adds Cuprite-specific accessible description resolution. |
| lib/capybara_accessible_selectors/node.rb | Includes Cuprite node extensions when Cuprite is already loaded. |
| lib/capybara_accessible_selectors/cuprite/accessibility_computed_value.rb | New helper to query computed accessibility values via CDP. |
| Gemfile / Gemfile.lock | Adds Cuprite dependency and updates the lockfile. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
88d327c to
89ae084
Compare
Add Cuprite (Chrome DevTools Protocol) as an alternative browser driver. Uses Chrome's Accessibility.getPartialAXTree CDP command to resolve accessible name, description, and role values. - Add CupriteNodeExtensions with defined? guard for optional dependency - Add AccessibilityComputedValue resolver for CDP accessibility tree - Handle Chrome's non-standard PascalCase role identifiers - Guard Cuprite require/registration in spec_helper - Use RUBY_PLATFORM for platform detection (no hard Selenium dependency) - Use evaluate_script for outerHTML access across drivers - Add send_keys nil guards for rich text Fixes citizensadvice#156
Annotate specs with skip_driver: :cuprite_chrome where Chrome's CDP accessibility tree returns different values than Selenium, or where Cuprite's send_keys handling of modifier keys differs. - 4 accessible_description edge cases (browser implementation differences) - 2 disclosure toggle/select specs (details element interaction) - 8 rich text fill/replace/within specs (modifier key handling)
89ae084 to
810bde3
Compare
| # So we can't just use backspace | ||
| input.send_keys [command_modifier, "a"], :backspace if input.text != "" && clear | ||
| input.send_keys with | ||
| input.send_keys with if with |
There was a problem hiding this comment.
Note to self: would be good to fix upstream!
| begin | ||
| require "capybara/cuprite" | ||
| rescue LoadError | ||
| # Cuprite is optional | ||
| end |
There was a problem hiding this comment.
I'm not sure if this is necessary - it might be ok to make Cuprite (and all Capybara drivers) test dependencies.
Summary
Accessibility.getPartialAXTreeto resolve computed accessible names, roles, and descriptionsTest plan
bundle exec rspec(default Selenium driver) — 1812 examples, 0 failuresDRIVER=cuprite_chrome_headless bundle exec rspec— 1812 examples, 0 failures, 14 expected pending