|
|
@ -113,6 +113,8 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
} |
|
|
|
} |
|
|
|
void on__run_clicked() { |
|
|
|
void on__run_clicked() { |
|
|
|
bool oldRecordState(_record->isChecked()); |
|
|
|
bool oldRecordState(_record->isChecked()); |
|
|
|
|
|
|
|
_record->setChecked(false); |
|
|
|
|
|
|
|
_record->setEnabled(false); |
|
|
|
_run->setEnabled(false); |
|
|
|
_run->setEnabled(false); |
|
|
|
try { |
|
|
|
try { |
|
|
|
Script script; |
|
|
|
Script script; |
|
|
@ -134,6 +136,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
.arg(x.what())); |
|
|
|
.arg(x.what())); |
|
|
|
} |
|
|
|
} |
|
|
|
_run->setEnabled(true); |
|
|
|
_run->setEnabled(true); |
|
|
|
|
|
|
|
_record->setEnabled(true); |
|
|
|
_record->setChecked(oldRecordState); |
|
|
|
_record->setChecked(oldRecordState); |
|
|
|
} |
|
|
|
} |
|
|
|
void on__focused_clicked() { |
|
|
|
void on__focused_clicked() { |
|
|
@ -325,26 +328,9 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
_lastFocused=element; |
|
|
|
_lastFocused=element; |
|
|
|
if (_record->isChecked()) { |
|
|
|
if (_record->isChecked()) { |
|
|
|
if (!element.isNull()) { |
|
|
|
if (!element.isNull()) { |
|
|
|
QString selected(selector(_lastFocused)); |
|
|
|
QString selected(selector(element)); |
|
|
|
QRegularExpressionMatch mooCombo |
|
|
|
if (handleMooTools(_lastFocused)) { |
|
|
|
(QRegularExpression("^(#jform_[_A-Za-z0-9]+)_chzn>.*$") |
|
|
|
// handled in handleMooTools
|
|
|
|
.match(selected)); |
|
|
|
|
|
|
|
QRegularExpressionMatch mooComboItem |
|
|
|
|
|
|
|
(QRegularExpression |
|
|
|
|
|
|
|
("^li\\.highlighted(\\.result-selected)?\\.active-result$") |
|
|
|
|
|
|
|
.match(selected)); |
|
|
|
|
|
|
|
if (mooCombo.hasMatch()) { |
|
|
|
|
|
|
|
// special treatment for moo tools combobox (e.g. used
|
|
|
|
|
|
|
|
// in joomla)
|
|
|
|
|
|
|
|
appendCommand("click "+map(mooCombo.captured(1)+">a")); |
|
|
|
|
|
|
|
appendCommand("sleep "+map("1")); |
|
|
|
|
|
|
|
} else if (mooComboItem.hasMatch()) { |
|
|
|
|
|
|
|
// special treatment for item in moo tools combobox
|
|
|
|
|
|
|
|
appendCommand |
|
|
|
|
|
|
|
("click "+map("li.active-result[data-option-array-index=\"" |
|
|
|
|
|
|
|
+element.attribute("data-option-array-index") |
|
|
|
|
|
|
|
+"\"]")); |
|
|
|
|
|
|
|
appendCommand("sleep "+map("1")); |
|
|
|
|
|
|
|
} else if (_lastFocused.tagName()=="SELECT") { |
|
|
|
} else if (_lastFocused.tagName()=="SELECT") { |
|
|
|
// click on a select results in a value change
|
|
|
|
// click on a select results in a value change
|
|
|
|
// find all selected options ...
|
|
|
|
// find all selected options ...
|
|
|
@ -356,15 +342,14 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
v += value(option); |
|
|
|
v += value(option); |
|
|
|
} |
|
|
|
} |
|
|
|
setValue(selected, v); |
|
|
|
setValue(selected, v); |
|
|
|
} else { |
|
|
|
} else if (_lastFocused.tagName()=="TEXTAREA" || |
|
|
|
appendCommand("click "+map(selected)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (_lastFocused.tagName()=="TEXTAREA" || |
|
|
|
|
|
|
|
_lastFocused.tagName()=="INPUT" && |
|
|
|
_lastFocused.tagName()=="INPUT" && |
|
|
|
_lastFocused.attribute("type")=="text") { |
|
|
|
_lastFocused.attribute("type")=="text") { |
|
|
|
// user clickt in a text edit field, so not the klick
|
|
|
|
// user clickt in a text edit field, so not the klick
|
|
|
|
// is important, but the text that will be typed
|
|
|
|
// is important, but the text that will be typed
|
|
|
|
_typing = true; |
|
|
|
_typing = true; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
appendCommand("click "+map(selected)); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
appendCommand("# click, but where?"); |
|
|
|
appendCommand("# click, but where?"); |
|
|
@ -531,7 +516,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
void javascript(const QString& selector, QString code) { |
|
|
|
void javascript(const QString& selector, QString code) { |
|
|
|
if (_record->isChecked()) |
|
|
|
if (_record->isChecked()) |
|
|
|
appendCommand("do "+map(selector)+"\n " |
|
|
|
appendCommand("do "+map(selector)+"\n " |
|
|
|
+map(code).replace("\n", "\\n")); |
|
|
|
+map(code).replace("\n", "\n ")); |
|
|
|
} |
|
|
|
} |
|
|
|
void cleanup(const QString& selector) { |
|
|
|
void cleanup(const QString& selector) { |
|
|
|
QString text(_testscript->toPlainText()); |
|
|
|
QString text(_testscript->toPlainText()); |
|
|
@ -565,6 +550,53 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
.join("', '")+"'")); |
|
|
|
.join("', '")+"'")); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
bool handleMooTools(QWebElement element) { |
|
|
|
|
|
|
|
QString selected(selector(element)); |
|
|
|
|
|
|
|
QRegularExpressionMatch mooCombo |
|
|
|
|
|
|
|
(QRegularExpression("^(#jform_[_A-Za-z0-9]+)_chzn>.*$") |
|
|
|
|
|
|
|
.match(selected)); |
|
|
|
|
|
|
|
QRegularExpressionMatch mooComboItem |
|
|
|
|
|
|
|
(QRegularExpression |
|
|
|
|
|
|
|
("^li\\.highlighted(\\.result-selected)?\\.active-result$") |
|
|
|
|
|
|
|
.match(selected)); |
|
|
|
|
|
|
|
if (mooCombo.hasMatch()) { |
|
|
|
|
|
|
|
// special treatment for moo tools combobox (e.g. used
|
|
|
|
|
|
|
|
// in joomla)
|
|
|
|
|
|
|
|
appendCommand("click realmouse "+map(mooCombo.captured(1)+">a")); |
|
|
|
|
|
|
|
appendCommand("sleep "+map("1")); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} else if (mooComboItem.hasMatch()) { |
|
|
|
|
|
|
|
// special treatment for item in moo tools combobox
|
|
|
|
|
|
|
|
appendCommand |
|
|
|
|
|
|
|
("click realmouse "+map("li.active-result[data-option-array-index=\"" |
|
|
|
|
|
|
|
+element.attribute("data-option-array-index") |
|
|
|
|
|
|
|
+"\"]")); |
|
|
|
|
|
|
|
appendCommand("sleep "+map("1")); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} else if (element.tagName()=="INPUT") { |
|
|
|
|
|
|
|
for (QWebElement e(element); !(e=e.parent()).isNull();) |
|
|
|
|
|
|
|
if (e.hasClass("chzn-container")) { |
|
|
|
|
|
|
|
_lastFocused = e; |
|
|
|
|
|
|
|
appendCommand("# moo tools combobox with search field"); |
|
|
|
|
|
|
|
appendCommand("# first set all elements visible"); |
|
|
|
|
|
|
|
javascript(map(selector(e)+" ul"), |
|
|
|
|
|
|
|
"this.style.height = \"auto\";\n" |
|
|
|
|
|
|
|
"this.style.maxHeight = \"auto\";\n" |
|
|
|
|
|
|
|
"this.style.overflow = \"visible\""); |
|
|
|
|
|
|
|
appendCommand("sleep "+map("1")); |
|
|
|
|
|
|
|
appendCommand("# moo tools open combobox"); |
|
|
|
|
|
|
|
appendCommand("click realmouse "+map(selector(e))); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else if (element.hasAttribute("id") && // is it a selected option?
|
|
|
|
|
|
|
|
element.attribute("id").contains("_chzn_o_")) { |
|
|
|
|
|
|
|
appendCommand("# moo tools select item"); |
|
|
|
|
|
|
|
appendCommand("click realmouse "+map(selector(element))); |
|
|
|
|
|
|
|
_lastFocused = element; |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
QString execute(const QString& selector, const QString& code) { |
|
|
|
QString execute(const QString& selector, const QString& code) { |
|
|
|
javascript(selector, code); |
|
|
|
javascript(selector, code); |
|
|
|
return _web->page()->mainFrame()->documentElement().findFirst(selector) |
|
|
|
return _web->page()->mainFrame()->documentElement().findFirst(selector) |
|
|
|