Permalink
Browse files

Don't look for attached nodes at invalid indices

  • Loading branch information...
1 parent 9223d9f commit 58c5b413397113fb744d2fe901d83294e1a0328c @mhoran mhoran committed Apr 2, 2013
Showing with 10 additions and 1 deletion.
  1. +8 −0 spec/integration/session_spec.rb
  2. +2 −1 src/capybara.js
@@ -60,6 +60,7 @@ module TestSessions
<strong>Hello</strong>
<span>UTF8文字列</span>
<input type="button" value="ボタン" />
+ <a href="about:blank">Link</a>
</body></html>
HTML
[200,
@@ -84,6 +85,13 @@ module TestSessions
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
@@ -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) {

0 comments on commit 58c5b41

Please sign in to comment.