Skip to content

Commit

Permalink
Handle js error during hint gathering in selenium driver
Browse files Browse the repository at this point in the history
  • Loading branch information
twalpole committed Jan 29, 2024
1 parent 234649c commit 64c3128
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/capybara/selenium/extensions/find.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ def find_by(format, selector, uses_visibility:, texts:, styles:, position:)

if (els.size > 2) && !ENV['DISABLE_CAPYBARA_SELENIUM_OPTIMIZATIONS']
els = filter_by_text(els, texts) unless texts.empty?
hints = gather_hints(els, uses_visibility: uses_visibility, styles: styles, position: position)
hints = begin
gather_hints(els, uses_visibility: uses_visibility, styles: styles, position: position)
rescue Selenium::WebDriver::Error::JavascriptError
# Unclear how this can happen but issue #2729 indicates it can
[]
end
end
els.map.with_index { |el, idx| build_node(el, hints[idx] || {}) }
end
Expand Down

0 comments on commit 64c3128

Please sign in to comment.