From 35f5aa9676b2aa90ee6ce1d539b10f1c56d573ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=A4ckerlin?= Date: Thu, 5 Jan 2017 14:25:03 +0000 Subject: [PATCH] more improve expect load; better logging in case of exception --- src/commands.hxx | 237 +++++++++++++++++++++++++---------------------- 1 file changed, 127 insertions(+), 110 deletions(-) diff --git a/src/commands.hxx b/src/commands.hxx index fe7386d..efa96ee 100644 --- a/src/commands.hxx +++ b/src/commands.hxx @@ -98,6 +98,10 @@ class Command: public QObject { virtual std::shared_ptr parse(Script*, QString, QStringList&, QString, int, int) = 0; virtual bool execute(Script*, QWebFrame*) = 0; + static void error(Logger& log, const Exception& e) { + log(QString(" FAILED: ")+e.what()); + throw e; + } void line(int linenr) { _line = linenr; } @@ -128,9 +132,9 @@ class Command: public QObject { virtual bool isTestcase() { return true; } - static void realMouseClick(QWebFrame* frame, QString selector) { + static void realMouseClick(Logger& log, QWebFrame* frame, QString selector) { QWebElement element(find(frame, selector)); - if (element.isNull()) throw ElementNotFound(selector); + if (element.isNull()) error(log, ElementNotFound(selector)); realMouseClick(element); } static void realMouseClick(const QWebElement& element) { @@ -168,7 +172,7 @@ class Command: public QObject { QCoreApplication::processEvents(QEventLoop::AllEvents, 100); } protected: - bool runScript(Command* parentCommand, + bool runScript(Logger& log, Command* parentCommand, std::shared_ptr