Choose radio button based on value

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
Burger
Posts: 16
Joined: Thu Jan 14, 2021 6:56 am

Choose radio button based on value

Post by Burger » Mon Aug 08, 2022 7:24 am

Hi All,

Sorry little bit later but here is my updated secenario with the requirements needed:

Windows : Windows server 2019
iMacros version : 12.6 Browser Enterprise edition


Our full .vbs script is build by Tom and I don't know if I can share it here on the web because there is alot of personal information in it.


The problem we are facing is that the radio buttons has the same ID in the HTML script, but both has a other value (Yes/No)

Code: Select all

<input id="_ctl4__ctl2_rbtAddPurpose1a_0" type="radio" name="_ctl4:_ctl2:rbtAddPurpose1a" value="yes">
<input id="_ctl4__ctl2_rbtAddPurpose1a_0" type="radio" name="_ctl4:_ctl2:rbtAddPurpose1a" value="no">
woody.PNG
woody.PNG (2.11 KiB) Viewed 5133 times
The Woody variable that I'm calling in the .iim file is comming from a CSV which is read by our .vbs file.

When I'm trying to do the following code to select the right radio button (The Yes or No) then it's working perfectly

Code: Select all

TAG POS=1 TYPE=INPUT:RADIO ATTR=NAME:_ctl4:_ctl2:rbtAddPurpose1b&&VALUE:YES
No I want to make the VALUE: variable because sometimes I've to choose Yes and sometimes I've to choose No.
The Yes or No is comming from the woody variable which is declared in my .csv file which I mentioned earlier above.

The thing what I'm trying to explain with :
"When I try to put the Variable {{Woody}} into a text box then it shows the correct value (Yes/No)."

Is that the Woody variable is showing the right value when I try to call the variable into a textbox:
See code below:

Code: Select all

TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:*txtContactName CONTENT={{Woody}}
AgentWoody.PNG
AgentWoody.PNG (2.03 KiB) Viewed 5133 times
------------------------------------------------------------------------------------------------------------------------------------------------------------

So what I'm trying to reach is to make the VALUE: variable based on the woody value out of my CSV which is a Yes or a No.
So hopefully someone can help me to point this into the right direction.
Also when I'm not clear in some point, don't hesitate to ask me some things!




[strike]Hi all,[/strike]

I'm in search for someone who can help me with the following:

I've a radio button which is build as followed:

<input id="_ctl4__ctl2_rbtAddPurpose1a_0" type="radio" name="_ctl4:_ctl2:rbtAddPurpose1a" value="yes">
<input id="_ctl4__ctl2_rbtAddPurpose1a_0" type="radio" name="_ctl4:_ctl2:rbtAddPurpose1a" value="no">

Now I've added the following code:

TAG POS=1 TYPE=INPUT:RADIO ATTR=NAME:_ctl4:_ctl2:rbtAddPurpose1a&&VALUE:{{Woody}}
Woody is a variable that is comming from my .csv file. Woody is a Yes or a No.
But I got the following error when I'm trying to run this :
Error -1200 in Enter Consignment Details: Attribute VALUE: is empty. Please specify a value like VALUE:"" (-1200)

When I try to put the Variable {{Woody}} into a text box then it shows the correct value (Yes/No).

Hopefully someone can point me into the right direction!

ps. I think I've posted this in the wrong section. Maybe someone can put it into the right section! :)
Last edited by Burger on Wed Aug 10, 2022 9:34 am, edited 5 times in total.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Choose radio button based on value

Post by chivracq » Mon Aug 08, 2022 3:49 pm

Burger wrote:
Mon Aug 08, 2022 7:24 am
Hi all,

I'm in search for someone who can help me with the following:

I've a radio button which is build as followed:

Code: Select all

<input id="_ctl4__ctl2_rbtAddPurpose1a_0" type="radio" name="_ctl4:_ctl2:rbtAddPurpose1a" value="yes">
<input id="_ctl4__ctl2_rbtAddPurpose1a_0" type="radio" name="_ctl4:_ctl2:rbtAddPurpose1a" value="no">
Now I've added the following code:

Code: Select all

TAG POS=1 TYPE=INPUT:RADIO ATTR=NAME:_ctl4:_ctl2:rbtAddPurpose1a&&VALUE:{{Woody}}
Woody is a variable that is comming from my .csv file. Woody is a Yes or a No.
But I got the following error when I'm trying to run this :

Code: Select all

Error -1200 in Enter Consignment Details: Attribute VALUE: is empty. Please specify a value like VALUE:"" (-1200)
When I try to put the Variable {{Woody}} into a text box then it shows the correct value (Yes/No).

Hopefully someone can point me into the right direction!

ps. I think I've posted this in the wrong section. Maybe someone can put it into the right section! :)

Yep, no problem about the "wrong section", nothing related to 'Data Extraction' indeed, I've moved your Thread to the 'General' Sub-Forum... :wink:

>>>

But OK, for me to "have a Look" and do any "Thinking"/Answering about your Thread, you would need to read the Forum Rules (+ my Sig), and to mention your FCI... :idea:
=> CIM...! :mrgreen: (Explained in my Sig...)

... Even if I can already "deduct" from the Error Code that you are probably using iMB v10.x/v11.x/14.x, => + Win7/8/10/11, but I don't want to have to "play little Detective" to try to guess your FCI... :twisted:
=> You can add it to your OP (Opening Post), preferably at the very Top (or Bottom is also OK :P ), this is the first Info "we" (Advanced Users & @TechSup) need to be able to answer most Threads on the Forum... (... And I "refuse" for myself to answer Threads when FCI is not mentioned, oops...! :P )
- (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...
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Choose radio button based on value

Post by chivracq » Mon Aug 08, 2022 7:23 pm

Awaiting you to mention/add your FCI to your OP, and you've seen my Reply, shouldn't be "too difficult" to mention 3 Versions, I would think...! :o , and hum, 2 Versions for you actually, if I'm correct about iMB, + 'Pro'/'Enterprise'/'Trial'.
=> 'Enterprise' I reckon, as you were using '.vbs' Scripts, from your previous Thread, but if a '.vbs' Script is "involved" in this Thread, then I would also need the 'SI' Version ('Scripting Interface'), but it should/will "normally" be the same like the iMB Version...

>>>

But anyway, I already had a Look at your "Scenario" and already did some Testing... 8)
No URL posted, so I used the Forum phpBB 'ucp' Page, => from the 'Board preferences' Tab + 'Edit global settings' Sub-Tab (direct Link), which contains several RB's, => on the "Users can contact me by email:" RB for example, which contains 2 Options with Values="1"/"0" (="Yes"/"No").

HTML Source of that RB:

Code: Select all

<dl>
	<dt><label for="viewemail0">Users can contact me by email:</label></dt>
	<dd>
		<label for="viewemail1"><input type="radio" name="viewemail" id="viewemail1" value="1" checked="checked" /> Yes</label>
		<label for="viewemail0"><input type="radio" name="viewemail" id="viewemail0" value="0" /> No</label>
	</dd>
</dl>
FCI (still) not mentioned, so I did all my Testing using:

Code: Select all

iMacros for FF v8.8.2, PM v26.3.3, Win10_Pro.
(I don't have any Version(s) of iMB anyway...)

And to select/toggle this 'Email' RB, ("my" Version of) iMacros will record:

Code: Select all

TAG POS=1 TYPE=INPUT:RADIO FORM=ID:ucp ATTR=ID:viewemail0
... And the Select is done on "ID:viewemail0" (="No"="0") or "ID:viewemail1" (="Yes"="1") as both Options within the RB have different ID's.

=> I can modify that recorded Line to also use the 'VALUE' Attribute like you are doing...:

Code: Select all

TAG POS=1 TYPE=INPUT:RADIO FORM=ID:ucp ATTR=NAME:viewemail&&VALUE:1
... And that works...!, => using "0"/"1" to toggle the RB. :D :P :D

Works also if I enclose the Value between Double Quotes like in:

Code: Select all

TAG POS=1 TYPE=INPUT:RADIO FORM=ID:ucp ATTR=NAME:viewemail&&VALUE:"1"
Then "everything" I try using a Var instead of hard-coding the Value in the 'TAG' Statement works...!:

Code: Select all

SET Woody 0
TAG POS=1 TYPE=INPUT:RADIO FORM=ID:ucp ATTR=NAME:viewemail&&VALUE:{{Woody}}
Works also:

Code: Select all

SET Woody "0"
TAG POS=1 TYPE=INPUT:RADIO FORM=ID:ucp ATTR=NAME:viewemail&&VALUE:{{Woody}}
Works also:

Code: Select all

SET Woody 0
TAG POS=1 TYPE=INPUT:RADIO FORM=ID:ucp ATTR=NAME:viewemail&&VALUE:"{{Woody}}"
And works also:

Code: Select all

SET Woody "0"
TAG POS=1 TYPE=INPUT:RADIO FORM=ID:ucp ATTR=NAME:viewemail&&VALUE:"{{Woody}}"
>

If I try to use an "invalid" Value, like "2" for example, then I get some Runtime Error:

Code: Select all

RuntimeError: element INPUT specified by NAME:viewemail&&VALUE:{{Woody}} was not found, line 11 (Error code: -921)
... which was to be expected indeed...

But even if I don't declare the 'Woody' Var, and still try to use it, the 'PROMPT' will display the expected "__undefined__", and the 'TAG' Line will still trigger the "element not found" Runtime Error:

Code: Select all

'SET Woody 0 // Line commented out, => not executed...
PROMPT {{Woody}}
TAG POS=1 TYPE=INPUT:RADIO FORM=ID:ucp ATTR=NAME:viewemail&&VALUE:{{Woody}}
=> I never get "your" Runtime Error about "Attribute VALUE: is empty.". :? :P

Oh...!, wait...!, I haven't tried this one yet:

Code: Select all

SET Woody ""
TAG POS=1 TYPE=INPUT:RADIO FORM=ID:ucp ATTR=NAME:viewemail&&VALUE:{{Woody}}
=> Nope..., I also get the "element not found" Error...

One mini-Bit I couldn't test, is if Case Sensitivity might play a Role, as the Page I'm using for my Tests is using "1"/"0" (= Numbers) for the Values, while you are using "Yes"/"No" (= Strings) in your Scenario/Implementation, + possible "Discrepancy" between "yes/no" <> "Yes/No", but I don't think that would play a Role, I think iMacros at Runtime is Case Insensitive for the 'ATTR' Param and different Attributes, I've already tested that "once", and I think I even use it myself in one of my Scripts... (But I've never tested that on a RB though...)
But anyway, even if it did, you would then get some "element not found" Error and not your "empty VALUE" one...! :P

>

Then..., I "don't know"... :? , maybe "your" Version of iMacros/iMB behaves differently than mine, + you would need to post "a bit more Info" about your whole Script, and how you declare that 'Woody' Var, especially because of your "Woody is a variable that is com[m]ing from my .csv file." Sentence which sounds a bit "strange" to me anyway..., because retrieving some Value from a '.CSV' DataSource is done using '{{!COLn}}', using some extra Var like you are doing is already a bit "cumbersome"... :(
But I would need to see the whole "Workflow" of your Script..., and if a '.vbs' Script is involved, then also how you retrieve that Content from the '.CSV' File, to then use it in the Declaration for your 'Woody' Var, in the '.vbs' or in the (on-the-fly) '.iim' Script, how you eventually pass it to some separate '.iim' Script (using 'iimSet()'), etc... :idea:

+ Your Sentence " When I try to put the Variable {{Woody}} into a text box then it shows the correct value (Yes/No)." is also not "completely clear" to me, if you used some 'PROMPT' Command in (one? of) the '.iim' Script(s), or if you triggered it from some "higher Level" from the '.vbs' Script itself, and where between the different '.iim' Scripts... :?
- (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...
Burger
Posts: 16
Joined: Thu Jan 14, 2021 6:56 am

Re: Choose radio button based on value

Post by Burger » Mon Aug 08, 2022 8:58 pm

Hi chivracq,

Already many thanks for your answer! I will look into this tomorrow and will reply and add as many as I know from my Imacros. Will edit the post!

Already many thanks for answering!
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Choose radio button based on value

Post by chivracq » Mon Aug 08, 2022 9:36 pm

Burger wrote:
Mon Aug 08, 2022 8:58 pm
Hi chivracq,

Already many thanks for your answer! I will look into this tomorrow and will reply and add as many as I know from my Imacros. Will edit the post!

Already many thanks for answering!

OK, Thanks for the "Heads-up" already... :D

And hum, try indeed to post an Update tomorrow, as I'll be "a bit busy" from Wednesday and the rest of the Week... :P

(Next to iMacros "Lover" and Advanced User (+ Forum Mod), I'm also a DJ IRL and will be gone playing [Th.-Su.] for some big Festival in NL, ... and where I probably won't have much time to spend on the Forum, or just to quickly approve First Posts by Newly Registered Users... But I would be able to ping @TechSup if I wasn't able to follow up, which I might do anyway if '.vbs' is involved, and/or if the Issue you are encountering is specific to some iMB Version, and especially if, (from your previous Thread), @Tom (= @TechSup) wrote your Script himself, ah-ah...! 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...
Burger
Posts: 16
Joined: Thu Jan 14, 2021 6:56 am

Re: Choose radio button based on value

Post by Burger » Wed Aug 10, 2022 9:36 am

chivracq wrote:
Mon Aug 08, 2022 9:36 pm
Burger wrote:
Mon Aug 08, 2022 8:58 pm
Hi chivracq,

Already many thanks for your answer! I will look into this tomorrow and will reply and add as many as I know from my Imacros. Will edit the post!

Already many thanks for answering!

OK, Thanks for the "Heads-up" already... :D

And hum, try indeed to post an Update tomorrow, as I'll be "a bit busy" from Wednesday and the rest of the Week... :P

(Next to iMacros "Lover" and Advanced User (+ Forum Mod), I'm also a DJ IRL and will be gone playing [Th.-Su.] for some big Festival in NL, ... and where I probably won't have much time to spend on the Forum, or just to quickly approve First Posts by Newly Registered Users... But I would be able to ping @TechSup if I wasn't able to follow up, which I might do anyway if '.vbs' is involved, and/or if the Issue you are encountering is specific to some iMB Version, and especially if, (from your previous Thread), @Tom (= @TechSup) wrote your Script himself, ah-ah...! 8) )
Did a update on my first post! Hopefully I gave you now some useful information!
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Choose radio button based on value

Post by chivracq » Thu Aug 11, 2022 3:11 pm

Burger wrote:
Wed Aug 10, 2022 9:36 am
Did a update on my first post! Hopefully I gave you now some useful information!

OK, but I already went to my Festival yesterday, I don't really have any time "now" to follow up, I've pinged @TechSup to "take over"...
- (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...
Tom, Tech Support
Posts: 3834
Joined: Mon May 31, 2010 4:59 pm

Re: Choose radio button based on value

Post by Tom, Tech Support » Fri Aug 12, 2022 1:30 pm

I think chivracq's intial response was already comprehensive enough to answer the question.

Here's another example using one of our demo pages:

Code: Select all

SET size medium

URL GOTO=https://demo.imacros.net/Automate/TestForm1
TAG POS=1 TYPE=INPUT:RADIO ATTR=NAME:drinksize&&VALUE:{{size}}

@Burger, this should be all you need to do in your macro:

Code: Select all

TAG POS=1 TYPE=INPUT:RADIO ATTR=NAME:_ctl4:_ctl2:rbtAddPurpose1b&&VALUE:{{Woody}}

Did you try this already? If it is not working, then I suggest displaying the variable value *immediately* before tagging the radio button to be absolutely sure it is the value you expect at that time (as chivracq also demonstrated with his code snippets):

Code: Select all

PROMPT {{Woody}}
TAG POS=1 TYPE=INPUT:RADIO ATTR=NAME:_ctl4:_ctl2:rbtAddPurpose1b&&VALUE:{{Woody}}
Regards,

Tom, iMacros Support
Burger
Posts: 16
Joined: Thu Jan 14, 2021 6:56 am

Re: Choose radio button based on value

Post by Burger » Mon Aug 15, 2022 2:52 pm

Hmm Strange..

When I'm trying to do the prompt in my first windows where it doesn't mind if it giving me back the right value, then It's working.
When I try to do the prompt on the specific page, the prompt is showing a empty value..
Could that be something in my vbs file Tom ?

Solved!

I've added a piece of code in my .VBS file! NOw it's working! Thanks for all the help!
Tom, Tech Support
Posts: 3834
Joined: Mon May 31, 2010 4:59 pm

Re: Choose radio button based on value

Post by Tom, Tech Support » Mon Aug 15, 2022 3:48 pm

No problem, glad it's sorted now. Thanks for the update!
Regards,

Tom, iMacros Support
Post Reply