In this blog, I will show you how to use QTP to test YouPlayOff.com for the following functions:
1, log in as a confirmed user, the “Add New” player link exists
2, Log in as non-confirmed user, the “Add New” player link won’t exists
3, Log in from log out page, the page will c to Home page
From this blog, you should be able to practice and learn the following:
1, How to define an object (i.e., not a number, not a string, etc.) (Dim and Set);
2, How to check if an object exists (object.exist);
3, How to write test result directly to the test result summary (Reporter.ReportEvent);
4, How to use If Then;
Dim addLink, addLinkText
addLinkText = "Add New"
'Confirmed user: addLink exists
Browser("YouPlayoff - Create and").Page("YouPlayoff - Create and").Sync
Browser("YouPlayoff - Create and").Navigate "http://testing.youplayoff.com/category/28/Hockey/?type=1"
Browser("YouPlayoff - Create and").Page("YouPlayoff - Hockey Players_2").Link("Sign In").Click
RunAction "Log in [Log in]", oneIteration
Set addLink = Browser("YouPlayoff - Create and").Page("YouPlayoff - Hockey Players").Link("text:=" & addLinkText)
If addLink.Exist Then
Reporter.ReportEvent micPass, "Find the AddNew Link when logged in as confirmed user", "PASS"
Else
Reporter.ReportEvent micFail, "Can NOT find the AddNew Link when logged in as confirmed user", "FAIL"
End If
'Check redirect function of login from logout page
Browser("YouPlayoff - Create and").Page("YouPlayoff - Hockey Players_3").Link("Sign out").Click
Browser("YouPlayoff - Create and").Page("Logout - YouPlayoff").Link("Sign In").Click
Browser("YouPlayoff - Create and").Page("Login - YouPlayoff").WebEdit("name").Set "guidebillion"
Browser("YouPlayoff - Create and").Page("Login - YouPlayoff").WebEdit("password").SetSecure "4c09bae5a2cf4dc2f458b8815ed6e83fdd06dd004f8f346d"
Browser("YouPlayoff - Create and").Page("Login - YouPlayoff").WebButton("Submit").Click
Browser("YouPlayoff - Create and").WinEdit("Edit").Check CheckPoint("Edit")
'Non-confirmed user: addLink does not exist
Browser("YouPlayoff - Create and").Navigate "http://testing.youplayoff.com/category/28/Hockey/?type=1"
Set addLink = Browser("YouPlayoff - Create and").Page("YouPlayoff - Hockey Players").Link("text:=" & addLinkText)
If addLink.Exist Then
Reporter.ReportEvent micFail, "Find the AddNew Link when logged in as NON-confirmed user", "FAIL"
Else
Reporter.ReportEvent micPass, "Can NOT find the AddNew Link when logged in as NON-confirmed user", "PASS"
End If
Browser("YouPlayoff - Create and").Page("YouPlayoff - Hockey Players").Link("Sign out").Click
Browser("YouPlayoff - Create and").Page("Logout - YouPlayoff").Link("Home").Click