Prompting a user for input with WebRecorder

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
JonDubya
Newbie
Posts: 18
Joined: Thu Mar 20, 2008 6:32 pm

Prompting a user for input with WebRecorder

Post by JonDubya » Thu Mar 20, 2008 6:35 pm

Is this possible? I have a process to automate, however it requires a user to enter a value specific to each process run. Is there a way to get a popup box, ask for the input (string) and then return those results to the web form field?

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Mar 20, 2008 6:49 pm

Yes. WebRecorder creates Macro Scheduler code. So you can edit the script in Macro Scheduler and use any Macro Scheduler function you like. Sounds like the Input function is what you need, but you could also design your own dialogs with the custom dialog designer.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

JonDubya
Newbie
Posts: 18
Joined: Thu Mar 20, 2008 6:32 pm

Post by JonDubya » Thu Mar 20, 2008 7:11 pm

Sweet...I have another question...checkboxes...I want it to UNCHECK certain boxes but when I check or uncheck the box, the script code looks the same to me, is there a way to make it only uncheck?

JonDubya
Newbie
Posts: 18
Joined: Thu Mar 20, 2008 6:32 pm

Post by JonDubya » Thu Mar 20, 2008 8:36 pm

nvm, found the Get/Set CheckBox functions.

JonDubya
Newbie
Posts: 18
Joined: Thu Mar 20, 2008 6:32 pm

Post by JonDubya » Thu Mar 20, 2008 8:59 pm

Ok...it seems that I'm using the GetCheckBox wrong or something because it continues to return 0. Is this function usable with IE? Here's my code:

Code: Select all


Let>FrameName={"main content"}
Let>FormName={""}
GetCheckBox>%IE[0]%,IPDHCPENABLE,dhcp
If>dhcp=1,checked,unchecked

Label>checked
Label>end

Label>unchecked
Let>FrameName={"main content"}
Let>FormName={""}
Let>TagValue={"vac.255.IPDHCPENABLE:1"}
IE_ClickTag>%IE[0]%,str:FrameName,str:FormName,INPUT,CHECKBOX,str:TagValue,r
Label>end
For the object_caption value, I've tried both the text next to the checkbox ("Enable DHCP") and the actual checkbox name, IPDHCPENABLE, with neither working. The problem either lies with that or with the window_title value (also guessing at this since it's what everything else uses in the script).

TIA
Jon

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Mar 20, 2008 9:10 pm

GetCheckBox/SetCheckBox work with regular windows - regular checkbox controls - windowed controls. Checkboxes in web pages are not windowed controls - they are HTML elements - part of the page itself. So GetCheckBox/SetCheckBox cannot work with web page controls.

You need to use WebRecorder's ClickTag function. However, you have noticed that this clicks it but gives you no way of knowing whether or not it is already checked.

What is needed is a new function to return the CHECKED property of a checkbox, or a version of the FormFill function which lets you specifically set the CHECKED property of checkboxes. This isn't there yet, but you have identified a need and we will get on to it immediately!
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

JonDubya
Newbie
Posts: 18
Joined: Thu Mar 20, 2008 6:32 pm

Post by JonDubya » Thu Mar 20, 2008 9:13 pm

Sweet! Thanks!

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Mar 20, 2008 9:19 pm

In the mean time I have just spotted a workaround. You can use the ExtractTag function.

Use the tag extraction wizard. Click on the checkbox. It will create some code something like this:

Let>INPUT5_SIZE=4098
LibFunc>hIE,ExtractTag,r,%IE[0]%,,INPUT,5,0,INPUT5
MidStr>r_6,1,r,INPUT5

This was created when recording against the contact form on our site, clicking on the subscribe checkbox there.

Now, change that zero, in the penultimate field, which I have bolded, to a 1.

This will return something like this:

Code: Select all

<INPUT type=checkbox CHECKED size=30 value=SUBSCRIBED name=subscribe>
When the box is NOT checked it will return:

Code: Select all

<INPUT type=checkbox size=30 value=SUBSCRIBED name=subscribe>
Note that when the checkbox is checked the word CHECKED appears in the tag. And when it is not checked the word CHECKED does NOT appear.

So, we can put this together and do something like this:

Code: Select all

Let>INPUT5_SIZE=4098
LibFunc>hIE,ExtractTag,r,%IE[0]%,,INPUT,5,1,INPUT5
MidStr>r_6,1,r,INPUT5
Position>CHECKED,Input5,1,p
If>p=0
  MessageModal>Not Checked
Else
  MessageModal>Checked
Endif
So now you can determine whether or not you should ClickTag it.

Hope this helps.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Mar 20, 2008 9:23 pm

Or if you're using the Imports method, replace the LibFunc line with:

IE_ExtractTag>%IE[0]%,,INPUT,5,1,INPUT5,r
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

JonDubya
Newbie
Posts: 18
Joined: Thu Mar 20, 2008 6:32 pm

Post by JonDubya » Thu Mar 20, 2008 9:26 pm

Yes, thanks again! Also, is there a list of the IEAuto functions (IE_*), their inputs and what the function does? Pretty much like what the Help for the Macro Scheduler does.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Mar 20, 2008 9:29 pm

Yes, look at the WebRecorder help file. Topic called "IEAuto.DLL Functions".

Run WebRecorder, clieck Help/Contents. Or hit F1. Or Start/Programs/WebRecorder Help.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

JonDubya
Newbie
Posts: 18
Joined: Thu Mar 20, 2008 6:32 pm

Post by JonDubya » Fri Mar 21, 2008 2:53 pm

Ok the workaround works. But man...what's with the r var? That s*** is confusing!

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Mar 21, 2008 2:57 pm

The "r" is the return variable. I could have called it "Fred". Call it "Result" if you think it makes it less confusing. It is just the name of the variable that stores the results of the function. r has the return code. r_6 the HTML returned as it relates to the 6th parameter which is a buffer.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

JonDubya
Newbie
Posts: 18
Joined: Thu Mar 20, 2008 6:32 pm

Post by JonDubya » Fri Mar 21, 2008 3:03 pm

yeah, I just renamed it.

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