How to get tags with two specific attribute=value in IEGetTagsByAttrib

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
geon12
Newbie
Posts: 8
Joined: Fri May 01, 2020 10:06 am

How to get tags with two specific attribute=value in IEGetTagsByAttrib

Post by geon12 » Thu Jul 30, 2020 2:52 pm

So dejected...Plz help a sad newb out..
Trying to click this button in a site that doesn't allow tab& image recognition doesn't work that well

IEGetTagsByAttrib>IE[0],input,value=1,O,arrTag
0: ARRTAG_1=<input id="first_hidsortnum" type="hidden" value="1">
0: ARRTAG_2=<input name="que_28799_348987" id="que_28799_348987_1" type="radio" value="1">
0: ARRTAG_3=<input name="que_28799_348988" class="check_val" id="que_28799_348988_1" type="radio" value="1">
0: ARRTAG_4=<input name="que_28799_348989" class="check_val" id="que_28799_348989_1" type="radio" value="1">

1. So.. the ARRTAG_1 is not what I'm looking for- I need to click on tags that have both type=radio AND value=1 in it.. but there seems to be no way to have multiple variables take effect in IEGetTagsByAttrib!!
I tried replacing value=1 with -> {type=radio}AND{value=1} /// {type=radio}&{value=1} to no success..
Is there any way to achieve this? or at least narrow the ARRTAG list by searching for type=radio within the ARRTAG list??

2. Welp, after giving up on that I'm trying to separate the id value of each ARRTAG so for example I can do
LET>wantclick="id=que_28799_348988_1
IETagEventByAttrib>IE[0],input,%wantclick%,click,
After all the methods I've tried- this actually works! I would love to do just
IETagEventByAttrib>IE[0],input,value=1,click,
and just have it click everything with value=1 but unfortunately it doesn't seem to work when there's mulitple options present..
So can I extract id or name of these ARRTAGS and arrange them in a separate variables so that I can use it to locate specific tag and click it?

I'm so close to finding answers to my nightmare of trying to find method to click multiple identical buttons on a web site.. PLZ HELP!!!

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1389
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: How to get tags with two specific attribute=value in IEGetTagsByAttrib

Post by Dorian (MJT support) » Thu Jul 30, 2020 4:12 pm

I hope I'm understanding correctly, but this will click the three "radio" "value=1" radio buttons. I tested this on a local file, so have used a dummy URL. Hopefully it's enough to get you started.

Code: Select all

//Create IE and Navigate
IECreate>IE[0]
IENavigate>IE[0],http://test.com/test.htm,res

//Extract tag
IEGetTagsByAttrib>http://test.com/test.htm,input,value=1,O,arrTag

//Loop through each result in array
Let>RadioLoop=0
Repeat>RadioLoop
  Let>RadioLoop=RadioLoop+1

  //Does it contain value="1" ?
  Pos>value="1",arrTag_%RadioLoop%,1,PosOne,

  //Does it contain type="radio" ? 
  Pos>type="radio",arrTag_%RadioLoop%,1,PosRadio,

  //If yes to both...
  If>{(%PosOne%>0) AND (%PosRadio%>0)}

    //Extract the ID (split into multiple lines so it's easier to follow)
    let>mystring=arrTag_%RadioLoop%
    let>BEGINNING=id="
    let>END="
    RegEx>(?<=%BEGINNING%).*?(?=%END%),mystring,0,matches,nm,0

    //Click the radio button
    IETagEventByAttrib>{"http://test.com/test.htm"},INPUT,ID=%matches_1%,click,
  Endif
Until>RadioLoop,arrTag_count
Note that the commands you were using require a URL, not an IE Reference (IE[0]).
Yes, we have a Custom Scripting Service. Message me or go here

geon12
Newbie
Posts: 8
Joined: Fri May 01, 2020 10:06 am

Re: How to get tags with two specific attribute=value in IEGetTagsByAttrib

Post by geon12 » Fri Jul 31, 2020 3:48 am

Thank you so much for the quick reply!!!
I'm so thrilled to try out your solution!
Yep- I used url for the actual code!
Belated thank-you but I'm loving using Macro scheduler and it's making my life so much easier now! Sometimes I don't entirely understand it and makes my brain melt.. but I'm learning so much through this forum! I'm gonna try learning Regex next time! Thanks!!!

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1389
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: How to get tags with two specific attribute=value in IEGetTagsByAttrib

Post by Dorian (MJT support) » Fri Jul 31, 2020 8:07 am

To be fair to you, that was probably beyond most beginners.

You'll find a lot of regex examples on this forum, plus there's a couple of free regex courses on Udemy, I think.
Yes, we have a Custom Scripting Service. Message me or go here

geon12
Newbie
Posts: 8
Joined: Fri May 01, 2020 10:06 am

Re: How to get tags with two specific attribute=value in IEGetTagsByAttrib

Post by geon12 » Sun Aug 09, 2020 7:16 am

Very ashamed to be asking for help again.. the finish line is so close yet so far away...
Most of my goal is: clicking multiple identical buttons in an internet site without image recognition
So using your solution - I tried to apply it to other part of my coding as well: most of it worked perfectly
But in this occation nothing is clicking. I suspect the problem is because the only defining feature of returned tags is a thing called href(tagname:"a" Classname: "href") whose value contains multiple "="s inside..
Let me show you what I've done so far


IEGetTagsByAttrib>https://exampleurl.com,dd,class=into,O,arrTag
//'So I guess tags have hierarchy but exists individually? I gathered [dl>dd>a>img] as separate tagnames but only identifying feature: a's href :showed up only when setting tagname as dd'//
///Tags I got ///
0: ARRTAG_1=<dd class="into"><a href="https://exampleurl.com:443/bbs/board.phpbo_table=0101&amp;wr_id=4119&amp;type=1"><img title=""alt="apply" src="/img/new_meditube/signup_on.png"></a></dd>
0: ARRTAG_2=<dd class="into"><a href="https://exampleurl.com:443/bbs/board.php?bo_table=0101&amp;wr_id=4110&amp;type=1"><img alt="apply" src="/img/new_meditube/signup_on.png"></a></dd>
0: ARRTAG_3=<dd class="into"><a href="https://exampleurl.com:443/bbs/board.php?bo_table=0101&amp;wr_id=4118&amp;type=1"><img title="" alt="cancel" src="/img/new_meditube/signup_on.png"></a></dd>


Let>Loop=0
Repeat>Loop
Let>Loop=Loop+1
//Does it contain alt=”apply”
Pos>alt="apply",arrTag_%Loop%,1,PosApply,
//Does it contain class=”into” ?
Pos>class="into",arrTag_%Loop%,1,PosInto,

//If yes to both...
If>{(%PosApply%>0) AND (%PosInto%>0)}
//Extract the href
let>mystring=arrTag_%Loop%
let>BEGINNING=href="
let>END="
RegEx>(?<=%BEGINNING%).*?(?=%END%),mystring,0,matches,nm,0
//Click the button
IETagEventByAttrib>{"https://exampleurl.com"},a,href=%matches_1%,click,
Endif
Until>Loop,arrTag_count


I hope I'm being semi-coherent here.. tried putting "" around %matches_1% to specify that =inside doesn't matter but I don't think it's registering. Your help is always greatly appreciated!! :o

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1389
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: How to get tags with two specific attribute=value in IEGetTagsByAttrib

Post by Dorian (MJT support) » Mon Aug 10, 2020 10:00 am

The issue seemed to be the :443 and the amp; in the hyperlink. It was in the html but not in the rendered version displayed in the browser. Remove those, and it clicks.

Code: Select all

stringreplace>oldstring,:ReplaceThis,WithThat,newstring

stringreplace>%matches_1%,:443,,matches_1
stringreplace>%matches_1%,amp;,,matches_1
So :

Code: Select all

IECreate>IE[0]
IENavigate>IE[0],d:\test.htm,
IEGetTagsByAttrib>test,dd,class=into,O,arrTag

Let>Loop=0
Repeat>Loop
Let>Loop=Loop+1
//Does it contain alt=”apply”
Pos>alt="apply",arrTag_%Loop%,1,PosApply,
//Does it contain class=”into” ?
Pos>class="into",arrTag_%Loop%,1,PosInto,
//If yes to both...
If>{(%PosApply%>0) AND (%PosInto%>0)}
//Extract the href
let>mystring=arrTag_%Loop%
let>BEGINNING=href="
let>END="
RegEx>(?<=%BEGINNING%).*?(?=%END%),mystring,0,matches,nm,0
//Click the button
stringreplace>%matches_1%,:443,,matches_1
stringreplace>%matches_1%,amp;,,matches_1

IETagEventByAttrib>test,a,href=%matches_1%,click,
Endif
Until>Loop,arrTag_count
Yes, we have a Custom Scripting Service. Message me or go here

geon12
Newbie
Posts: 8
Joined: Fri May 01, 2020 10:06 am

Re: How to get tags with two specific attribute=value in IEGetTagsByAttrib

Post by geon12 » Wed Aug 12, 2020 12:03 pm

Stringreplace! Never thought of those!!
Thank you for helping out! :D

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts