如何获取元素位置 - Imacros

How to Get element Position - Imacros

我有 3 种不同类型的 HTML 元素(重复,动态值,我无法计算数量)第一种元素具有相同的属性 (class),但文本不同 (我可以跨文本获取元素),其他 2 个具有相同的属性(我可以跨位置获取此元素),所以我想在第一种元素的位置上单击其他 2 种类型,为此我想要要根据第一类元素位置(全部)了解第一类元素位置(我在文本中发现的内容),我必须做什么才能获得我找到的重复元素的位置?!

编辑:

示例:

<div class="class1">Text1</div> //i want it (the pos here is 1 , for both all elements and imacros)
<div class="class2"></div> //i want to click on it
<div class="class1">Text2</div>
<div class="class1">Text1</div> //And it (the pos here is 3 to all elements , but 2 in imacros)
<div class="class2"></div> //i want to click on it too
<div class="class1">Text3</div>
<div class="class1">Text4</div>

示例 2:

<div class="class1">Text1</div>
<div class="class1">Text2</div>
<div class="class1">Text3</div>
<div class="class1">Text4</div>
<div class="class1">Text5</div> //i found this element by text , i want to know (Programmatically with imacros) the POSITION of this element (according to same elements (Similar in some attributes (like class in this case)))
<div class="class1">Text6</div>
<div class="class1">Text7</div>
<div class="class1">Text8</div>
<div class="class1">Text9</div>
<div class="class1">Text10</div>

我通过 "for function" 解决了它,但是 javascript 语言帮助..

我的代码:在 (.js) 文件中..

for (var i=1;i<10;i++)
{
var macro = "CODE: ";
macro += "SET !ERRORIGNORE YES\n";
macro += "SET !EXTRACT NULL\n";
macro += "TAG POS={{i}} TYPE=DIV ATTR=class:class1 EXTRACT=TXT\n";
iimPlay(macro);
if(iimGetLastExtract().search("TEXT5")!=-1)
{
alert("element pos is: " + i)
}
}