mirror of
https://github.com/thoughtbot/capybara-webkit
synced 2023-03-27 23:22:28 -04:00
Implement Browser#title
This commit is contained in:
parent
09e19e305f
commit
fda0894f76
8 changed files with 46 additions and 2 deletions
|
@ -22,6 +22,10 @@ module Capybara::Webkit
|
|||
command("Header", key, value)
|
||||
end
|
||||
|
||||
def title
|
||||
command("Title")
|
||||
end
|
||||
|
||||
def find(query)
|
||||
command("Find", query).split(",")
|
||||
end
|
||||
|
|
|
@ -41,6 +41,10 @@ module Capybara::Webkit
|
|||
browser.header(key, value)
|
||||
end
|
||||
|
||||
def title
|
||||
browser.title
|
||||
end
|
||||
|
||||
def execute_script(script)
|
||||
value = browser.execute_script script
|
||||
value.empty? ? nil : value
|
||||
|
|
|
@ -41,6 +41,7 @@ describe Capybara::Webkit::Driver do
|
|||
<<-HTML
|
||||
<html>
|
||||
<head>
|
||||
<title>Title</title>
|
||||
<style type="text/css">
|
||||
#display_none { display: none }
|
||||
</style>
|
||||
|
@ -150,6 +151,12 @@ describe Capybara::Webkit::Driver do
|
|||
driver.status_code.should == 200
|
||||
end
|
||||
end
|
||||
|
||||
it "returns the document title" do
|
||||
driver.within_frame("f") do
|
||||
driver.title.should == "Title"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "error iframe app" do
|
||||
|
@ -299,6 +306,7 @@ describe Capybara::Webkit::Driver do
|
|||
driver_for_html(<<-HTML)
|
||||
<html>
|
||||
<head>
|
||||
<title>Title</title>
|
||||
<style type="text/css">
|
||||
#display_none { display: none }
|
||||
#visibility_hidden { visibility: hidden }
|
||||
|
@ -490,6 +498,10 @@ describe Capybara::Webkit::Driver do
|
|||
driver.find("//*[@id='invisible']").first.should_not be_visible
|
||||
driver.find("//*[@id='invisible_with_visibility']").first.should_not be_visible
|
||||
end
|
||||
|
||||
it "returns the document title" do
|
||||
driver.title.should == "Title"
|
||||
end
|
||||
end
|
||||
|
||||
context "svg app" do
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "JavascriptPromptMessages.h"
|
||||
#include "SetUrlBlacklist.h"
|
||||
#include "Version.h"
|
||||
#include "Title.h"
|
||||
|
||||
CommandFactory::CommandFactory(WebPageManager *manager, QObject *parent) : QObject(parent) {
|
||||
m_manager = manager;
|
||||
|
|
11
src/Title.cpp
Normal file
11
src/Title.cpp
Normal file
|
@ -0,0 +1,11 @@
|
|||
#include "Title.h"
|
||||
#include "WebPage.h"
|
||||
#include "WebPageManager.h"
|
||||
#include "NetworkAccessManager.h"
|
||||
|
||||
Title::Title(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
||||
}
|
||||
|
||||
void Title::start() {
|
||||
finish(true, page()->currentFrame()->title());
|
||||
}
|
9
src/Title.h
Normal file
9
src/Title.h
Normal file
|
@ -0,0 +1,9 @@
|
|||
#include "SocketCommand.h"
|
||||
|
||||
class Title : public SocketCommand {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Title(WebPageManager *, QStringList &arguments, QObject *parent = 0);
|
||||
virtual void start();
|
||||
};
|
|
@ -39,5 +39,6 @@ CHECK_COMMAND(JavascriptPromptMessages)
|
|||
CHECK_COMMAND(GetTimeout)
|
||||
CHECK_COMMAND(SetTimeout)
|
||||
CHECK_COMMAND(SetUrlBlacklist)
|
||||
CHECK_COMMAND(Title)
|
||||
|
||||
CHECK_COMMAND(Version)
|
||||
|
|
|
@ -58,7 +58,8 @@ HEADERS = \
|
|||
NoOpReply.h \
|
||||
JsonSerializer.h \
|
||||
InvocationResult.h \
|
||||
ErrorMessage.h
|
||||
ErrorMessage.h \
|
||||
Title.h
|
||||
|
||||
SOURCES = \
|
||||
Version.cpp \
|
||||
|
@ -118,7 +119,8 @@ SOURCES = \
|
|||
NoOpReply.cpp \
|
||||
JsonSerializer.cpp \
|
||||
InvocationResult.cpp \
|
||||
ErrorMessage.cpp
|
||||
ErrorMessage.cpp \
|
||||
Title.cpp
|
||||
|
||||
RESOURCES = webkit_server.qrc
|
||||
QT += network webkit
|
||||
|
|
Loading…
Add table
Reference in a new issue