1
0
Fork 0
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:
Darren Hinderer 2010-07-08 15:54:05 -07:00
parent a8a4efc379
commit fec3603235

View file

@ -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