Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Commit

Permalink
Fixed for Capybara 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jferris committed Sep 30, 2011
1 parent f75bc3d commit 5843e56
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
16 changes: 8 additions & 8 deletions Gemfile.lock
@@ -1,24 +1,24 @@
GEM
remote: http://rubygems.org/
specs:
capybara (1.0.0)
capybara (1.1.1)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
selenium-webdriver (~> 0.2.0)
selenium-webdriver (~> 2.0)
xpath (~> 0.1.4)
childprocess (0.1.9)
childprocess (0.2.2)
ffi (~> 1.0.6)
diff-lcs (1.1.2)
ffi (1.0.9)
json_pure (1.5.3)
json_pure (1.6.0)
mime-types (1.16)
mini_magick (3.2.1)
subexec (~> 0.0.4)
nokogiri (1.5.0)
rack (1.3.0)
rack-test (0.6.0)
rack (1.3.2)
rack-test (0.6.1)
rack (>= 1.0)
rake (0.9.2)
rspec (2.6.0)
Expand All @@ -30,8 +30,8 @@ GEM
diff-lcs (~> 1.1.2)
rspec-mocks (2.6.0)
rubyzip (0.9.4)
selenium-webdriver (0.2.2)
childprocess (>= 0.1.9)
selenium-webdriver (2.6.0)
childprocess (>= 0.2.1)
ffi (>= 1.0.7)
json_pure
rubyzip
Expand Down
3 changes: 3 additions & 0 deletions lib/capybara/driver/webkit.rb
Expand Up @@ -10,6 +10,9 @@ class WebkitInvalidResponseError < StandardError
class WebkitNoResponseError < StandardError
end

class NodeNotAttachedError < Capybara::ElementNotFound
end

attr_reader :browser

def initialize(app, options={})
Expand Down
10 changes: 9 additions & 1 deletion lib/capybara/driver/webkit/node.rb
Expand Up @@ -88,7 +88,15 @@ def find(xpath)
end

def invoke(name, *args)
browser.command "Node", name, native, *args
if attached?
browser.command "Node", name, native, *args
else
raise Capybara::Driver::Webkit::NodeNotAttachedError
end
end

def attached?
browser.command("Node", "isAttached", native) == "true"
end

def browser
Expand Down
4 changes: 4 additions & 0 deletions src/capybara.js
Expand Up @@ -27,6 +27,10 @@ Capybara = {
return results.join(",");
},

isAttached: function(index) {
return document.evaluate("ancestor-or-self::html", this.nodes[index], null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue != null;
},

text: function (index) {
var node = this.nodes[index];
var type = (node.type || node.tagName).toLowerCase();
Expand Down

0 comments on commit 5843e56

Please sign in to comment.