mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Fix intermittent "RegexpError (regular expression too big)" errors when
using Selenium. The problem stems from session.rb where the has_xpath? method keeps searching for results. Every time this statement executes the options[:text] inside of searchable.rb would be re-escaped resulting in a larger and larger regular expression. If it takes Selenium too long to respond, eventually a RegexpError is raised.
This commit is contained in:
parent
a8a4efc379
commit
fec3603235
1 changed files with 8 additions and 2 deletions
|
@ -33,8 +33,14 @@ module Capybara
|
|||
results = all_unfiltered(locator)
|
||||
|
||||
if options[:text]
|
||||
options[:text] = Regexp.escape(options[:text]) unless options[:text].kind_of?(Regexp)
|
||||
results = results.select { |n| n.text.match(options[:text]) }
|
||||
|
||||
if options[:text].kind_of?(Regexp)
|
||||
regexp = options[:text]
|
||||
else
|
||||
regexp = Regexp.escape(options[:text])
|
||||
end
|
||||
|
||||
results = results.select { |n| n.text.match(regexp) }
|
||||
end
|
||||
|
||||
if options[:visible] or Capybara.ignore_hidden_elements
|
||||
|
|
Loading…
Reference in a new issue