if else imacros with javascript command

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了if else imacros with javascript command相关的知识,希望对你有一定的参考价值。

请帮我处理我的脚本我想检查{{!COL22}} NOT NULL的复选框,如果{{!COL22}}是NULL,请取消选中该复选框

但此脚本在此语句中无法使用格式化条件

if ("{{!COL22}}" = "") {
        var uncheck = "CODE:";
        uncheck += "FRAME NAME="rf"" + "
";
        uncheck += "TAG POS=1 TYPE=LABEL ATTR=ONCLICK:publishVipJS.toggleSaleAttr(this,'text');&&FOR:testsale2260958&&DATA:9248:2260958&&TXT:" + "
";
        uncheck += "TAG POS=1 TYPE=INPUT:CHECKBOX ATTR=ID:testsale2260958 CONTENT=NO" + "
";
        iimset(uncheck);
        iimPlay(uncheck);
        var notif = alert("NULL");
    }else{
        var check = "CODE:";
        check += "FRAME NAME="rf"" + "
";
        check += "TAG POS=1 TYPE=LABEL ATTR=ONCLICK:publishVipJS.toggleSaleAttr(this,'text');&&FOR:testsale2260958&&DATA:9248:2260958&&TXT:" + "
";
        check += "TAG POS=1 TYPE=INPUT:CHECKBOX ATTR=ID:testsale2260958 CONTENT=YES" + "
";
        iimset(check);
        iimPlay(check);
        var notif = alert("SUCCSES");
    }

完整的脚本如下

var isi = "CODE:";
isi += "VERSION BUILD=8970419 RECORDER=FX" + "
";
isi += "TAB T=1" + "
";
isi += "SET !REPLAYSPEED FAST" + "
";
isi += "SET !ERRORIGNORE YES" + "
";
isi += "SET !TIMEOUT_PAGE 20" + "
";
isi += "SET !TIMEOUT_STEP 0" + "
";
isi += "SET !DATASOURCE_LINE {{!LOOP}}" + "
";
isi += "SET !DATASOURCE Shoes<SP>05-04-2018.csv" + "
";
isi += "SET !LOOP 4" + "
";
isi += "FRAME NAME="mainFrame"" + "
";
isi += "EVENT TYPE=CLICK SELECTOR="#mainContent>DIV:nth-of-type(29)>DIV>DIV>INPUT:nth-of-type(2)" BUTTON=0" + "
";
isi += "TAG POS=1 TYPE=INPUT:TEXT ATTR=TYPE:text&&ONCHANGE:publishVipJS.changeAlias(this,<SP>'text');&&VALUE:* CONTENT=" + "
";
isi += "FRAME NAME="rf"" + "
";
isi += "TAG POS=101 TYPE=INPUT:TEXT ATTR=* CONTENT={{!COL22}}" + "
";
isi += "FRAME F=0" + "
";
isi += "TAG POS=1 TYPE=A ATTR=CLASS:btn" + "
";
iimPlay(isi);

if ("{{!COL22}}" = "") {
    var uncheck = "CODE:";
    uncheck += "FRAME NAME="rf"" + "
";
    uncheck += "TAG POS=1 TYPE=LABEL ATTR=ONCLICK:publishVipJS.toggleSaleAttr(this,'text');&&FOR:testsale2260958&&DATA:9248:2260958&&TXT:" + "
";
    uncheck += "TAG POS=1 TYPE=INPUT:CHECKBOX ATTR=ID:testsale2260958 CONTENT=NO" + "
";
    iimset(uncheck);
    iimPlay(uncheck);
    var notif = alert("NULL");
}else{
    var check = "CODE:";
    check += "FRAME NAME="rf"" + "
";
    check += "TAG POS=1 TYPE=LABEL ATTR=ONCLICK:publishVipJS.toggleSaleAttr(this,'text');&&FOR:testsale2260958&&DATA:9248:2260958&&TXT:" + "
";
    check += "TAG POS=1 TYPE=INPUT:CHECKBOX ATTR=ID:testsale2260958 CONTENT=YES" + "
";
    iimset(check);
    iimPlay(check);
    var notif = alert("SUCCSES");
}
答案

在js脚本中直接获取!COL22值是不可能的。您应该使用iim-code之前提取它。例如,通过使用其他宏:

...
iimPlay(isi);

iimPlayCode (
    'SET !DATASOURCE Shoes<SP>05-04-2018.csv' + "
" +
    'SET !EXTRACT {{!COL22}}' + "
"
);

if (iimGetExtract() = "") {
...

以上是关于if else imacros with javascript command的主要内容,如果未能解决你的问题,请参考以下文章

[Ramda] Rewrite if..else with Ramda ifElse

尝试catch with contains for和if语句Java [关闭]

sqlserver中使用 with as ,后面不能用if else吗?

python,中使用while...else 和 for...else 还有try...else,另外就是运用with关键字

pandas编写自定义条件函数基于if函数elif函数else函数使用apply基于条件对数据行进行判断生成新的数据列(apply function with condition)

if/else 三元表达式中的 def