|
|
|
@ -113,6 +113,8 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
|
} |
|
|
|
|
void on__run_clicked() { |
|
|
|
|
bool oldRecordState(_record->isChecked()); |
|
|
|
|
_record->setChecked(false); |
|
|
|
|
_record->setEnabled(false); |
|
|
|
|
_run->setEnabled(false); |
|
|
|
|
try { |
|
|
|
|
Script script; |
|
|
|
@ -134,6 +136,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
|
.arg(x.what())); |
|
|
|
|
} |
|
|
|
|
_run->setEnabled(true); |
|
|
|
|
_record->setEnabled(true); |
|
|
|
|
_record->setChecked(oldRecordState); |
|
|
|
|
} |
|
|
|
|
void on__focused_clicked() { |
|
|
|
@ -325,26 +328,9 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
|
_lastFocused=element; |
|
|
|
|
if (_record->isChecked()) { |
|
|
|
|
if (!element.isNull()) { |
|
|
|
|
QString selected(selector(_lastFocused)); |
|
|
|
|
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 "+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")); |
|
|
|
|
QString selected(selector(element)); |
|
|
|
|
if (handleMooTools(_lastFocused)) { |
|
|
|
|
// handled in handleMooTools
|
|
|
|
|
} else if (_lastFocused.tagName()=="SELECT") { |
|
|
|
|
// click on a select results in a value change
|
|
|
|
|
// find all selected options ...
|
|
|
|
@ -356,15 +342,14 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
|
v += value(option); |
|
|
|
|
} |
|
|
|
|
setValue(selected, v); |
|
|
|
|
} else { |
|
|
|
|
appendCommand("click "+map(selected)); |
|
|
|
|
} |
|
|
|
|
if (_lastFocused.tagName()=="TEXTAREA" || |
|
|
|
|
} else if (_lastFocused.tagName()=="TEXTAREA" || |
|
|
|
|
_lastFocused.tagName()=="INPUT" && |
|
|
|
|
_lastFocused.attribute("type")=="text") { |
|
|
|
|
// user clickt in a text edit field, so not the klick
|
|
|
|
|
// is important, but the text that will be typed
|
|
|
|
|
_typing = true; |
|
|
|
|
} else { |
|
|
|
|
appendCommand("click "+map(selected)); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
appendCommand("# click, but where?"); |
|
|
|
@ -531,7 +516,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
|
void javascript(const QString& selector, QString code) { |
|
|
|
|
if (_record->isChecked()) |
|
|
|
|
appendCommand("do "+map(selector)+"\n " |
|
|
|
|
+map(code).replace("\n", "\\n")); |
|
|
|
|
+map(code).replace("\n", "\n ")); |
|
|
|
|
} |
|
|
|
|
void cleanup(const QString& selector) { |
|
|
|
|
QString text(_testscript->toPlainText()); |
|
|
|
@ -565,6 +550,53 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
|
.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) { |
|
|
|
|
javascript(selector, code); |
|
|
|
|
return _web->page()->mainFrame()->documentElement().findFirst(selector) |
|
|
|
|