1
0
Fork 0
mirror of https://github.com/thoughtbot/capybara-webkit synced 2023-03-27 23:22:28 -04:00

Don't look for attached nodes at invalid indices

This commit is contained in:
Matthew Horan 2013-04-02 19:25:26 -04:00
parent 9223d9fd79
commit 58c5b41339
2 changed files with 10 additions and 1 deletions

View file

@ -60,6 +60,7 @@ describe Capybara::Session do
<strong>Hello</strong>
<span>UTF8文字列</span>
<input type="button" value="ボタン" />
<a href="about:blank">Link</a>
</body></html>
HTML
[200,
@ -84,6 +85,13 @@ describe Capybara::Session do
it "can click utf8 string" do
subject.click_button('ボタン')
end
it "raises an ElementNotFound error when the selector scope is no longer valid" do
subject.within('//body') do
subject.click_link 'Link'
lambda { subject.find('//strong') }.should raise_error(Capybara::ElementNotFound)
end
end
end
context "response headers with status code" do

View file

@ -51,7 +51,8 @@ Capybara = {
},
isAttached: function(index) {
return document.evaluate("ancestor-or-self::html", this.nodes[index], null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue != null;
return this.nodes[index] &&
document.evaluate("ancestor-or-self::html", this.nodes[index], null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue != null;
},
text: function (index) {