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

Fixed for Capybara 1.1

This commit is contained in:
Joe Ferris 2011-09-30 16:13:54 -05:00
parent f75bc3dbad
commit 5843e56a8c
4 changed files with 24 additions and 9 deletions

View file

@ -1,24 +1,24 @@
GEM GEM
remote: http://rubygems.org/ remote: http://rubygems.org/
specs: specs:
capybara (1.0.0) capybara (1.1.1)
mime-types (>= 1.16) mime-types (>= 1.16)
nokogiri (>= 1.3.3) nokogiri (>= 1.3.3)
rack (>= 1.0.0) rack (>= 1.0.0)
rack-test (>= 0.5.4) rack-test (>= 0.5.4)
selenium-webdriver (~> 0.2.0) selenium-webdriver (~> 2.0)
xpath (~> 0.1.4) xpath (~> 0.1.4)
childprocess (0.1.9) childprocess (0.2.2)
ffi (~> 1.0.6) ffi (~> 1.0.6)
diff-lcs (1.1.2) diff-lcs (1.1.2)
ffi (1.0.9) ffi (1.0.9)
json_pure (1.5.3) json_pure (1.6.0)
mime-types (1.16) mime-types (1.16)
mini_magick (3.2.1) mini_magick (3.2.1)
subexec (~> 0.0.4) subexec (~> 0.0.4)
nokogiri (1.5.0) nokogiri (1.5.0)
rack (1.3.0) rack (1.3.2)
rack-test (0.6.0) rack-test (0.6.1)
rack (>= 1.0) rack (>= 1.0)
rake (0.9.2) rake (0.9.2)
rspec (2.6.0) rspec (2.6.0)
@ -30,8 +30,8 @@ GEM
diff-lcs (~> 1.1.2) diff-lcs (~> 1.1.2)
rspec-mocks (2.6.0) rspec-mocks (2.6.0)
rubyzip (0.9.4) rubyzip (0.9.4)
selenium-webdriver (0.2.2) selenium-webdriver (2.6.0)
childprocess (>= 0.1.9) childprocess (>= 0.2.1)
ffi (>= 1.0.7) ffi (>= 1.0.7)
json_pure json_pure
rubyzip rubyzip

View file

@ -10,6 +10,9 @@ class Capybara::Driver::Webkit
class WebkitNoResponseError < StandardError class WebkitNoResponseError < StandardError
end end
class NodeNotAttachedError < Capybara::ElementNotFound
end
attr_reader :browser attr_reader :browser
def initialize(app, options={}) def initialize(app, options={})

View file

@ -88,7 +88,15 @@ class Capybara::Driver::Webkit
end end
def invoke(name, *args) def invoke(name, *args)
if attached?
browser.command "Node", name, native, *args browser.command "Node", name, native, *args
else
raise Capybara::Driver::Webkit::NodeNotAttachedError
end
end
def attached?
browser.command("Node", "isAttached", native) == "true"
end end
def browser def browser

View file

@ -27,6 +27,10 @@ Capybara = {
return results.join(","); 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) { text: function (index) {
var node = this.nodes[index]; var node = this.nodes[index];
var type = (node.type || node.tagName).toLowerCase(); var type = (node.type || node.tagName).toLowerCase();