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
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)
@ -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

View file

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

View file

@ -88,7 +88,15 @@ class Capybara::Driver::Webkit
end
def invoke(name, *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

View file

@ -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();