diff --git a/lib/capybara/webkit/browser.rb b/lib/capybara/webkit/browser.rb index c172adb..9513f33 100644 --- a/lib/capybara/webkit/browser.rb +++ b/lib/capybara/webkit/browser.rb @@ -27,7 +27,7 @@ module Capybara::Webkit end def find_xpath(query) - command("Find", query).split(",") + command("FindXpath", query).split(",") end def find_css(query) diff --git a/lib/capybara/webkit/node.rb b/lib/capybara/webkit/node.rb index 47a6feb..4dbf2f0 100644 --- a/lib/capybara/webkit/node.rb +++ b/lib/capybara/webkit/node.rb @@ -96,7 +96,7 @@ module Capybara::Webkit end def find_xpath(xpath) - invoke("findWithin", xpath).split(',').map do |native| + invoke("findXpathWithin", xpath).split(',').map do |native| self.class.new(driver, native) end end diff --git a/src/CommandFactory.cpp b/src/CommandFactory.cpp index e401b75..1d1f94f 100644 --- a/src/CommandFactory.cpp +++ b/src/CommandFactory.cpp @@ -1,7 +1,7 @@ #include "CommandFactory.h" #include "NullCommand.h" #include "Visit.h" -#include "Find.h" +#include "FindXpath.h" #include "Reset.h" #include "Node.h" #include "Evaluate.h" diff --git a/src/Find.cpp b/src/Find.cpp deleted file mode 100644 index 3325e19..0000000 --- a/src/Find.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "Find.h" -#include "WebPage.h" -#include "WebPageManager.h" -#include "InvocationResult.h" - -Find::Find(WebPageManager *manager, QStringList &arguments, QObject *parent) : JavascriptCommand(manager, arguments, parent) { -} - -void Find::start() { - InvocationResult result = page()->invokeCapybaraFunction("find", arguments()); - finish(&result); -} - diff --git a/src/Find.h b/src/Find.h deleted file mode 100644 index e153893..0000000 --- a/src/Find.h +++ /dev/null @@ -1,11 +0,0 @@ -#include "JavascriptCommand.h" - -class Find : public JavascriptCommand { - Q_OBJECT - - public: - Find(WebPageManager *, QStringList &arguments, QObject *parent = 0); - virtual void start(); -}; - - diff --git a/src/FindXpath.cpp b/src/FindXpath.cpp new file mode 100644 index 0000000..f450bd2 --- /dev/null +++ b/src/FindXpath.cpp @@ -0,0 +1,13 @@ +#include "FindXpath.h" +#include "WebPage.h" +#include "WebPageManager.h" +#include "InvocationResult.h" + +FindXpath::FindXpath(WebPageManager *manager, QStringList &arguments, QObject *parent) : JavascriptCommand(manager, arguments, parent) { +} + +void FindXpath::start() { + InvocationResult result = page()->invokeCapybaraFunction("findXpath", arguments()); + finish(&result); +} + diff --git a/src/FindXpath.h b/src/FindXpath.h new file mode 100644 index 0000000..0ba09b4 --- /dev/null +++ b/src/FindXpath.h @@ -0,0 +1,11 @@ +#include "JavascriptCommand.h" + +class FindXpath : public JavascriptCommand { + Q_OBJECT + + public: + FindXpath(WebPageManager *, QStringList &arguments, QObject *parent = 0); + virtual void start(); +}; + + diff --git a/src/capybara.js b/src/capybara.js index 385283d..e6e48ec 100644 --- a/src/capybara.js +++ b/src/capybara.js @@ -11,23 +11,23 @@ Capybara = { } }, - find: function (xpath) { - return this.findRelativeTo(document, xpath); + findXpath: function (xpath) { + return this.findXpathRelativeTo(document, xpath); }, findCss: function (selector) { - return this.findRelativeToSelector(document, selector); + return this.findCssRelativeTo(document, selector); }, - findWithin: function (index, xpath) { - return this.findRelativeTo(this.nodes[index], xpath); + findXpathWithin: function (index, xpath) { + return this.findXpathRelativeTo(this.nodes[index], xpath); }, findCssWithin: function (index, selector) { - return this.findRelativeToSelector(this.nodes[index], selector); + return this.findCssRelativeTo(this.nodes[index], selector); }, - findRelativeTo: function (reference, xpath) { + findXpathRelativeTo: function (reference, xpath) { var iterator = document.evaluate(xpath, reference, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null); var node; var results = []; @@ -39,7 +39,7 @@ Capybara = { return results.join(","); }, - findRelativeToSelector: function (reference, selector) { + findCssRelativeTo: function (reference, selector) { var elements = reference.querySelectorAll(selector); var results = []; for (var i = 0; i < elements.length; i++) { diff --git a/src/find_command.h b/src/find_command.h index f90a003..29c7813 100644 --- a/src/find_command.h +++ b/src/find_command.h @@ -4,7 +4,7 @@ } CHECK_COMMAND(Visit) -CHECK_COMMAND(Find) +CHECK_COMMAND(FindXpath) CHECK_COMMAND(Reset) CHECK_COMMAND(Node) CHECK_COMMAND(Evaluate) diff --git a/src/webkit_server.pro b/src/webkit_server.pro index 4f9b444..9eab9a8 100644 --- a/src/webkit_server.pro +++ b/src/webkit_server.pro @@ -22,7 +22,6 @@ HEADERS = \ Command.h \ SocketCommand.h \ Visit.h \ - Find.h \ Reset.h \ Node.h \ JavascriptInvocation.h \ @@ -61,7 +60,8 @@ HEADERS = \ ErrorMessage.h \ Title.h \ FindCss.h \ - JavascriptCommand.h + JavascriptCommand.h \ + FindXpath.h SOURCES = \ Version.cpp \ @@ -85,7 +85,6 @@ SOURCES = \ Command.cpp \ SocketCommand.cpp \ Visit.cpp \ - Find.cpp \ Reset.cpp \ Node.cpp \ JavascriptInvocation.cpp \ @@ -124,7 +123,8 @@ SOURCES = \ ErrorMessage.cpp \ Title.cpp \ FindCss.cpp \ - JavascriptCommand.cpp + JavascriptCommand.cpp \ + FindXpath.cpp RESOURCES = webkit_server.qrc QT += network webkit