mirror of
https://github.com/thoughtbot/capybara-webkit
synced 2023-03-27 23:22:28 -04:00
Rename Find command to FindXpath
This commit is contained in:
parent
121a360e75
commit
60a8300821
10 changed files with 40 additions and 40 deletions
|
@ -27,7 +27,7 @@ module Capybara::Webkit
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_xpath(query)
|
def find_xpath(query)
|
||||||
command("Find", query).split(",")
|
command("FindXpath", query).split(",")
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_css(query)
|
def find_css(query)
|
||||||
|
|
|
@ -96,7 +96,7 @@ module Capybara::Webkit
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_xpath(xpath)
|
def find_xpath(xpath)
|
||||||
invoke("findWithin", xpath).split(',').map do |native|
|
invoke("findXpathWithin", xpath).split(',').map do |native|
|
||||||
self.class.new(driver, native)
|
self.class.new(driver, native)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "CommandFactory.h"
|
#include "CommandFactory.h"
|
||||||
#include "NullCommand.h"
|
#include "NullCommand.h"
|
||||||
#include "Visit.h"
|
#include "Visit.h"
|
||||||
#include "Find.h"
|
#include "FindXpath.h"
|
||||||
#include "Reset.h"
|
#include "Reset.h"
|
||||||
#include "Node.h"
|
#include "Node.h"
|
||||||
#include "Evaluate.h"
|
#include "Evaluate.h"
|
||||||
|
|
13
src/Find.cpp
13
src/Find.cpp
|
@ -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);
|
|
||||||
}
|
|
||||||
|
|
11
src/Find.h
11
src/Find.h
|
@ -1,11 +0,0 @@
|
||||||
#include "JavascriptCommand.h"
|
|
||||||
|
|
||||||
class Find : public JavascriptCommand {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
Find(WebPageManager *, QStringList &arguments, QObject *parent = 0);
|
|
||||||
virtual void start();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
13
src/FindXpath.cpp
Normal file
13
src/FindXpath.cpp
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
|
11
src/FindXpath.h
Normal file
11
src/FindXpath.h
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#include "JavascriptCommand.h"
|
||||||
|
|
||||||
|
class FindXpath : public JavascriptCommand {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
FindXpath(WebPageManager *, QStringList &arguments, QObject *parent = 0);
|
||||||
|
virtual void start();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
|
@ -11,23 +11,23 @@ Capybara = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
find: function (xpath) {
|
findXpath: function (xpath) {
|
||||||
return this.findRelativeTo(document, xpath);
|
return this.findXpathRelativeTo(document, xpath);
|
||||||
},
|
},
|
||||||
|
|
||||||
findCss: function (selector) {
|
findCss: function (selector) {
|
||||||
return this.findRelativeToSelector(document, selector);
|
return this.findCssRelativeTo(document, selector);
|
||||||
},
|
},
|
||||||
|
|
||||||
findWithin: function (index, xpath) {
|
findXpathWithin: function (index, xpath) {
|
||||||
return this.findRelativeTo(this.nodes[index], xpath);
|
return this.findXpathRelativeTo(this.nodes[index], xpath);
|
||||||
},
|
},
|
||||||
|
|
||||||
findCssWithin: function (index, selector) {
|
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 iterator = document.evaluate(xpath, reference, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
|
||||||
var node;
|
var node;
|
||||||
var results = [];
|
var results = [];
|
||||||
|
@ -39,7 +39,7 @@ Capybara = {
|
||||||
return results.join(",");
|
return results.join(",");
|
||||||
},
|
},
|
||||||
|
|
||||||
findRelativeToSelector: function (reference, selector) {
|
findCssRelativeTo: function (reference, selector) {
|
||||||
var elements = reference.querySelectorAll(selector);
|
var elements = reference.querySelectorAll(selector);
|
||||||
var results = [];
|
var results = [];
|
||||||
for (var i = 0; i < elements.length; i++) {
|
for (var i = 0; i < elements.length; i++) {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_COMMAND(Visit)
|
CHECK_COMMAND(Visit)
|
||||||
CHECK_COMMAND(Find)
|
CHECK_COMMAND(FindXpath)
|
||||||
CHECK_COMMAND(Reset)
|
CHECK_COMMAND(Reset)
|
||||||
CHECK_COMMAND(Node)
|
CHECK_COMMAND(Node)
|
||||||
CHECK_COMMAND(Evaluate)
|
CHECK_COMMAND(Evaluate)
|
||||||
|
|
|
@ -22,7 +22,6 @@ HEADERS = \
|
||||||
Command.h \
|
Command.h \
|
||||||
SocketCommand.h \
|
SocketCommand.h \
|
||||||
Visit.h \
|
Visit.h \
|
||||||
Find.h \
|
|
||||||
Reset.h \
|
Reset.h \
|
||||||
Node.h \
|
Node.h \
|
||||||
JavascriptInvocation.h \
|
JavascriptInvocation.h \
|
||||||
|
@ -61,7 +60,8 @@ HEADERS = \
|
||||||
ErrorMessage.h \
|
ErrorMessage.h \
|
||||||
Title.h \
|
Title.h \
|
||||||
FindCss.h \
|
FindCss.h \
|
||||||
JavascriptCommand.h
|
JavascriptCommand.h \
|
||||||
|
FindXpath.h
|
||||||
|
|
||||||
SOURCES = \
|
SOURCES = \
|
||||||
Version.cpp \
|
Version.cpp \
|
||||||
|
@ -85,7 +85,6 @@ SOURCES = \
|
||||||
Command.cpp \
|
Command.cpp \
|
||||||
SocketCommand.cpp \
|
SocketCommand.cpp \
|
||||||
Visit.cpp \
|
Visit.cpp \
|
||||||
Find.cpp \
|
|
||||||
Reset.cpp \
|
Reset.cpp \
|
||||||
Node.cpp \
|
Node.cpp \
|
||||||
JavascriptInvocation.cpp \
|
JavascriptInvocation.cpp \
|
||||||
|
@ -124,7 +123,8 @@ SOURCES = \
|
||||||
ErrorMessage.cpp \
|
ErrorMessage.cpp \
|
||||||
Title.cpp \
|
Title.cpp \
|
||||||
FindCss.cpp \
|
FindCss.cpp \
|
||||||
JavascriptCommand.cpp
|
JavascriptCommand.cpp \
|
||||||
|
FindXpath.cpp
|
||||||
|
|
||||||
RESOURCES = webkit_server.qrc
|
RESOURCES = webkit_server.qrc
|
||||||
QT += network webkit
|
QT += network webkit
|
||||||
|
|
Loading…
Add table
Reference in a new issue