mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
invalid element error while filtering results shold be caught
This commit is contained in:
parent
8e407cc243
commit
d8368b783b
2 changed files with 21 additions and 1 deletions
|
@ -91,8 +91,16 @@ module Capybara
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
res &&= node.session.using_wait_time(0){ @filter_block.call(node)} unless @filter_block.nil?
|
res &&= if node.respond_to?(:session)
|
||||||
|
node.session.using_wait_time(0){ @filter_block.call(node) }
|
||||||
|
else
|
||||||
|
@filter_block.call(node)
|
||||||
|
end unless @filter_block.nil?
|
||||||
|
|
||||||
res
|
res
|
||||||
|
|
||||||
|
rescue *(node.respond_to?(:driver) ? node.driver.invalid_element_errors : [])
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
def visible
|
def visible
|
||||||
|
|
|
@ -71,6 +71,18 @@ RSpec.describe Capybara::Result do
|
||||||
expect(result[-1].text).to eq 'Delta'
|
expect(result[-1].text).to eq 'Delta'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'works with filter blocks' do
|
||||||
|
result = string.all('//li') { |node| node.text == 'Alpha' }
|
||||||
|
expect(result.size).to eq 1
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should catch invalid element errors during filtering' do
|
||||||
|
allow_any_instance_of(Capybara::Node::Simple).to receive(:driver).and_return(double("driver", invalid_element_errors: [::Selenium::WebDriver::Error::StaleElementReferenceError]))
|
||||||
|
allow_any_instance_of(Capybara::Node::Simple).to receive(:text).and_raise(::Selenium::WebDriver::Error::StaleElementReferenceError)
|
||||||
|
result = string.all('//li') { |node| node.text == 'Alpha' }
|
||||||
|
expect(result.size).to eq 0
|
||||||
|
end
|
||||||
|
|
||||||
#Not a great test but it indirectly tests what is needed
|
#Not a great test but it indirectly tests what is needed
|
||||||
it "should evaluate filters lazily" do
|
it "should evaluate filters lazily" do
|
||||||
skip 'JRuby has an issue with lazy enumerator evaluation' if RUBY_PLATFORM == 'java'
|
skip 'JRuby has an issue with lazy enumerator evaluation' if RUBY_PLATFORM == 'java'
|
||||||
|
|
Loading…
Reference in a new issue