Micro Focus QTP (UFT) Forums
Use of RegisterUserFunc - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Use of RegisterUserFunc (/Thread-Use-of-RegisterUserFunc)



Use of RegisterUserFunc - tapandalal - 10-24-2008

Hi Ankur,

I am trying to use RegisterUserFunc in my script to set one Function and Use it as my new Value.

What I want to do is I have Textbox of name:"ClientName". Everytime when I run my script I want to use a new value for that I created one function of Random_Generator which generates Random No and then Join this Random No with one predefined clientName:

here is that Function:

Code:
Function Random_Generator (Max_Value, Min_Value)
   Dim Mystring,MyValue,MyArray(1),RandomNo
   Max_Value=100
   Min_Value=10
   Randomize
   RandomNo=Int ((Max_Value - Min_Value + 1) * Rnd) + Min_Value
   Mystring = Cstr (RandomNo)
   MyArray(0) = "Smoke Test_AddClient"
   MyArray(1) = Mystring
   MyValue = Join (MyArray)
   MyValue= Cstr(MyValue)
   Random_Generator=MyValue
'   msgbox Random_Generator
End Function

after this I am going to the main Test, and recording a script, right now I am trying on Google. Our environement is not ready for testing.

I recorded the script for logging in Google.

and then I used this function so I can enter different username each time i run the script,
Code:
'RegisterUserFunc  "WebEdit", "Set", "Random_Generator"
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Email").Set " "

here i donot unserstand what should I put in Set " " field. I tried to put lot of things but it is not inserting any text in gmail username.

Do i need to change anything in the object proporties first.

Thanks
Tapan Dalal