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

2k views Asked by At

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.

2

There are 2 answers

0
Shugar On BEST ANSWER

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:*
0
chivracq On

Interesting "old" Question, ah-ah...! => With a "new" Solution, 7 year later...

Typical Use for "Double Relative Positioning" (*), with the "Banana" Element as Anchor like the Asker was trying...:

TAG POS=1 TYPE=SPAN ATTR=TXT:Banana
TAG POS=R1 TYPE=* ATTR=*
TAG POS=R-1 TYPE=A ATTR=TXT:*

=> The 1st R-POS with R1 to get outside of the SPAN Element containing the Link, ... and the 2nd R-POS with R-1 for iMacros to be able "to see" inside that same SPAN Element again...


(*): For more Info on "Double Relative Positioning", google those 3 Terms (with Double Quotes) or search the iMacros Forum, the Concept is "mine", I've explained it dozens of times (since 2014) on the iMacros Forum...
(I don't dare to post any (direct) Link as Answers with Links to Resources outside the Site usually end up being flagged and deleted...)