EXTRACT=CHECKED wont find check box

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
senor pengwin
Posts: 41
Joined: Thu Aug 17, 2017 10:33 pm

EXTRACT=CHECKED wont find check box

Post by senor pengwin » Wed Jul 25, 2018 6:50 pm

Hey guys, need a little help here.

Windows 10 Pro
iMacros Browser V12.0.501.6698
iMacros BUILD=12.0.501.6698

I have a check box and I am trying to select the check box if it is not selected.

To start out I have seen this thread https://forum.imacros.net/viewtopic.php?t=27248
and I have the main concept down I just cannot get the EXTRACT to return a YES or NO.

Here is my code using regular record:

Code: Select all

VERSION BUILD=12.0.501.6698
TAB T=1
TAB CLOSEALLOTHERS
URL GOTO=https://www.b50first.com/prod/login_app.aspx
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:tbCompany CONTENT=xx
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:tbUser CONTENT=xx
TAG POS=1 TYPE=INPUT:PASSWORD ATTR=NAME:tbPassword CONTENT=xx
TAG POS=1 TYPE=INPUT:SUBMIT ATTR=NAME:bLogin
TAG POS=1 TYPE=SPAN ATTR=TXT:Reports
TAG POS=1 TYPE=SPAN ATTR=TXT:GL<SP>Account<SP>Balances
'New tab opened
TAB T=2
TAG POS=1 TYPE=SPAN ATTR=ID:ctl00_cph_ctl02_MainLocTree_tree_SelAll_D  'This line selects check box
here is the line when I use the expert recorder:

Code: Select all

TAG POS=1 TYPE=SPAN FORM=NAME:aspnetForm ATTR=ID:ctl00_cph_ctl02_MainLocTree_tree_SelAll_D&&CLASS:dxWeb_edtCheckBoxUnchecked_1<SP>dxICheckBox_1 'Unchecked Box
TAG POS=1 TYPE=SPAN FORM=NAME:aspnetForm ATTR=ID:ctl00_cph_ctl02_MainLocTree_tree_SelAll_D&&CLASS:dxWeb_edtCheckBoxChecked_1<SP>dxICheckBox_1 'Checked Box
So I either get two returns, the one below returns that EXTRACT=CHECKED only works on check boxes:

Code: Select all

TAG POS=1 TYPE=SPAN FORM=NAME:aspnetForm ATTR=ID:ctl00_cph_ctl02_MainLocTree_tree_SelAll_D EXTRACT=CHECKED
This line returned an error saying the extract value is #EANF#:

Code: Select all

TAG POS=1 TYPE=HIDDEN FORM=NAME:aspnetForm ATTR=ID:ctl00_cph_ctl02_MainLocTree_tree_SelAll_D EXTRACT=CHECKED

Additionally here is the HTML from the website that selects the checkbox (I think):

Code: Select all

<input type="hidden" name="ctl00$cph$ctl02$MainLocTree$tree$STATE" id="ctl00_cph_ctl02_MainLocTree_tree_STATE" value="Y2dkZ2ACYQYQUChyYGdkYmT7/5+dgZ2V/Q2Q5AIKs3MzsRoZWhgbQygTCGUKpIxMLMwglDmQMjE0AMlZWpiZQShzCGUBoiwNTSGUGdBUNiY2v/yUVE8XdiaegMSi1LwSGJfNvaggPsCbmYnNJz8ZzOAASYWkVpSwg8X8korY2RkA">

Any advise on why it isn't finding the checkbox?

Thanks!
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: EXTRACT=CHECKED wont find check box

Post by chivracq » Thu Jul 26, 2018 3:09 am

senor pengwin wrote:Hey guys, need a little help here.

Code: Select all

Windows 10 Pro
iMacros Browser V12.0.501.6698
iMacros BUILD=12.0.501.6698
I have a check box and I am trying to select the check box if it is not selected.

To start out I have seen this thread https://forum.imacros.net/viewtopic.php?t=27248
and I have the main concept down I just cannot get the EXTRACT to return a YES or NO.

Here is my code using regular record:

Code: Select all

VERSION BUILD=12.0.501.6698
TAB T=1
TAB CLOSEALLOTHERS
URL GOTO=https://www.b50first.com/prod/login_app.aspx
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:tbCompany CONTENT=xx
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:tbUser CONTENT=xx
TAG POS=1 TYPE=INPUT:PASSWORD ATTR=NAME:tbPassword CONTENT=xx
TAG POS=1 TYPE=INPUT:SUBMIT ATTR=NAME:bLogin
TAG POS=1 TYPE=SPAN ATTR=TXT:Reports
TAG POS=1 TYPE=SPAN ATTR=TXT:GL<SP>Account<SP>Balances
'New tab opened
TAB T=2
TAG POS=1 TYPE=SPAN ATTR=ID:ctl00_cph_ctl02_MainLocTree_tree_SelAll_D  'This line selects check box
here is the line when I use the expert recorder:

Code: Select all

TAG POS=1 TYPE=SPAN FORM=NAME:aspnetForm ATTR=ID:ctl00_cph_ctl02_MainLocTree_tree_SelAll_D&&CLASS:dxWeb_edtCheckBoxUnchecked_1<SP>dxICheckBox_1 'Unchecked Box
TAG POS=1 TYPE=SPAN FORM=NAME:aspnetForm ATTR=ID:ctl00_cph_ctl02_MainLocTree_tree_SelAll_D&&CLASS:dxWeb_edtCheckBoxChecked_1<SP>dxICheckBox_1 'Checked Box
So I either get two returns, the one below returns that EXTRACT=CHECKED only works on check boxes:

Code: Select all

TAG POS=1 TYPE=SPAN FORM=NAME:aspnetForm ATTR=ID:ctl00_cph_ctl02_MainLocTree_tree_SelAll_D EXTRACT=CHECKED
This line returned an error saying the extract value is #EANF#:

Code: Select all

TAG POS=1 TYPE=HIDDEN FORM=NAME:aspnetForm ATTR=ID:ctl00_cph_ctl02_MainLocTree_tree_SelAll_D EXTRACT=CHECKED
Additionally here is the HTML from the website that selects the checkbox (I think):

Code: Select all

<input type="hidden" name="ctl00$cph$ctl02$MainLocTree$tree$STATE" id="ctl00_cph_ctl02_MainLocTree_tree_STATE" value="Y2dkZ2ACYQYQUChyYGdkYmT7/5+dgZ2V/Q2Q5AIKs3MzsRoZWhgbQygTCGUKpIxMLMwglDmQMjE0AMlZWpiZQShzCGUBoiwNTSGUGdBUNiY2v/yUVE8XdiaegMSi1LwSGJfNvaggPsCbmYnNJz8ZzOAASYWkVpSwg8X8korY2RkA">
Any advise on why it isn't finding the checkbox?

Thanks!
Yeah well, the 'EXTRACT=CHECKED' is indeed for some 'TYPE=INPUT:CHECKBOX' Element, not for a 'SPAN' Element...

Your Site is using some "fake" 'CB' which is actually a 'SPAN' Element, like many Sites "now" use "fake" 'DDLB''s made of one 'DIV' and several 'SPAN''s for each 'DDLB' Option.

The "Checked Box" or "Unchecked Box" Info is present as Attribute for your 'SPAN' Element...
=> Simply do an 'EXTRACT=HTM' on that 'SPAN' Element and isolate/determine the "[Un]/Checked" Info/State using 'EVAL()'... :idea:

>>>

You had asked me a few "final" Qt's / extra Explanation at the end of your previous Thread..., to which I answered in some a bit detailed way, any Follow-up on that one maybe, 5 or 6 days later...? (=> in its own Thread...)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
senor pengwin
Posts: 41
Joined: Thu Aug 17, 2017 10:33 pm

Re: EXTRACT=CHECKED wont find check box

Post by senor pengwin » Thu Jul 26, 2018 5:27 am

chivracq wrote: Yeah well, the 'EXTRACT=CHECKED' is indeed for some 'TYPE=INPUT:CHECKBOX' Element, not for a 'SPAN' Element...

Your Site is using some "fake" 'CB' which is actually a 'SPAN' Element, like many Sites "now" use "fake" 'DDLB''s made of one 'DIV' and several 'SPAN''s for each 'DDLB' Option.

The "Checked Box" or "Unchecked Box" Info is present as Attribute for your 'SPAN' Element...
=> Simply do an 'EXTRACT=HTM' on that 'SPAN' Element and isolate/determine the "[Un]/Checked" Info/State using 'EVAL()'... :idea:

>>>

You had asked me a few "final" Qt's / extra Explanation at the end of your previous Thread..., to which I answered in some a bit detailed way, any Follow-up on that one maybe, 5 or 6 days later...? (=> in its own Thread...)

Got it!! Below is what I did.

Now I just spent the past 3 hours trying to figure out how to chop up this HTM extract but it's past my knowledge of Java and integration into iMacros, so I did it the ugly long way :/ If you have any advice on how to maybe get just the 'value="C"' part that would be wonderful.. I imagine I need to use some sort of splice() or indexof() but I couldn't figure it out.

Code: Select all

VERSION BUILD=12.0.501.6698
TAB T=1
TAB CLOSEALLOTHERS
URL GOTO=https://www.b50first.com/prod/login_app.aspx
TAG POS=1 TYPE=INPUT:SUBMIT ATTR=NAME:bLogin
TAG POS=1 TYPE=SPAN ATTR=TXT:Reports
TAG POS=1 TYPE=SPAN ATTR=TXT:GL<SP>Account<SP>Balances
'New tab opened
TAB T=2
SET !EXTRACT_TEST_POPUP NO
SET !EXTRACT NULL
TAG POS=1 TYPE=SPAN ATTR=ID:ctl00_cph_ctl02_MainLocTree_tree_SelAll_D EXTRACT=HTM

SET Check_CB EVAL("var s='{{!EXTRACT}}'; var z; if(s=='<span class=\"dxWeb_edtCheckBoxChecked_1 dxICheckBox_1\" id=\"ctl00_cph_ctl02_MainLocTree_tree_SelAll_D\"><input id=\"ctl00_cph_ctl02_MainLocTree_tree_SelAll\" style=\"border-width: 0px; margin: 0px; padding: 0px; width: 0px; height: 0px; display: block; position: relative; background-color: transparent;\" readonly=\"readonly\" value=\"C\"></span>'){z=0;} else{z=1;}; z;")

SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0
TAG POS={{Check_CB}} TYPE=SPAN ATTR=ID:ctl00_cph_ctl02_MainLocTree_tree_SelAll_D


-----------
Also I noticed in the original post that you had a typo in the code you posted which was then quoted in subsequent replies, tsk tsk!! :lol:

Code: Select all

PROMP CB<SP>checked...?:<SP>_{{[!EXTRACT}}_<BR>Check_CB:<SP>_{{Check_CB}}_    'PROMPT spelt with a T!!
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: EXTRACT=CHECKED wont find check box

Post by chivracq » Thu Jul 26, 2018 6:06 am

senor pengwin wrote:Got it!! Below is what I did.

Now I just spent the past 3 hours trying to figure out how to chop up this HTM extract but it's past my knowledge of Java and integration into iMacros, so I did it the ugly long way :/ If you have any advice on how to maybe get just the 'value="C"' part that would be wonderful.. I imagine I need to use some sort of splice() or indexof() but I couldn't figure it out.

Code: Select all

VERSION BUILD=12.0.501.6698
TAB T=1
TAB CLOSEALLOTHERS
URL GOTO=https://www.b50first.com/prod/login_app.aspx
TAG POS=1 TYPE=INPUT:SUBMIT ATTR=NAME:bLogin
TAG POS=1 TYPE=SPAN ATTR=TXT:Reports
TAG POS=1 TYPE=SPAN ATTR=TXT:GL<SP>Account<SP>Balances
'New tab opened
TAB T=2
SET !EXTRACT_TEST_POPUP NO
SET !EXTRACT NULL
TAG POS=1 TYPE=SPAN ATTR=ID:ctl00_cph_ctl02_MainLocTree_tree_SelAll_D EXTRACT=HTM

SET Check_CB EVAL("var s='{{!EXTRACT}}'; var z; if(s=='<span class=\"dxWeb_edtCheckBoxChecked_1 dxICheckBox_1\" id=\"ctl00_cph_ctl02_MainLocTree_tree_SelAll_D\"><input id=\"ctl00_cph_ctl02_MainLocTree_tree_SelAll\" style=\"border-width: 0px; margin: 0px; padding: 0px; width: 0px; height: 0px; display: block; position: relative; background-color: transparent;\" readonly=\"readonly\" value=\"C\"></span>'){z=0;} else{z=1;}; z;")

SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0
TAG POS={{Check_CB}} TYPE=SPAN ATTR=ID:ctl00_cph_ctl02_MainLocTree_tree_SelAll_D
Hum, I recognize "my" syntax, ah-ah...! 8)

But OK, if you get some "value="C"" in the 'EXTRACT=HTM', then a bit easier would be:

Code: Select all

SET Check_CB EVAL("var s='{{!EXTRACT}}'; var x,y,z; x=s.split('value=\"'); y=x[1].split('\"'); if(y[0]=='C'){z=0;} else{z=1;}; z;")
And probably even much easier would be stg like...:

Code: Select all

SET !EXTRACT NULL
TAG POS=1 TYPE=SPAN ATTR=ID:*_MainLocTree_tree_SelAll_D&&CLASS:dxWeb_edtCheckBoxChecked_1* EXTRACT=TXT
SET Check_CB EVAL("var s='{{!EXTRACT}}'; var x,y,z; if(s!='#EANF#'){z=0;} else{z=1;}; z;")
Both Solutions not tested of course...
senor pengwin wrote:-----------
Also I noticed in the original post that you had a typo in the code you posted which was then quoted in subsequent replies, tsk tsk!! :lol:

Code: Select all

PROMP CB<SP>checked...?:<SP>_{{[!EXTRACT}}_<BR>Check_CB:<SP>_{{Check_CB}}_    'PROMPT spelt with a T!!
Oh..., yep indeed, probably the User didn't post any URL and I wrote everything from Scratch without being able to test anything... :wink:
(Corrected...)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
senor pengwin
Posts: 41
Joined: Thu Aug 17, 2017 10:33 pm

Re: EXTRACT=CHECKED wont find check box

Post by senor pengwin » Thu Jul 26, 2018 3:40 pm

chivracq wrote: And probably even much easier would be stg like...:

Code: Select all

SET !EXTRACT NULL
TAG POS=1 TYPE=SPAN ATTR=ID:*_MainLocTree_tree_SelAll_D&&CLASS:dxWeb_edtCheckBoxChecked_1* EXTRACT=TXT
SET Check_CB EVAL("var s='{{!EXTRACT}}'; var x,y,z; if(s!='#EANF#'){z=0;} else{z=1;}; z;")
Yep! This works perfect, much cleaner. Thanks for the help, slowly starting to become more comfortable looking through HTML, now just need to touch up some Java basics.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: EXTRACT=CHECKED wont find check box

Post by chivracq » Thu Jul 26, 2018 4:15 pm

senor pengwin wrote:
chivracq wrote: And probably even much easier would be stg like...:

Code: Select all

SET !EXTRACT NULL
TAG POS=1 TYPE=SPAN ATTR=ID:*_MainLocTree_tree_SelAll_D&&CLASS:dxWeb_edtCheckBoxChecked_1* EXTRACT=TXT
SET Check_CB EVAL("var s='{{!EXTRACT}}'; var x,y,z; if(s!='#EANF#'){z=0;} else{z=1;}; z;")
Yep! This works perfect, much cleaner. Thanks for the help, slowly starting to become more comfortable looking through HTML, now just need to touch up some Java basics.
Ah...!, glad to hear, ah-ah...! :D
And no Typo this time, ouf...! :wink:

It's "JavaScript" btw, (used inside 'EVAL()'), not "Java"... :?

I also only use a mini-Subset of JS Commands for some "basic" Manipulation on Strings/Numbers/Arrays in all my 'EVAL()' Statements..., more or less always the same ones... One Command for example I use a lot is 'split()' that I find very "powerful", and I use it to "replace" 'SEARCH' + 'REGEXP' + 'match()' + Global 'replace()' that I all find "complicated" to use...
I've been using the Documentation/Examples from this Site... :idea:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Post Reply