|
|
|
@ -14,6 +14,7 @@ |
|
|
|
|
#include <QWebFrame> |
|
|
|
|
#include <QWebElement> |
|
|
|
|
#include <QFileDialog> |
|
|
|
|
#include <QScrollBar> |
|
|
|
|
#include <QFile> |
|
|
|
|
#include <QMessageBox> |
|
|
|
|
#include <ui_testgui.h> |
|
|
|
@ -49,7 +50,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
|
void on__load_clicked() { |
|
|
|
|
enterText(true); |
|
|
|
|
if (_record->isChecked()) |
|
|
|
|
_testscript->appendPlainText("load "+_url->text()); |
|
|
|
|
appendCommand("load "+_url->text()); |
|
|
|
|
_web->load(_url->text()); |
|
|
|
|
} |
|
|
|
|
void on__abort_clicked() { |
|
|
|
@ -109,6 +110,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
|
} |
|
|
|
|
void on__actionClear_triggered() { |
|
|
|
|
_testscript->clear(); |
|
|
|
|
_log->clear(); |
|
|
|
|
_filename.clear(); |
|
|
|
|
_actionSave->setEnabled(false); |
|
|
|
|
_actionRevertToSaved->setEnabled(false); |
|
|
|
@ -171,7 +173,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
|
void on__web_linkClicked(const QUrl& url) { |
|
|
|
|
enterText(true); |
|
|
|
|
if (_record->isChecked()) |
|
|
|
|
_testscript->appendPlainText("load "+url.url()); |
|
|
|
|
appendCommand("load "+url.url()); |
|
|
|
|
} |
|
|
|
|
void on__web_loadProgress(int progress) { |
|
|
|
|
enterText(true); |
|
|
|
@ -180,7 +182,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
|
void on__web_loadStarted() { |
|
|
|
|
enterText(true); |
|
|
|
|
if (_record->isChecked()) |
|
|
|
|
_testscript->appendPlainText("expect loadStarted"); |
|
|
|
|
appendCommand("expect loadStarted"); |
|
|
|
|
_progress->setValue(0); |
|
|
|
|
_urlStack->setCurrentIndex(PROGRESS_VIEW); |
|
|
|
|
} |
|
|
|
@ -193,7 +195,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
|
void on__web_urlChanged(const QUrl& url) { |
|
|
|
|
enterText(true); |
|
|
|
|
if (_record->isChecked()) |
|
|
|
|
_testscript->appendPlainText("expect urlChanged "+url.url()); |
|
|
|
|
appendCommand("expect urlChanged "+url.url()); |
|
|
|
|
} |
|
|
|
|
void on__web_selectionChanged() { |
|
|
|
|
_source->setPlainText(_web->hasSelection() |
|
|
|
@ -203,7 +205,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
|
void on__web_loadFinished(bool ok) { |
|
|
|
|
enterText(true); |
|
|
|
|
if (_record->isChecked()) |
|
|
|
|
_testscript->appendPlainText("expect loadFinished " |
|
|
|
|
appendCommand("expect loadFinished " |
|
|
|
|
+QString(ok?"true":"false")); |
|
|
|
|
_urlStack->setCurrentIndex(URL_VIEW); |
|
|
|
|
on__web_selectionChanged(); |
|
|
|
@ -222,7 +224,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
|
void uploadFile(QString filename) { |
|
|
|
|
enterText(true); |
|
|
|
|
if (_record->isChecked()) |
|
|
|
|
_testscript->appendPlainText("upload "+filename); |
|
|
|
|
appendCommand("upload "+filename); |
|
|
|
|
} |
|
|
|
|
void unsupportedContent(QNetworkReply* reply) { |
|
|
|
|
if (!_record->isChecked()) return; |
|
|
|
@ -245,10 +247,19 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
|
} |
|
|
|
|
void downloadRequested(const QNetworkRequest&) { |
|
|
|
|
if (_record->isChecked()) |
|
|
|
|
_testscript->appendPlainText("download2"); |
|
|
|
|
appendCommand("download2"); |
|
|
|
|
} |
|
|
|
|
void logging(QString txt) { |
|
|
|
|
void logging(const QString& txt) { |
|
|
|
|
_log->appendPlainText(txt); |
|
|
|
|
QScrollBar *vb(_log->verticalScrollBar()); |
|
|
|
|
if (!vb) return; |
|
|
|
|
vb->setValue(vb->maximum()); |
|
|
|
|
} |
|
|
|
|
void appendCommand(const QString& txt) { |
|
|
|
|
_testscript->appendPlainText(txt); |
|
|
|
|
QScrollBar *vb(_testscript->verticalScrollBar()); |
|
|
|
|
if (!vb) return; |
|
|
|
|
vb->setValue(vb->maximum()); |
|
|
|
|
} |
|
|
|
|
protected: |
|
|
|
|
void closeEvent(QCloseEvent* event) { |
|
|
|
@ -301,16 +312,16 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
|
.match(selected)); |
|
|
|
|
if (mooCombo.hasMatch()) { |
|
|
|
|
// special treatment for moo tools combobox (e.g. used in joomla)
|
|
|
|
|
_testscript->appendPlainText("click "+mooCombo.captured(1)+">a"); |
|
|
|
|
_testscript->appendPlainText("sleep 1"); |
|
|
|
|
appendCommand("click "+mooCombo.captured(1)+">a"); |
|
|
|
|
appendCommand("sleep 1"); |
|
|
|
|
} else if (mooComboItem.hasMatch()) { |
|
|
|
|
// special treatment for item in moo tools combobox
|
|
|
|
|
_testscript->appendPlainText |
|
|
|
|
appendCommand |
|
|
|
|
("click li.active-result[data-option-array-index=\"" |
|
|
|
|
+element.attribute("data-option-array-index")+"\"]"); |
|
|
|
|
_testscript->appendPlainText("sleep 1"); |
|
|
|
|
appendCommand("sleep 1"); |
|
|
|
|
} else { |
|
|
|
|
_testscript->appendPlainText("click "+selected); |
|
|
|
|
appendCommand("click "+selected); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} break; |
|
|
|
@ -425,7 +436,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
|
} |
|
|
|
|
void store(const QString& selector, QString code) { |
|
|
|
|
if (_record->isChecked()) |
|
|
|
|
_testscript->appendPlainText("do "+selector+"\n " |
|
|
|
|
appendCommand("do "+selector+"\n " |
|
|
|
|
+code.replace("\n", "\\n")); |
|
|
|
|
} |
|
|
|
|
void execute(const QString& selector, const QString& code) { |
|
|
|
|