mirror of
https://github.com/thoughtbot/capybara-webkit
synced 2023-03-27 23:22:28 -04:00
Implement source for driver.
This commit is contained in:
parent
92a17ae94e
commit
003529cd9f
8 changed files with 42 additions and 3 deletions
|
@ -29,7 +29,7 @@ class Capybara::Driver::Webkit
|
|||
end
|
||||
|
||||
def source
|
||||
raise NotImplementedError
|
||||
browser.source
|
||||
end
|
||||
|
||||
def body
|
||||
|
|
|
@ -19,6 +19,10 @@ class Capybara::Driver::Webkit
|
|||
command("Reset")
|
||||
end
|
||||
|
||||
def source
|
||||
command("Source")
|
||||
end
|
||||
|
||||
def url
|
||||
command("Url")
|
||||
end
|
||||
|
|
|
@ -43,5 +43,14 @@ describe Capybara::Driver::Webkit do
|
|||
port = subject.instance_variable_get("@rack_server").port
|
||||
subject.current_url.should == "http://127.0.0.1:#{port}/hello/world?success=true"
|
||||
end
|
||||
|
||||
it "returns the source code for the page" do
|
||||
subject.source.should == %{<html><head></head><body>
|
||||
<script type="text/javascript">
|
||||
document.write("<p id='greeting'>he" + "llo</p>");
|
||||
</script><p id="greeting">hello</p>
|
||||
|
||||
</body></html>}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "Reset.h"
|
||||
#include "Attribute.h"
|
||||
#include "Url.h"
|
||||
#include "Source.h"
|
||||
|
||||
#include <QTcpSocket>
|
||||
#include <iostream>
|
||||
|
|
12
src/Source.cpp
Normal file
12
src/Source.cpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
#include "Source.h"
|
||||
#include "WebPage.h"
|
||||
|
||||
Source::Source(WebPage *page, QObject *parent) : Command(page, parent) {
|
||||
}
|
||||
|
||||
void Source::start() {
|
||||
QString response = page()->mainFrame()->toHtml();
|
||||
|
||||
emit finished(true, response);
|
||||
}
|
||||
|
12
src/Source.h
Normal file
12
src/Source.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#include "Command.h"
|
||||
|
||||
class WebPage;
|
||||
|
||||
class Source : public Command {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Source(WebPage *page, QObject *parent = 0);
|
||||
virtual void start();
|
||||
};
|
||||
|
|
@ -8,3 +8,4 @@ CHECK_COMMAND(Find)
|
|||
CHECK_COMMAND(Reset)
|
||||
CHECK_COMMAND(Attribute)
|
||||
CHECK_COMMAND(Url)
|
||||
CHECK_COMMAND(Source)
|
|
@ -1,8 +1,8 @@
|
|||
TEMPLATE = app
|
||||
TARGET = webkit_server
|
||||
DESTDIR = .
|
||||
HEADERS = WebPage.h Server.h Connection.h Command.h Visit.h Find.h Reset.h Attribute.h Url.h
|
||||
SOURCES = main.cpp WebPage.cpp Server.cpp Connection.cpp Command.cpp Visit.cpp Find.cpp Reset.cpp Attribute.cpp Url.cpp
|
||||
HEADERS = WebPage.h Server.h Connection.h Command.h Visit.h Find.h Reset.h Attribute.h Url.h Source.h
|
||||
SOURCES = main.cpp WebPage.cpp Server.cpp Connection.cpp Command.cpp Visit.cpp Find.cpp Reset.cpp Attribute.cpp Url.cpp Source.cpp
|
||||
QT += network webkit
|
||||
CONFIG += console staticlib
|
||||
|
||||
|
|
Loading…
Reference in a new issue