Pulling from CSV to select specific check box

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.
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
acichosz13
Posts: 7
Joined: Tue Sep 11, 2018 5:58 pm

Pulling from CSV to select specific check box

Post by acichosz13 » Tue Sep 11, 2018 6:39 pm

Hey all I am extremely new the iMacros and I have been playing around with this for a while now. I am pulling in a CSV file that has basic info: firstName, lastName, Race.. ect. The form I am trying to fill out is on a website that has 7 individual check boxes depending on the race. I need to take the column of race = col15 and do a bunch of if else statements to check if it matches the box and then if so to check it.

My CSV example file has American Indian as the race, but how do I do the logic in iMacros to get the American Indian box checked.

I had initially done some logic like this, but fear I am not in the right place. I am using IE as my browser. Can anyone help point me in a better direction.


VERSION BUILD=11.5.499.3066
TAB T=1
TAB CLOSEALLOTHERS
SET !PLAYBACKDELAY 0.2
URL GOTO=http://phdcdtmswebid03/CDPHWebCMR/Pages ... Entry.aspx

SET !VAR1 EVAL("if(\"{{!COL15}}\" == \"C\"){var x=1}; x;")
TAG POS={{!VAR1}} TYPE=LABEL ATTR=TXT:American<SP>Indian<SP>or<SP>Alaska<SP>Native
TAG POS={{!VAR1}} TYPE=INPUT:CHECKBOX ATTR=NAME:dgdRace$ct101$chkRace CONTENT=YES

(get an error {{VAR1}} is not correct parameter)


When I record the iMacros and check a box this is what is recorded
TAG POS=1 TYPE=LABEL ATTR=TXT:American<SP>Indian<SP>or<SP>Alaska<SP>Native
TAG POS=1 TYPE=INPUT:CHECKBOX ATTR=NAME:dgdRace$ctl01$chkRace CONTENT=YES
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Pulling from CSV to select specific check box

Post by chivracq » Tue Sep 11, 2018 7:27 pm

acichosz13 wrote:Hey all I am extremely new the iMacros and I have been playing around with this for a while now. I am pulling in a CSV file that has basic info: firstName, lastName, Race.. ect. The form I am trying to fill out is on a website that has 7 individual check boxes depending on the race. I need to take the column of race = col15 and do a bunch of if else statements to check if it matches the box and then if so to check it.

My CSV example file has American Indian as the race, but how do I do the logic in iMacros to get the American Indian box checked.

I had initially done some logic like this, but fear I am not in the right place. I am using IE as my browser. Can anyone help point me in a better direction.

Code: Select all

VERSION BUILD=11.5.499.3066
TAB T=1
TAB CLOSEALLOTHERS
SET !PLAYBACKDELAY 0.2
URL GOTO=http://phdcdtmswebid03/CDPHWebCMR/Pages/PHPersonalRecord/PHPersonalRecordEntry.aspx

SET !VAR1 EVAL("if(\"{{!COL15}}\" == \"C\"){var x=1}; x;")
TAG POS={{!VAR1}} TYPE=LABEL ATTR=TXT:American<SP>Indian<SP>or<SP>Alaska<SP>Native
TAG POS={{!VAR1}} TYPE=INPUT:CHECKBOX ATTR=NAME:dgdRace$ct101$chkRace CONTENT=YES
(get an error {{VAR1}} is not correct parameter)

When I record the iMacros and check a box this is what is recorded

Code: Select all

TAG POS=1 TYPE=LABEL ATTR=TXT:American<SP>Indian<SP>or<SP>Alaska<SP>Native
TAG POS=1 TYPE=INPUT:CHECKBOX ATTR=NAME:dgdRace$ctl01$chkRace CONTENT=YES
FCIM...! :mrgreen: (Read my Sig...)
=> iMacros for IE v11.5, IE11...?, OS...?

But yep, you are on the "right path"... :wink:

Use 'PROMPT' to follow your Vars and debug your Script, I suspect you simply miss a ';' in "{var x=1}" => "{var x=1;}"... :idea:

Here is some similar Syntax for your 'EVAL()' Statement that I prefer to use... (and that will be easier to reuse for much more complex Expressions...):

Code: Select all

SET !VAR1 EVAL("var c15='{{!COL15}}'; var z; if(c15=='C'){z=1;} else{z=0;}; z;")
PROMPT COL15:<SP>_{{!COL15}}_<BR>VAR1:<SP>_{{!VAR1}}_
(And you need to use '!ERRORIGNORE' as well for the "Case" 'POS=0' (or even for your 'POS=__undefined__')...)

Hum..., and I don't know if you've truncated your Script for the Forum, but you need of course also to specify the '!DATASOURCE' and '!DATASOURCE_LINE'...! :?
- (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...
acichosz13
Posts: 7
Joined: Tue Sep 11, 2018 5:58 pm

Re: Pulling from CSV to select specific check box

Post by acichosz13 » Tue Sep 11, 2018 8:49 pm

Thank you so MUCH for the PROMPT trick! I am forever grateful for that. I actually changed my syntax to your format as well it is so much easier! I changed a few things and added in another if else, but followed the same thing. It is working correctly.

SET !VAR1 EVAL("var c28='{{!COL28}}'; var z; if(c28=='Yes'){z=1;} else if(c28=='No'){z=2;} else{z=3;}; z;")
TAG POS={{!VAR1}} TYPE=INPUT:RADIO ATTR=NAME:rlstPregnant
PROMPT COL15:<SP>_{{!COL28}}_<BR>VAR1:<SP>_{{!VAR1}}_

I didn't have POS=0, but I will add that.

I do have the other info I left out:

SET !LOOP 2
SET !DATASOURCE_LINE {{!LOOP}}
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0


Thank you so much!! I am catching on to the syntax of iMacros!
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Pulling from CSV to select specific check box

Post by chivracq » Tue Sep 11, 2018 8:59 pm

acichosz13 wrote:Thank you so MUCH for the PROMPT trick! I am forever grateful for that. I actually changed my syntax to your format as well it is so much easier! I changed a few things and added in another if else, but followed the same thing. It is working correctly.

Code: Select all

SET !VAR1 EVAL("var c28='{{!COL28}}'; var z; if(c28=='Yes'){z=1;} else if(c28=='No'){z=2;} else{z=3;}; z;")
TAG POS={{!VAR1}} TYPE=INPUT:RADIO ATTR=NAME:rlstPregnant
PROMPT COL15:<SP>_{{!COL28}}_<BR>VAR1:<SP>_{{!VAR1}}_
I didn't have POS=0, but I will add that.

I do have the other info I left out:

Code: Select all

SET !LOOP 2
SET !DATASOURCE_LINE {{!LOOP}}
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0
Thank you so much!! I am catching on to the syntax of iMacros!
Yep, very good...!, that's exactly the "Principle"... :D

Well, "my" 'POS=0' was related to your first/original Example, I consider it "Good Practice" to always "catch" all Cases, but your "else{z=3;}" in this 2nd Example about "Pregnant" does catch all other Cases not caught before by the first 2 'IF' Statements... 8)
- (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