javascript - 在iMacro中连续寻找DIV

标签 javascript jquery imacros

我是 iMacro 新手。我尝试录制一个脚本,当它出现在屏幕上时,我单击了一个弹出窗口。问题是,发布任何新事件时都会出现弹出窗口。因此,在制作脚本时它是可用的,但是当我循环脚本时它会收到错误,因为它云找不到脚本。

我的代码如下 -

EVENT TYPE=CLICK SELECTOR="HTML>BODY>DIV:nth-of-type(7)>DIV:nth-of-type(2)>DIV>DIV>DIV>DIV>P:nth-of-type(2)" BUTTON=0
TAB T=2
EVENT TYPE=CLICK SELECTOR="HTML>BODY>DIV:nth-of-type(4)>DIV:nth-of-type(2)>DIV>DIV:nth-of-type(10)>DIV:nth-of-type(7)>DIV:nth-of-type(2)>A" BUTTON=0
EVENT TYPE=CLICK SELECTOR="HTML>BODY>DIV:nth-of-type(4)>DIV:nth-of-type(2)>DIV>DIV:nth-of-type(10)>DIV:nth-of-type(5)>DIV>FOOTER>DIV>DIV:nth-of-type(2)>A:nth-of-type(2)" BUTTON=0
EVENT TYPE=CLICK SELECTOR="HTML>BODY>DIV:nth-of-type(4)>DIV:nth-of-type(2)>DIV>DIV:nth-of-type(11)>DIV>DIV:nth-of-type(3)>DIV:nth-of-type(2)>A" BUTTON=0

我在第一行遇到错误。

(Error code: -921)

  1. 如果发生任何错误,有什么方法可以重新从头开始执行吗?
  2. 还有什么方法可以增加循环次数?

最佳答案

如果发生任何错误,有什么方法可以重新从头开始执行吗?

答案:

解决此问题的方法是将行添加到 imacros 脚本的顶部

SET !ERRORIGNORE YES
EVENT TYPE=CLICK SELECTOR="HTML>BODY>DIV:nth-of-type(7)>DIV:nth-of-type(2)>DIV>DIV>DIV>DIV>P:nth-of-type(2)" BUTTON=0
EVENT TYPE=CLICK SELECTOR="HTML>BODY>DIV:nth-of-type(4)>DIV:nth-of-type(2)>DIV>DIV:nth-of-type(10)>DIV:nth-of-type(7)>DIV:nth-of-type(2)>A" BUTTON=0
EVENT TYPE=CLICK SELECTOR="HTML>BODY>DIV:nth-of-type(4)>DIV:nth-of-type(2)>DIV>DIV:nth-of-type(10)>DIV:nth-of-type(5)>DIV>FOOTER>DIV>DIV:nth-of-type(2)>A:nth-of-type(2)" BUTTON=0
EVENT TYPE=CLICK SELECTOR="HTML>BODY>DIV:nth-of-type(4)>DIV:nth-of-type(2)>DIV>DIV:nth-of-type(11)>DIV>DIV:nth-of-type(3)>DIV:nth-of-type(2)>A" BUTTON=0

还有什么方法可以增加循环次数吗?

答案: 您需要使用 javascript 并在必要时创建无限循环,您可以通过按停止按钮结束此循环,因此我们将创建以下文件 (macro.js),而不是 imacros 文件 (macro.iim)。添加超时是因为将以 1 秒的间隔检查不同的选择器,如果需要,也可以将其设置为 0。

macro.js 文件的内容如下:

var macro;
macro=  'CODE:';
macro+=  'SET !TIMEOUT_STEP 1' + '\n'; 
macro+=  'SET !ERRORIGNORE YES' + '\n'; 
macro+=  'EVENT TYPE=CLICK SELECTOR="HTML>BODY>DIV:nth-of-type(7)>DIV:nth-of-type(2)>DIV>DIV>DIV>DIV>P:nth-of-type(2)" BUTTON=0' + '\n'; 
macro+=  'EVENT TYPE=CLICK SELECTOR="HTML>BODY>DIV:nth-of-type(4)>DIV:nth-of-type(2)>DIV>DIV:nth-of-type(10)>DIV:nth-of-type(7)>DIV:nth-of-type(2)>A" BUTTON=0' + '\n';
macro+=  'EVENT TYPE=CLICK SELECTOR="HTML>BODY>DIV:nth-of-type(4)>DIV:nth-of-type(2)>DIV>DIV:nth-of-type(10)>DIV:nth-of-type(5)>DIV>FOOTER>DIV>DIV:nth-of-type(2)>A:nth-of-type(2)" BUTTON=0' + '\n'; 
macro+=  'EVENT TYPE=CLICK SELECTOR="HTML>BODY>DIV:nth-of-type(4)>DIV:nth-of-type(2)>DIV>DIV:nth-of-type(11)>DIV>DIV:nth-of-type(3)>DIV:nth-of-type(2)>A" BUTTON=0' + '\n'; 

while(true){
    iimPlay(macro);
};

关于javascript - 在iMacro中连续寻找DIV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45487085/

相关文章:

javascript - Web Worker 可以工作,但在控制台中生成错误

javascript - 是否可以覆盖/阻止避免每小时点击一次以上的 Javascript 代码?

javascript - imacros 不停地运行 .iim

javascript - 用于识别复选框的正确 xpath

javascript - 进入页面后如何使元素滚动到滚动条的中心

javascript - AngularJS - 如何在另一个过滤器中使用过滤后的数组?

firefox - 在 Imacro 中打开 select2

javascript - 如何从 node_modules 导入 JS 库

javascript - 如果使用 php 标签,php jquery 示例将不起作用

javascript - 使用另一个元素更改的比率更改元素尺寸