Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Implement source for driver.

  • Loading branch information...
commit 003529cd9f3b848be59a373b9a5154fa61d50e9e 1 parent 92a17ae
@tristandunn tristandunn authored
View
2  lib/capybara/driver/webkit.rb
@@ -29,7 +29,7 @@ def find(query)
end
def source
- raise NotImplementedError
+ browser.source
end
def body
View
4 lib/capybara/driver/webkit/browser.rb
@@ -19,6 +19,10 @@ def reset!
command("Reset")
end
+ def source
+ command("Source")
+ end
+
def url
command("Url")
end
View
9 spec/driver_spec.rb
@@ -43,5 +43,14 @@
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
View
1  src/Connection.cpp
@@ -5,6 +5,7 @@
#include "Reset.h"
#include "Attribute.h"
#include "Url.h"
+#include "Source.h"
#include <QTcpSocket>
#include <iostream>
View
12 src/Source.cpp
@@ -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);
+}
+
View
12 src/Source.h
@@ -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();
+};
+
View
1  src/find_command.h
@@ -8,3 +8,4 @@ CHECK_COMMAND(Find)
CHECK_COMMAND(Reset)
CHECK_COMMAND(Attribute)
CHECK_COMMAND(Url)
+CHECK_COMMAND(Source)
View
4 src/webkit_server.pro
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.