1
0
Fork 0
mirror of https://github.com/thoughtbot/capybara-webkit synced 2023-03-27 23:22:28 -04:00

Support multi-line confirmation messages

This commit is contained in:
Matthew Horan 2012-12-30 14:28:45 -05:00
parent 857a1a0383
commit eabe88e543
5 changed files with 15 additions and 6 deletions

View file

@ -55,7 +55,7 @@ module Capybara::Webkit
end
def confirm_messages
command("JavascriptConfirmMessages").split("\n")
JSON.parse(command("JavascriptConfirmMessages"))
end
def prompt_messages

View file

@ -615,6 +615,12 @@ describe Capybara::Webkit::Driver do
driver.find("//input").first.click
driver.console_messages.first[:message].should == "hello"
end
it "supports multi-line confirmation messages" do
driver.execute_script("confirm('Hello\\nnewline')")
driver.confirm_messages.first.should == "Hello\nnewline"
end
end
context "on a prompt app" do

View file

@ -1,10 +1,13 @@
#include "JavascriptConfirmMessages.h"
#include "WebPage.h"
#include "WebPageManager.h"
#include "JsonSerializer.h"
JavascriptConfirmMessages::JavascriptConfirmMessages(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {}
void JavascriptConfirmMessages::start()
{
emitFinished(true, page()->confirmMessages());
JsonSerializer serializer;
QByteArray json = serializer.serialize(page()->confirmMessages());
emitFinished(true, json);
}

View file

@ -91,8 +91,8 @@ QString WebPage::alertMessages() {
return m_alertMessages.join("\n");
}
QString WebPage::confirmMessages() {
return m_confirmMessages.join("\n");
QVariantList WebPage::confirmMessages() {
return m_confirmMessages;
}
QString WebPage::promptMessages() {

View file

@ -25,7 +25,7 @@ class WebPage : public QWebPage {
void setSkipImageLoading(bool skip);
QVariantList consoleMessages();
QString alertMessages();
QString confirmMessages();
QVariantList confirmMessages();
QString promptMessages();
void resetWindowSize();
QWebPage *createWindow(WebWindowType type);
@ -73,7 +73,7 @@ class WebPage : public QWebPage {
bool m_prompt;
QVariantList m_consoleMessages;
QStringList m_alertMessages;
QStringList m_confirmMessages;
QVariantList m_confirmMessages;
QString m_prompt_text;
QStringList m_promptMessages;
QString m_uuid;