Wednesday, September 21, 2011

message window validation

If not dialog( "Login").Exist(2)Then
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\HP\QuickTest Professional\samples\flight\app\",""
End If
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "rajan"
Dialog("Login").WinEdit("Agent Name:").Type micTab
Dialog("Login").WinEdit("Password:").SetSecure "4e2e616befbf25362991054e9261351ead9a"
Dialog("Login").WinButton("OK").Click
Dialog("Flight Reservations").WinButton("OK").Click
Dialog("Login").WinButton("Help").Click
Dialog("Flight Reservations").Static("The password is 'MERCURY'").Check CheckPoint("The password is 'MERCURY'")
message = Dialog("text:= Login").dialog("text:= Flight Reservations").Static("window id:= 65535").GetROProperty("text")
Dialog("Flight Reservations").WinButton("OK").Click

If message = "The password is 'MERCURY'" Then
reporter.ReportEvent 0,"Res","Correct message" & message
else
reporter.ReportEvent 1,"Res","Incorrect message"
End If

Check Checkbox using Descriptive programming

Option explicit
Dim qtp,flight_app,f,t,i,j,x,y
If not Window("text:= Flight Reservation:").Exist (2) = true Then
qtp = Environment("ProductDir")
Flight_app = "\samples\flight\app\flight4a.exe"
SystemUtil.Run qtp & Flight_app
Dialog("text:= Login").Activate
Dialog("text:= Login").WinEdit("attached text:= Agent Name:").Set "asdf"
Dialog("text:= Login").WinEdit("attached text:= Password:").SetSecure "4e2d605c46a3b5d32706b9ea1735d00e79319dd2"
Dialog("text:= Login").WinButton("text:= OK").Click
End If

Window("text:= Flight Reservation").Activate
Window("text:= Flight Reservation").Activex("Acx_name:= MaskEdBox","window id:=0").Type "121212"
f = Window("text:= Flight Reservation").WinComboBox("attached text:= Fly From:").GetItemsCount

For i= 0 to f-1 step 1
Window("text:=Flight Reservation").WinComboBox("attached Text:= Fly From:").Select(i)
x =Window("text:=Flight Reservation").WinComboBox("attached Text:= Fly From:").GetROProperty("text")
t = Window("text:=Flight Reservation").WinComboBox("attached text:= Fly To:","x:= 244","y:=143").GetItemsCount
For J = 0 TO t-1 step 1
Window("text:= Flight Reservation").WinComboBox("attached text:= Fly To:","x:= 244","y:=143").Select(j)
y = Window("text:= Flight Reservation").WinComboBox("attached text:= Fly To:","x:= 244","y:=143").GetROProperty("text")
If x <> y Then
Reporter.ReportEvent 0,"Res","Test passed"
else
Reporter.ReportEvent 1,"Res","Test Failed"
End If

Next

Next

Getting dynamic text from the webpage by using text output value function

Step 1: Open google and type as site: motevich.blogspot.com QTP
Step 2: Click search button
Step 3: get a searched result
Step 4: see below google search bar we can view no of results displayed like 1000 or 2000
Step 5: now we can capture that no of values only
Step 6: now just change as test instead of QTP
Step 7: Click search button
Step 8: get a searched result
Step 9: now we can get someother result like 3000 or 4000
Step 10: Stop recording
Step 11: Go to active screen and select the value what we want to get and right click that
Step 12: just click text output value ,screen will open
Step 13: Make some changes in that window
Step 14: click ok
Step 15: again run the script


Browser("Google").Page("Google").WebEdit("q").Set "site: motevich.blogspot.com QTP"
Browser("Google").Page("Google").WebButton("Google Search").Click
Browser("Google").Page("site: motevich.blogspot.com").Sync
Browser("Google").Page("Google").Output CheckPoint("ResCount_2")
msgbox Datatable.Value("count")
Browser("Google").CloseAllTabs

Verify the Check point and if check point is true or false further process is handled using functional statement

Dim Str
Dialog("Login").WinEdit("Agent Name:").Set "rajan"
Dialog("Login").WinEdit("Agent Name:").Type micTab
Dialog("Login").WinEdit("Password:").SetSecure "4e2558dc476c11a2ea3597e2545811aef6477598"
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").WinComboBox("Fly To:").Check CheckPoint("Fly To:_2")
Str = Window("Flight Reservation").WinComboBox("Fly To:").Check (CheckPoint("Fly To:"))

msgbox (Str)
If Str = true Then
process()
Else
exitaction()
End If

Private Function process()
Window("Flight Reservation").WinComboBox("Fly To:").Select "London"
Window("Flight Reservation").Dialog("Flight Reservations").WinButton("OK").Click
exitaction()
End Function

Private Function exitaction()
Window("Flight Reservation").Close
End Function

Open Various Application using vb script

Dim wsh
Public Function Launch_App(arg1)
Set wsh=CreateObject("wscript.shell")
wsh.run arg1
Set wsh=nothing
End Function

Call Launch_App("Notepad.exe")
wait 1
Call Launch_App("cmd.exe")
wait 1
Call Launch_App("www.google.com")
wait 1
Call Launch_App("calc.exe")

Run Multiple QTP Test Script using command prompt and display results in command prompt itself

Dim APP //Declaration
Set APP = CreateObject("QuickTest.Application") //create Application object
App.Launch //Start Quicktestapplication
App.Visible = True //make QTP Application visible
Dim QTP_Tests(3) //Declaration
QTP_Tests(1) = "C:\Users\perinbarajani\Documents\HP\QuickTest Professional\Tests\pagecheckpoint" //Set path
QTP_Tests(2) = "C:\Users\perinbarajani\Documents\HP\QuickTest Professional\Tests\textcheckpoint" //Set path
QTP_Tests(3) = "C:\Users\perinbarajani\Documents\HP\QuickTest Professional\Tests\Tooltip" //Set path
set res_obj = CreateObject("QuickTest.RunResultsOptions") //Create run result object

For i=1 to Ubound(QTP_Tests) //For loop running Multiple application
App.Open QTP_Tests(i),True
Set QTP_Test = App.Test
res_obj.ResultsLocation = Qtp_Tests(i) & "QTPResults"
Qtp_Test.Run res_obj,True
QTP_Test.close
Next

App.Quit //Quit the Application
Set res_obj = nothing //Release Result object
Set QTP_Test = nothing // Release the test object
Set App = nothing // Release the application object

Wednesday, September 7, 2011

Bugs, defects and issues

This article explains the terminologies like bugs, defects and issues

All these three terms means the same. It all represents a problem in software.

Background of Bug

In 1946, a huge electromechanical computer stopped functioning suddenly. Operators traced that a bug was trapped in it's relay unit causing the problem. They fixed the problem by removing the bug. Software "bug tracking" and "bug fixing" was evolved from this!

Below is the picture of the first real bug reported:



For several years, the term "bug" and "defect" were widely used in software develop process to indicate problems in software. However, software engineers started questioning the terms "bugs" and "defects" because in many cases they argue that certain "bug" is not a bug, but it is a "feature" or "it is how customer originally asked for it". To avoid conflicts between testing and development team, several companies are now using a different term - "software issue".

Even though both "issue" and "bug" indicate some kind of problems in software, developers feel the term "issue" is less offensive than "bug" ! This is because, the bug directly indicate a problem in the code he wrote, while "issue" is a term which indicates any kind of general problems in the software including wrong requirement, bad design etc.

Whatever problems the QA or testing team find, they will call it as an "issue". An issue may or may not be a bug. A tester may call a feature as a "issue" because that is not what the customer wants, even though it is a nice feature. Or, the software is not delivered to QA team on the date planned, it can be reported as an "issue".

The tester reports issues and his role ends there. It is the job of the product manager to decide whether to solve the issue and how to solve it. Depending on the nature of the issue, the product manager assigns it to the appropriate team to resolve. Product manager may even decide to "waive the issue" if he feels that it is not a problem. If the issue is a bug, then it will be assigned to the developers and they will fix the code. When the bug is fixed, the testing team will re test the software and verify it. If the issues is fixed, then the status of the issue will be changed to "closed".

An issue can be resolved in different ways, depending on it's nature. If it is a software bug, it goes to the developer to correct the code and program. If it is due to wrong requirement, it goes to the customer or marketing to correct the requirement. If the issue was caused by bad configuration in the testing computer, it will be assigned to the appropriate hardware representative to correct the configuration problem.

Software developers like the term "issue" rather than "bug" because the term "issue" does not really indicate that there is a problem in their code ! The term "issue" is becoming the standard in software testing process to indicate problems in software.