iMacros iimGetExtract() 函数

iMacros iimGetExtract()

我是 JavaScript 的新手,我需要一些帮助来从 iMacros 中获取最后提取的值。问题是,当我使用 JavaScript 函数 alert() 时,它显示了正确的最后提取,但是如果条件不起作用。

宏步骤:

  1. Click on image which is positioned based on LOOP

  2. Click on button and if there exists a text, extract the text and if text is 2 start another iim code. The code is more complex, this is only part for extract debug which is important for conditionals which starts another piece of code

我得到的错误是:

TypeError: path is undefined, line -633 (Error code: -991)

代码如下:

var numPage = prompt("current numPage?");
numPage++;
var i = 1;
var macroStart;
macroStart =  "CODE:";
macroStart +=  "'set global variables" + "\n"; 
macroStart +=  "SET !EXTRACT_TEST_POPUP NO" + "\n"; 
macroStart +=  "SET tabCheck NULL" + "\n";
macroStart +=  "SET !ERRORIGNORE YES" + "\n"; 
macroStart +=  "SET !EXTRACT NULL" + "\n"; 
macroStart +=  "SET !TIMEOUT_STEP 1" + "\n"; 
macroStart +=  "SET !CLIPBOARD NULL" + "\n"; 
macroStart +=  "SET productUrl {{!URLCURRENT}}" + "\n"; 
macroStart +=  "TAG POS={{i}} TYPE=IMG ATTR=SRC:https://www.xxx.sk/admin/xxx/xxx/img/uprav.gif" + "\n"; 
macroStart +=  "TAG POS=1 TYPE=A ATTR=ID:zalozka_obrazky" + "\n"; 
macroStart +=  "TAG POS=1 TYPE=A ATTR=TXT:2 EXTRACT=TXT" + "\n"; 

macroStartExtract = iimGetLastExtract();
if (macroStartExtract == 2) {
     var goToProductUrl;
     goToProductUrl +=  "'back to main product's page" + "\n"; 
     goToProductUrl +=  "SET !VAR5 2" + "\n"; 
     goToProductUrl +=  "PROMPT !VAR5" + "\n";
     iimPlay(goToProductUrl);
    } else {iimPlay(goToProductUrl);}


var macroChangePage;
macro2 = "CODE:"
macro2 += "TAG POS=2 TYPE=A ATTR=TXT:{{numPage}}"

while (i < 2) {
    iimSet("i",i)
    iimPlay(macroStart)
    i++;

    if (i == 2) {
         iimSet("numPage", numPage)
         iimPlay(macroChangePage)
         numPage++
         i = 1;
    }
 }

我检查了代码是否有问题,我发现它在下面的块中失败了。

else {iimPlay(goToProductUrl);}

因为在 if 条件中定义了 goToProductUrl 变量。 if 没有被执行,当它进入 else 块时,变量未定义,因此程序失败。由于缺少 URL 无法检查程序是否正常工作,但是 else 块应该是这样的吗?

else {iimPlay(macroStart);}

javascript 错误已修复,请在删除错误后尝试构建代码。

var numPage = prompt("current numPage?");
numPage++;
var i = 1;
var macroStart;
macroStart =  "CODE:";
macroStart +=  "'set global variables" + "\n"; 
macroStart +=  "SET !EXTRACT_TEST_POPUP NO" + "\n"; 
macroStart +=  "SET tabCheck NULL" + "\n";
macroStart +=  "SET !ERRORIGNORE YES" + "\n"; 
macroStart +=  "SET !EXTRACT NULL" + "\n"; 
macroStart +=  "SET !TIMEOUT_STEP 1" + "\n"; 
macroStart +=  "SET !CLIPBOARD NULL" + "\n"; 
macroStart +=  "SET productUrl {{!URLCURRENT}}" + "\n"; 
macroStart +=  "TAG POS={{i}} TYPE=IMG ATTR=SRC:https://www.xxx.sk/admin/xxx/xxx/img/uprav.gif" + "\n"; 
macroStart +=  "TAG POS=1 TYPE=A ATTR=ID:zalozka_obrazky" + "\n"; 
macroStart +=  "TAG POS=1 TYPE=A ATTR=TXT:2 EXTRACT=TXT" + "\n"; 

macroStartExtract = iimGetLastExtract();
if (macroStartExtract == 2) {
     var goToProductUrl;
     goToProductUrl +=  "'back to main product's page" + "\n"; 
     goToProductUrl +=  "SET !VAR5 2" + "\n"; 
     goToProductUrl +=  "PROMPT !VAR5" + "\n";
     iimPlay(goToProductUrl);
    } else {iimPlay(macroStart);}


var macroChangePage;
macro2 = "CODE:"
macro2 += "TAG POS=2 TYPE=A ATTR=TXT:{{numPage}}"

while (i < 2) {
    iimSet("i",i)
    iimPlay(macroStart)
    i++;

    if (i == 2) {
         iimSet("numPage", numPage)
         iimPlay(macroChangePage)
         numPage++
         i = 1;
    }
 }