Permalink
Browse files

Support multi-line alert messages

  • Loading branch information...
1 parent eabe88e commit 2f9d76bfbbbbf1bb1c7b0dfee0d16ee573169e84 @mhoran mhoran committed Dec 30, 2012
Showing with 11 additions and 8 deletions.
  1. +1 −1 lib/capybara/webkit/browser.rb
  2. +2 −2 spec/driver_spec.rb
  3. +4 −1 src/JavascriptAlertMessages.cpp
  4. +2 −2 src/WebPage.cpp
  5. +2 −2 src/WebPage.h
View
2 lib/capybara/webkit/browser.rb
@@ -51,7 +51,7 @@ def error_messages
end
def alert_messages
- command("JavascriptAlertMessages").split("\n")
+ JSON.parse(command("JavascriptAlertMessages"))
end
def confirm_messages
View
4 spec/driver_spec.rb
@@ -537,7 +537,7 @@ def visit(url, driver=driver)
</head>
<body>
<script type="text/javascript">
- alert("Alert Text Goes Here");
+ alert("Alert Text\\nGoes Here");
</script>
</body>
</html>
@@ -547,7 +547,7 @@ def visit(url, driver=driver)
before { visit("/") }
it "should let me read my alert messages" do
- driver.alert_messages.first.should == "Alert Text Goes Here"
+ driver.alert_messages.first.should == "Alert Text\nGoes Here"
end
it "empties the array when reset" do
View
5 src/JavascriptAlertMessages.cpp
@@ -1,10 +1,13 @@
#include "JavascriptAlertMessages.h"
#include "WebPage.h"
#include "WebPageManager.h"
+#include "JsonSerializer.h"
JavascriptAlertMessages::JavascriptAlertMessages(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {}
void JavascriptAlertMessages::start()
{
- emitFinished(true, page()->alertMessages());
+ JsonSerializer serializer;
+ QByteArray json = serializer.serialize(page()->alertMessages());
+ emitFinished(true, json);
}
View
4 src/WebPage.cpp
@@ -87,8 +87,8 @@ QVariantList WebPage::consoleMessages() {
return m_consoleMessages;
}
-QString WebPage::alertMessages() {
- return m_alertMessages.join("\n");
+QVariantList WebPage::alertMessages() {
+ return m_alertMessages;
}
QVariantList WebPage::confirmMessages() {
View
4 src/WebPage.h
@@ -24,7 +24,7 @@ class WebPage : public QWebPage {
virtual bool extension (Extension extension, const ExtensionOption *option=0, ExtensionReturn *output=0);
void setSkipImageLoading(bool skip);
QVariantList consoleMessages();
- QString alertMessages();
+ QVariantList alertMessages();
QVariantList confirmMessages();
QString promptMessages();
void resetWindowSize();
@@ -72,7 +72,7 @@ class WebPage : public QWebPage {
bool m_confirm;
bool m_prompt;
QVariantList m_consoleMessages;
- QStringList m_alertMessages;
+ QVariantList m_alertMessages;
QVariantList m_confirmMessages;
QString m_prompt_text;
QStringList m_promptMessages;

0 comments on commit 2f9d76b

Please sign in to comment.