Micro Focus QTP (UFT) Forums
script for login feature - 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: script for login feature (/Thread-script-for-login-feature)



script for login feature - sekhan - 10-06-2010

can you help me
i have a script
Code:
Browser("Browser").Page("ABC").WebEdit("user_login").Set DataTable("user", dtGlobalSheet)
strMail = Browser("Browser").Page("ABC").WebEdit("user_login").ToString
Browser("Browser").Page("ABC").WebEdit("password").SetSecure "3c32f2445bbc7481db3492b1d1556ceb7fdf9e03ca7be253143d"
If strMail = "dqv@yahoo.com" Then
    Browser("Browser").Page("ABC").WebButton("Login").Click
else
    reporter.ReportEvent micFail, "Failed Report","Failed Email"
End If

when i input "dqv@yahoo.com" (this acc i registered) into datatable. the report always display Failed Email case without run Login case. i don't know why


RE: script for login feature - Saket - 10-06-2010

I am not able to understand what exactly you are trying to do here, You are passing the username through datatable again taking it to a variable , are you trying to verify if it has been set or not? what is the logic, would you like to elaborate it?

put a msgbox there to see what comes in strMail?
ToString is not a correct method to get the value from webedit, it will returns the string representation of webedit, something like 'txtusername edit box', that's why you are getting always fail result. Use GetROProperty("Value")


RE: script for login feature - quicktest - 10-06-2010

For this script, if you are trying to compare
Code:
If strMail = "dqv@yahoo.com" Then
Browser("Browser").Page("ABC").WebButton("Login").Click
else
reporter.ReportEvent micFail, "Failed Report","Failed Email"
End If
The script should be
If strcomp (strMail,"xxxxxx") = 0 Then
Browser("Browser").Page("ABC").WebButton("Login").Click
else
reporter.ReportEvent micFail, "Failed Report","Failed Email"
End If



RE: script for login feature - sekhan - 10-07-2010

my script has run correctly
i added into script:
Code:
Browser("Browser").Page("ABC").WebEdit("user_login").SetTOProperty "value", DataTable("user", dtGlobalSheet)
strMail = Browser("Browser").Page("ABC").WebEdit("user_login").GetTOProperty("value")
everyone, thanks
with this script, i want to catch the case user input data do not accord with requirement of the test case
Ex: for the test case, you must input a registered email, but you input a email has not yet been registered


RE: script for login feature - quicktest - 10-07-2010

You obviously got to compare with existing email address using strcomp function ... where are you storing the registered email addresses?

If they are stored in DB, connect to DB and run the for loop till eof, use strcomp condition in between the for loop ....