javascriptweb-scrapingdomimacros

iMacros TAG to Find TXT and Click Nearby (previous) Link


Below is the example code of Wordpress Backend tag management section. I'm trying to write an iMacros to find a tag and delete it. However the Tag text doesn't below in any HTML's tag.

<div class="tagchecklist">
    <span>
        <a id="post_tag-check-num-0" class="ntdelbutton" tabindex="0">X</a>
        &nbsp;Orange
    </span>
    <span>
        <a id="post_tag-check-num-1" class="ntdelbutton" tabindex="0">X</a>
        &nbsp;Apple
    </span>
    <span>
        <a id="post_tag-check-num-2" class="ntdelbutton" tabindex="0">X</a>
        &nbsp;Banana
    </span>
    <span>
        <a id="post_tag-check-num-3" class="ntdelbutton" tabindex="0">X</a>
        &nbsp;Grape
    </span>
</div>

What I've tried to do but it doesn't work because TAG can't go to

TAG POS=1 TYPE=(Not sure what to put here) ATTR=TXT:Banana
TAG POS=R-1 TYPE=A ATTR=TXT:*

I need the script to find a where SPAN that contains Banana text located and click the X button in the SPAN.

Thanks for any help.


Solution

  • Relative positioning doesn't meet well this issue, so:

    SET !EXTRACT_TEST_POPUP NO
    TAG POS=1 TYPE=SPAN ATTR=TXT:*Banana* EXTRACT=HTM
    SET FP EVAL("parseInt('{{!EXTRACT}}'.match(/check-num-(\\d)/)[1]) + 1;")
    TAG POS={{FP}} TYPE=A ATTR=TXT:*