Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Teach List selector ARIA label locator filter

Alexander Brandon Coles1a0ed0f47930
diff --git a/spec/support/capybara/additional_accessible_selectors.rb b/spec/support/capybara/additional_accessible_selectors.rb
index 5654f464970..8c728a3d919 100644
--- a/spec/support/capybara/additional_accessible_selectors.rb
+++ b/spec/support/capybara/additional_accessible_selectors.rb
@@ -29,13 +29,29 @@
#++
Capybara.add_selector(:list) do
- xpath { ".//ul | .//ol" }
+ xpath do |*|
+ XPath.descendant[[
+ XPath.self(:ul),
+ XPath.self(:ol)
+ ].reduce(:|)]
+ end
+
+ locator_filter skip_if: nil do |node, locator, exact:, **|
+ method = exact ? :eql? : :include?
+ if node[:"aria-labelledby"]
+ CapybaraAccessibleSelectors::Helpers.element_labelledby(node).public_send(method, locator)
+ elsif node[:"aria-label"]
+ node[:"aria-label"].public_send(method, locator.to_s)
+ end
+ end
end
Capybara.add_selector(:list_item) do
label "list item"
- xpath { ".//li" }
+ xpath do |*|
+ XPath.descendant[XPath.self(:li)]
+ end
expression_filter(:position) do |xpath, position|
position ? "#{xpath}[#{position}]" : xpath