diff --git a/src/commands.hxx b/src/commands.hxx index b475ad0..2bf57a4 100644 --- a/src/commands.hxx +++ b/src/commands.hxx @@ -1382,9 +1382,12 @@ class Exists: public Command { Logger log(this, script); QString selector(script->replacevars(_selector)); QString text(script->replacevars(_text)); + QStringList notfound; Q_FOREACH(QWebElement element, frame->findAllElements(selector)) { if (text.isEmpty()) return true; // just find element if (element.toOuterXml().indexOf(text)!=-1) return true; + if (element.toPlainText().indexOf(text)!=-1) return true; + notfound += element.toOuterXml(); } QWebElement element(find(frame, selector)); if (text.isEmpty()) @@ -1394,7 +1397,7 @@ class Exists: public Command { +selector); else throw AssertionFailed("not found \""+text+"\" in \"" - +element.toOuterXml()+"\" on "+selector); + +notfound.join("\", \"")+"\" on "+selector); return true; // never reached due to throw above } private: @@ -2082,8 +2085,8 @@ class If: public Command { " <...>\n" "\n\n" "Execute commands conditionally. " - "The comparision can be = ^ ~ < >, " - "which means equal, different, match, " + "The comparision can be = ^ . ~ < >, " + "which means equal, different, contains, match, " "less (as integer), bigger (as integer). " "Match allows a regular expression. " "There is an optional else part."; @@ -2096,7 +2099,7 @@ class If: public Command { QStringList& in, QString file, int line, int indent) { std::shared_ptr cmd(new If()); - int pos(args.indexOf(QRegularExpression("[=^~<>]"))); + int pos(args.indexOf(QRegularExpression("[=^.~<>]"))); if (pos<0) throw BadArgument(tag()+" needs a comparision, not: "+args); cmd->_variable = args.left(pos).trimmed(); cmd->_cmp = args[pos].toLatin1(); @@ -2119,6 +2122,8 @@ class If: public Command { break; case '^': check = script->variable(_variable)!=value; break; + case '.': check = script->variable(_variable).contains(value); + break; case '~': check = script->variable(_variable).contains(QRegularExpression(value)); break; @@ -2216,8 +2221,8 @@ class Check: public Command { " output, such as , which returns the result of JavaScript or" " , which returns the output of the executed command, or" " , which returns the result of the last command. " - "The comparision can be = ^ ~ < >, " - "which means equal, different, match, " + "The comparision can be = ^ . ~ < >, " + "which means equal, different, contains match, " "less (as integer), bigger (as integer). " "Match allows a regular expression. " " less than < (integers), larger than > (integers)"; @@ -2233,7 +2238,7 @@ class Check: public Command { int indent) { std::shared_ptr cmd(new Check()); cmd->_next = 0; - int pos(args.indexOf(QRegularExpression("[=^~<>]"))); + int pos(args.indexOf(QRegularExpression("[=^.~<>]"))); if (pos<0) throw BadArgument(tag()+" needs a comparision, not: "+args); cmd->_value1 = args.left(pos).trimmed(); cmd->_cmp = args[pos].toLatin1(); @@ -2256,6 +2261,7 @@ class Check: public Command { switch (_cmp) { case '=': check = value1==value2; break; case '^': check = value1!=value2; break; + case '.': check = value1.contains(value2); break; case '~': check = value1.contains(QRegularExpression(value2)); break; case '<': check = value1.toInt()': check = value1.toInt()>value2.toInt(); break; @@ -2302,7 +2308,7 @@ class For: public Command { if (!args.size()) throw BadArgument(tag()+" requires a "); QStringList allargs(args.split("->")); cmd->_variable = allargs.takeFirst().trimmed(); - cmd->_vals = commaSeparatedList(allargs.join(' ')); + cmd->_vals = commaSeparatedList(allargs.join("->")); cmd->_script = std::shared_ptr