Page 1 of 1

Internet Library Question - How to URL encode a variable?

Posted: Mon May 09, 2011 5:13 pm
by MasterchiefJB
Basically I want to use a variable for the following Login script.
I just posted the relevant lines of my script as everything else would be quite confusing.

So instead of a static value I would like to use a variable to fill in the WebForm of my TestWebsite.
Using the code below I am able to successfully fill in the WebForm with static values like StaticTestUsername and StaticTestPassword.

Code: Select all

  // TestWebsite.COM Login 
   put "TestUsername" into tDynamicLogin
   put "TestPassword" into tDynamicPass

get revBrowserExecuteScript(tBrowserId2, "document.getElementById('COOKIEusername').value = 'StaticTestUsername';")
      #get revBrowserExecuteScript(tBrowserId2, "document.getElementById('COOKIEusername').value = tDynamicLogin ;") # <- I would like to use the tDynamicLogin variable instead of a static value.
get revBrowserExecuteScript(tBrowserId2, "document.getElementById('COOKIEpass').value = 'StaticTestPassword';")
      #get revBrowserExecuteScript(tBrowserId2, "document.getElementById('COOKIEpass').value = tDynamicPass';") # <- I would like to use the tDynamicPass variable instead of a static value.

 
I wasn´t able to achieve a working result but the final output should look like this:

Code: Select all

get revBrowserExecuteScript(tBrowserId2, "document.getElementById('COOKIEusername').value = 'tDynamicLogin';")  // Whereas tDynamicLogin is "TestUsername"
get revBrowserExecuteScript(tBrowserId2, "document.getElementById('COOKIEpass').value = tDynamicPass';") // Whereas tDynamicPass is "TestPassword"
I appreciate everyone´s help who is able to help me short this little problem out.

Regards,
Masterchief

Re: Internet Library Question - How to URL encode a variable?

Posted: Mon May 09, 2011 5:21 pm
by Klaus
Hiu Chief,

you must build the necessary string like this:
...
put urlencode(tDynamicLogin) into tUrlLogin
put urlencode(tDynamicPass) into tUrlPass
get revBrowserExecuteScript(tBrowserId2, "document.getElementById('COOKIEusername').value = '" & tUrlLogin & "';")
get revBrowserExecuteScript(tBrowserId2, "document.getElementById('COOKIEpass').value = '" & tUrlPass & "';")
...

Get the picture?


Best

Klaus

Re: Internet Library Question - How to URL encode a variable?

Posted: Mon May 09, 2011 6:32 pm
by MasterchiefJB
Wow Klaus!
Thanks for the fast answer!

Got the picture! Now everything works right now!

Cheers!
Masterchief