mirror of
https://github.com/thoughtbot/capybara-webkit
synced 2023-03-27 23:22:28 -04:00
Support multi-line alert messages
This commit is contained in:
parent
eabe88e543
commit
2f9d76bfbb
5 changed files with 11 additions and 8 deletions
|
@ -51,7 +51,7 @@ module Capybara::Webkit
|
||||||
end
|
end
|
||||||
|
|
||||||
def alert_messages
|
def alert_messages
|
||||||
command("JavascriptAlertMessages").split("\n")
|
JSON.parse(command("JavascriptAlertMessages"))
|
||||||
end
|
end
|
||||||
|
|
||||||
def confirm_messages
|
def confirm_messages
|
||||||
|
|
|
@ -537,7 +537,7 @@ describe Capybara::Webkit::Driver do
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
alert("Alert Text Goes Here");
|
alert("Alert Text\\nGoes Here");
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -547,7 +547,7 @@ describe Capybara::Webkit::Driver do
|
||||||
before { visit("/") }
|
before { visit("/") }
|
||||||
|
|
||||||
it "should let me read my alert messages" do
|
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
|
end
|
||||||
|
|
||||||
it "empties the array when reset" do
|
it "empties the array when reset" do
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
#include "JavascriptAlertMessages.h"
|
#include "JavascriptAlertMessages.h"
|
||||||
#include "WebPage.h"
|
#include "WebPage.h"
|
||||||
#include "WebPageManager.h"
|
#include "WebPageManager.h"
|
||||||
|
#include "JsonSerializer.h"
|
||||||
|
|
||||||
JavascriptAlertMessages::JavascriptAlertMessages(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {}
|
JavascriptAlertMessages::JavascriptAlertMessages(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {}
|
||||||
|
|
||||||
void JavascriptAlertMessages::start()
|
void JavascriptAlertMessages::start()
|
||||||
{
|
{
|
||||||
emitFinished(true, page()->alertMessages());
|
JsonSerializer serializer;
|
||||||
|
QByteArray json = serializer.serialize(page()->alertMessages());
|
||||||
|
emitFinished(true, json);
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,8 +87,8 @@ QVariantList WebPage::consoleMessages() {
|
||||||
return m_consoleMessages;
|
return m_consoleMessages;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString WebPage::alertMessages() {
|
QVariantList WebPage::alertMessages() {
|
||||||
return m_alertMessages.join("\n");
|
return m_alertMessages;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantList WebPage::confirmMessages() {
|
QVariantList WebPage::confirmMessages() {
|
||||||
|
|
|
@ -24,7 +24,7 @@ class WebPage : public QWebPage {
|
||||||
virtual bool extension (Extension extension, const ExtensionOption *option=0, ExtensionReturn *output=0);
|
virtual bool extension (Extension extension, const ExtensionOption *option=0, ExtensionReturn *output=0);
|
||||||
void setSkipImageLoading(bool skip);
|
void setSkipImageLoading(bool skip);
|
||||||
QVariantList consoleMessages();
|
QVariantList consoleMessages();
|
||||||
QString alertMessages();
|
QVariantList alertMessages();
|
||||||
QVariantList confirmMessages();
|
QVariantList confirmMessages();
|
||||||
QString promptMessages();
|
QString promptMessages();
|
||||||
void resetWindowSize();
|
void resetWindowSize();
|
||||||
|
@ -72,7 +72,7 @@ class WebPage : public QWebPage {
|
||||||
bool m_confirm;
|
bool m_confirm;
|
||||||
bool m_prompt;
|
bool m_prompt;
|
||||||
QVariantList m_consoleMessages;
|
QVariantList m_consoleMessages;
|
||||||
QStringList m_alertMessages;
|
QVariantList m_alertMessages;
|
||||||
QVariantList m_confirmMessages;
|
QVariantList m_confirmMessages;
|
||||||
QString m_prompt_text;
|
QString m_prompt_text;
|
||||||
QStringList m_promptMessages;
|
QStringList m_promptMessages;
|
||||||
|
|
Loading…
Reference in a new issue