QTP Web scripts

'Test Requirement: Verify the Cost in jjperfumes web portal
'Where Cost=Quantity*Unit Price

'************************************************************************
SystemUtil.Run "C:\Program Files\Internet Explorer\IEXPLORE.EXE", "www.jjperfumes.com"

Browser("JJ Perfumes-Discount perfume").Page("JJ Perfumes-Discount perfume").Image("thumb_1845_WLINP50PSW").Click
Browser("JJ Perfumes-Discount perfume").Page("JJ Perfumes-Discount perfume_2").WebEdit("quantity").Set "4"
Browser("JJ Perfumes-Discount perfume").Page("JJ Perfumes-Discount perfume_2").WebButton("Add To Cart").Click

Unit_Price = Browser("JJ Perfumes-Discount perfume").Page("JJ Perfumes-Discount perfume_3").WebElement("[Remove]").GetROProperty("innertext")
Quantity = Browser("JJ Perfumes-Discount perfume").Page("JJ Perfumes-Discount perfume_3").WebEdit("quantity[]").GetROProperty("value")
Cost = Browser("JJ Perfumes-Discount perfume").Page("JJ Perfumes-Discount perfume_3").WebElement("[Remove]_2").GetROProperty("innertext")

'Msgbox Unit_Price: Msgbox Quantity: Msgbox Cost
Unit_Price=Cdbl (Unit_Price)
Quantity=Cint(Quantity)
Cost=Cdbl(Cost)

If Cost= Unit_Price*Quantity Then
    Msgbox "Pass"
Else
Msgbox "Fail"
End If


'***************************************************

'Test Requrement : Verify Login & Logout Links
'After Launch the Application then check the existance of the Login and Logout Links
'Login Link only should be available
'After Login Operation then check the existance of the Login and Logout Links
'Logout Link only should be available

'-----------------------------------------------------------------------------------------------------------
SystemUtil.Run "C:\Program Files\Internet Explorer\IEXPLORE.EXE","www.jjperfumes.com"
Wait 5
Set myBrowser=Browser("JJ Perfumes-Discount perfume")
If myBrowser.Page("JJ Perfumes-Discount perfume").Link("Login").Exist(3) Then
Reporter.ReportEvent 0,"Res","Login Link Exists"
Else
Reporter.ReportEvent 1,"Res","Login Link Not Exists"
End If

If Not myBrowser.Page("JJ Perfumes-Discount perfume_5").Link("Logout").Exist(3) Then
Reporter.ReportEvent 0,"Res","Logout Link Not Exists"
Else
Reporter.ReportEvent 1,"Res","Logout Link Exists"
End If
myBrowser.Page("JJ Perfumes-Discount perfume").Link("Login").Click
myBrowser.Page("JJ Perfumes-Discount perfume_4").WebEdit("username").Set "ganga12@yahoo.com"
myBrowser.Page("JJ Perfumes-Discount perfume_4").WebEdit("password").Set "abcd"
myBrowser.Page("JJ Perfumes-Discount perfume_4").WebButton("Login").Click

If Not myBrowser.Page("JJ Perfumes-Discount perfume").Link("Login").Exist(3) Then
Reporter.ReportEvent 0,"Res","Login Link Not Exists"
Else
Reporter.ReportEvent 1,"Res","Login Link Exists"
End If

If myBrowser.Page("JJ Perfumes-Discount perfume_5").Link("Logout").Exist(3) Then
Reporter.ReportEvent 0,"Res","Logout Link Exists"
Else
Reporter.ReportEvent 1,"Res","Logout Link Not Exists"
End If

0 comments:

Post a Comment