Upload
hakhanh
View
221
Download
2
Embed Size (px)
Citation preview
Qtp:
1. What are the Features & Benefits of Quick Test Pro (QTP)..? Operates stand-alone, integrates into Mercury Business Process Testing and Mercury Quality Center. Introduces next-generation “zero-configuration” Keyword Driven testing technology in Quick Test Professional 8.0 — allowing for fast test creation, easier to use. 2. Where can I get Quick Test Pro (QTP) document. In help menu select Printer-Friendly Document. Then choose Quick Test User’s guide hyperlink to open PDF file with almost 1000 pages that gives detailed information of QTP with advanced features. 3. How to handle the exceptions using recovery scenario manager in QTP? There are 4 trigger events during which a recovery scenario should be activated. They are A pop up window appears in an opened application during the test run. A property of an object changes its state or value. A step in the test does 4. What is the use of Text output value in Qtp? Output values enable to view the values that the application talks during run time. When parameterized, the values change for each test iteration. Thus by creating output values, we can capture the values that
5. How to use the Object spy in QTP 8.2 versions? Follow Tools->Object Spy / Select Object Spy button from Object Repository. 6. What are the file extensions in QTP?Test Script - “.mts”, Per-Action OR File – “.mtr”, Shared OR File -“.tsr”, Batch Test File- “.mtb”, Data Table File – “.xls”, Parameters File – “.prm” 7. Explain the concept of object repository & how QTP recognizes objects? Object Repository stores the description of each test object that are captured from object of AUT during recording. It captures the mandatory properties of each object depends on type of object. With this description QTP recognize the same object to perform specified event during test run. 8. What are the properties you would use for identifying a browser & page when using descriptive programming? We use “title” property to identify browser and web page. 9. What are the different scripting languages you could use when working with QTP? VBScript, Java Script and Windows Script Host(WSH) 10. Explain the keyword “CreateObject” with an example. Creates and returns a reference to an Automation object. Example: ES = CreateObject ("Excel.Sheet")
11. Explain in brief about the QTP Automation Object Model (AOM). Quick Test automate the testing of your applications, we can use the QTP Automation Object Model to automate your Quick Test operations. Using the objects, methods, and properties exposed by QuickTest's AOM, we can write programs that configure Quick Test options and run tests instead of performing these operations manually using the Quick Test interface.
Automation programs are especially useful for performing the same tasks multiple times or on multiple tests or components, or quickly configuring Quick Test according to your needs for a particular environment or application.
12. How to handle dynamic objects in QTP? Using “GetROProperty” we will handle the runtime objects.
13. What is a Run-Time Data Table? Where can I find and view this table?
During the run session, Quick Test creates a run-time Data Table—a live version of the Data Table associated with your test or component. When the run session ends, the run-time Data Table closes, and the Data Table pane again displays the stored design-time Data Table. Data entered in the run-time Data Table during the run session is not saved with the test or component. The final data from the run-time Data Table is displayed in the Run-Time Data Table in the Test Results window
14. How does Parameterization and Data-Driving relate to each other in QTP?Using parameterization feature we can enhance test or component by parameterize the values that it uses. A Parameter is variable that is assigned a value from the external data source. There are 4 types of parameters like Test/Action or Component, Data Table parameter, Random Number and Environment Parameter. Data Driving enables to parameterize several property values for test objects, checkpoints. 15. What is the difference between Call to Existing Action and Copy of an Action? When we insert Call to Existing Action, they are read only in the calling test. It can only be modified in the original test. Where as come to Copy of Action, you can make changes to the copied action. Changes will not effect the original action where it created. 16. Discuss QTP Environment. Quick Test Pro environment uses the graphical interface and Active Screen technologies. A testing process for creating test scripts, relating manual test requirements to automated verification features - Data driving to use several sets of data using parameters. 17. Explain the concept of how QTP identifies object. During recording QTP looks at the object and stores it as test object. For each test object QTP learns a set of default properties called mandatory properties and look at the rest of the objects to check whether this properties are enough to uniquely identify the same object during test run. 18. Differentiate the two Object Repository Types of QTP. In QTP there are 2 object repositories, Shared Object Repository and Per Action Mode. Default mode is Per-Action. In Shared, we use only one OR that is common to all actions and can share by other testers. It's like calling external libraries. We will use per action OR for a each action exclusively. 19. What the differences are and best practical application of each. Per Action: For Each Action, one Object Repository is created. Shared: Single Object Repository will be used for all actions.
20. Disadvantages of Shared Object Repository?It cannot store objects when it reaches maximum Size (2MB). We cannot do changes to an object by tester at the same time.
21. Can you do more than just capture and playback? Yes, I can do more than capture/playback. Descriptive Programming is the answer to this question. We can write scripts without recording and it would still work fine. 22. What is the purpose of Ordinal Identifier? This assigns object a numerical value that indicates its order relative to other objects that have the same values for all properties. This ordered value enables Quick Test to create a unique description when the mandatory and assistive properties are not sufficient to do so
23. How to do the scripting. Is there any inbuilt function in QTP? What the difference between them? How to handle script issues? Yes, there's an in-built functionality called "Step Generator" in Insert->Step->Step Generator -F7, which will generate the scripts as u enter the appropriate steps. 24. What is the difference between Check Point and Output Value? An output value is a value retrieved during the run session and entered into runtime table or data table subsequently it can be used as input value in your test. Checkpoint ensures the functionality of an object by verifying the state of an object during the runtime. 25. If we use batch testing the result shown for last action only. In that how can we get result for every action? We can click on the icon in the tree view to view the result of every action. The results for each test are stored in their default location. 26. How the exception handling can be done using QTP Recovery scenario manager provides a wizard that guides you through the defining recovery scenario. Recovery scenario has four steps 1. Triggered Events 2. Recovery steps 3. Post Recovery 4.Name and Finish 27. How do you test Siebel application using QTP? In SWE section we need to add AutomationEnable = TRUE and at the same time you need to use SWECmd= AutoOn in the URL 28. How many types of Actions are there in QTP? QTP structured by actions. Actions are sub procedures which perform certain events on AUT. There are 2 types of actions. Regular actions (non reusable actions) and reusable actions. Regular actions are used only in the script where the action exists. 29. How do you data drive an external spreadsheet? Press mouse right click by placing the cursor Data Table to select Import ->From File. This imports a tabbed text file or a single sheet from an existing Microsoft Excel file into the Data Table. The sheet you import replaces all data in the current Data Table. 30. I want to open a Notepad window without recording a test and I do not want to use SystemUtil.Run command as well how do I do this? We can use WSH (Window Script Host) to create COM object. Use run method to invoke an application in specified window style. Check out with the followingDim wsh Set wsh = WScript.CreateObject ("WSCript.shell")wsh. run "notepad.exe" 31. How many types of recording modes in QTP? Describe each type with an example where we use them?
There are 3 types of recording modes in QTP, Context Sensitive (normal), Analog Recording mode and Low Level Recording mode. Context Sensitive records the objects in the application and operations performed on them. Analog records all mouse exact mouse and keyboard actions. Low level enables to record on any object
32. What if storage limit of shared object repository exceeds its limit (2 MB). How this kind of situation can be handled? One can use advanced object repository Editor from Sirus SQA
33. How to handle java tree in QTP First of all we need to have a java add-in to handle a java tree. In tools option we have the "object identification" drop down list, there we have the java option to recognize the objects. We select the tree option and add the properties 34. How to fetch test data from Database by using QTP? First we have to create an object to “ADODB.Connection”. Then use methods to open connection with data base, execute query and to store the result set. Set con=CreateObject ("ADODB.Connection") 35. How can u write a script without using OR in QTP? We need to design Descriptive Programming where OR is not required. The information about the object will be added into the test script in place of Logical Name.
1. How will you automate a window which while spying is not returning any property value ??Answer 1: In QTP point of view we automation applications where there is proper addin.There are few cases where we can use win32 API and shell programming to acheive.
EX use win32 query to get the handle or processid of the app and use some api to act on it...this will be a work around not a solution.
2. How do you find the color and font of all the links on the page???
Answer 2: Ans: use DHTML properties ....uses object.attributes...u will get all DHTML properties of that particular element in a collection.
3. what are the disadvantages of smart identification.??
Answer 3: Ans. there are many out of which is time consuming it eats lot of time and some times it yields wrong results also in case of dynamic environment.
4.what are the disadvantages of recovery scenario??
Answer 4: I think Space and time may be the constraints, because i never used it. it is pretty waste of time to use it.
5.How can you execute javascript on qtp??
Answer 5: HKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive\QuickTest Professional\Configuration_UI\ScriptMgr
Create a new String value with name AltProgID and value "Mercury.JSScriptMgr" and change the value of "Create" to 1
Create a new child key inside the keyHKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive\QuickTest Professional\Configuration_UI\ScriptConstants{0ECD5785-BE7D-11d4-8EAF-11135659EC56}
Repeat the same steps for the below keyHKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive\QuickTest Professional\Configuration
OpenC:\Program Files\Mercury Interactive\QuickTest Professional\bin\QTEditor.iniAdd the below parameter to [General options]AllowJavaScript = 1DisableVBScript = 1
6.What are the basic prerequisites required in automating an infragistics controls based application?
7.Can i record a web based application on Mozilla??
Answer 7: U can record but not as a web application but a standard windows application
ex:Window("Mozilla Firefox").WinObject("MozillaWindowClass").Type "naveen"
8.What is the difference between Repository Parameter and Repositories Collection ??
Answer 8: Repository parameters enable you to specify that certain property values should be parameterized, but leave the actual parameterization to be defined in each test that is associated with the object repository that contains the parameterized test object property values.Repository parameters are useful when you want to create and run tests on an object that changes dynamically
repositoriescollection is a collection object that enables you to programmatically manage the run-time collection of shared object repository files associated with the current action
for more details refere QTP Help file.
9.How to copy Virtual Object Manager from one computer to another computer??
Answer 9: checkout for .VOT files in dat foler of the installation
10.Can we use GetRoProperty method to get index or location of link in web application??
Answer 10: NO 36. How to add run-time parameter to a datasheet? DataTable.GlobalSheet.AddParameter (“ParamName”,”value”) DataTable.LocalSheet.AddParameter (“ParamName”,”value”)
DataTable:
1. You can use the DataTable, DTSheet and DTParam utility objects to manipulate the data in any cell in the Data Table
2. Component iterations are defined for the business process test in Quality Center and are not affected by the Data Table
3. you can insert a DataTable.Export statement to the end of your test or component to export the run-time Data Table to a file.
4. When working with components, the Data Table has only one type of sheet for the component.
5. Whenever you save your test or component, QuickTest automatically saves its Data Table as an .xls file.
6. When working with tests, the Data Table is saved with your test by default. You can save the Data Table in another location thenYou specify a name and location for the Data Table in the Resources tab of the Test Settings dialog box.
7. When working with components, the Data Table is always saved with your component, and cannot be saved in a different location.
8 QuickTest resource files are locked if the file:
is being used by another QuickTest user
has been checked into a Quality Center version control database or some other version control software
has been marked as read-only
9. External files that are associated with your test or component, but cannot be edited within QuickTest
(such as library files and environment variable files) are not affected by this locking mechanism
10. Each row in the table represents the set of values
11. Each column in the table represents the list of values
12. The main limitations for the Data Table are listed below:
Maximum worksheet size—65,536 rows by 256 columns
Column width—0 to 255 characters
Text length—16,383 characters
Formula length—1024 characters
Number precision—15 digits
Largest positive number—9.99999999999999E307
Largest negative number— -9.99999999999999E307
Smallest positive number—1E-307
Smallest negative number— -1E-307
Maximum number of names per workbook—Limited by available memory
Maximum length of name—255
Maximum length of format string—255
13. You can select a .dsn file in the ODBC Select Data Source dialog box
14. Data Table is made up of three types of objects—DataTable, DTSheet (sheet), and DTParameter (column). Each object has several methods and properties that you can use to retrieve or set values
15. Formulas in the Data Table: TEXT and VALUE functions to convert values from one type to another
TEXT(value, format) returns the textual equivalent of a numeric value in the specified format, so that,
for example the formula =TEXT(8.2, "0.00") is "8.20".
VALUE(string) returns the numeric value of a string, so that, for example, =VALUE("$8.20") is 8.20.
16. AddSheet Method: AddSheet method to create the new sheet, "MySheet" in the run-time Data
17. Table and then adds a parameter to the new sheet.
DataTable.AddSheet(SheetName)
Ex: Variable=DataTable.AddSheet ("MySheet").AddParameter("Time", "8:00")
17. DeleteSheet Method: DeleteSheet method to delete the sheet, "MySheet" from the run-time Data Table.
DataTable.DeleteSheet SheetID
Ex; DataTable.DeleteSheet "MySheet"
18. Export Method: Saves a copy of the run-time Data Table in the specified location
DataTable.Export(FileName)
DataTable.Export ("C:\flights.xls") Note:no need to create file flight.xls,its created automativally.
19. ExportSheet Method: Exports a specified sheet of the run-time Data Table to the specified file.
if the specified file does not exist, a new file is created and the specified sheet is saved.
If the current file exists, but the file does not contain a sheet with the specified sheet name,
the sheet is inserted as the last sheet of the file.
If the current file exists and the file contains the specified sheet, the exported sheet overwrites
the existing sheet
DataTable.ExportSheet(FileName, DTSheet)
DataTable.ExportSheet "C:\name.xls" ,1
20. GetCurrentRow Method: Returns the current (active) row in the first sheet in the
run-time Data Table.
DataTable.GetCurrentRow
Ex: row = DataTable.GetCurrentRow
Reporter.ReportEvent 1, "Row Number", row
21. GetRowCount Method: Returns the total number of rows in the longest column in the first sheet
in the run-time Data Table.
Syntax : DataTable.GetRowCount
Ex: rowcount = DataTable.GetSheet("MySheet").GetRowCount
Reporter.ReportEvent 2, "There are " &rowcount, "rows in the data sheet."
22. GetSheet Method: Returns the specified sheet from the run-time Data Table.
Syntax : DataTable.GetSheet(SheetID)
Ex: MyParam=DataTable.GetSheet ("MySheet").AddParameter("Time", "8:00")
23. GetSheetCount Method: Returns the total number of sheets in the run-time Data Table
Syntax : DataTable.GetSheetCount
EX: sheetcount = DataTable.GetSheetCount
msgbox sheetcount
Reporter.ReportEvent 0, "Sheet number", " & sheetcount "
24. GlobalSheet Property: Returns the first sheet in the run-time Data Table
Syntax : DataTable.GlobalSheet
Ex: ParamValue=DataTable.GlobalSheet.AddParameter("Time", "5:45")
25. Import Method: Imports the specified Microsoft Excel file to the run-time Data Table.
Syntax : DataTable.Import(FileName)
Ex: DataTable.Import ("C:\flights.xls")
26. ImportSheet Method: Imports a sheet of a specified file to a specified sheet in the run-time Data Table.
Syntax :DataTable.ImportSheet(FileName, SheetSource, SheetDest)
EX: DataTable.ImportSheet "C:\name.xls" ,1 ,"Global
27. LocalSheet Property :" Returns the current (active) local sheet of the run-time Data Table
Syntax : DataTable.LocalSheet
Ex: MyParam=DataTable.LocalSheet.AddParameter("Time", "5:45")
28. RawValue Property: Retrieves the raw value of the cell in the specified parameter and the current row of the run-time Data Table.
Syntax : DataTable.RawValue ParameterID [, SheetID]
RawValue property to find the formula used in the current row of the Date column in the ActionA sheet in the run-time Data Table.
Ex: FormulaVal=DataTable.RawValue ("Date", "ActionA")
29. SetCurrentRow Method: Sets the specified row as the current (active) row in the run-time Data Table
Syntax : DataTable.SetCurrentRow(RowNumber)
SetCurrentRow method to change the active row to the second row in the global run-time Data Table.
Ex: DataTable.SetCurrentRow (2)
30. SetNextRow Method: Sets the row after the current (active) row as the new current row in the run-time Data Table
Syntax :DataTable.SetNextRow
SetNextRow method to change the active row to the next row in the global run-time Data Table.
Ex: DataTable.SetNextRow
31. SetPrevRow Method: Sets the row above the current (active) row as the new current (active) row in the run-time Data Table.
Syntax : DataTable.SetPrevRow
SetPrevRow method to change the active row to the previous row in the global run-time Data Table.
Ex: DataTable.SetPrevRow
32. Value Property: to set the value in the current row of the Destination parameter (column) in the "ActionA" sheet in the run-time Data Table
DataTable("Destination", dtlocalSheet)="New York" or
DataTable.Value ("Destination", "ActionA")="New York"
33. CDate :function to convert a string to a date
MyShortDate = Cdate(MyDate)
msgbox MyShortDate
34. IsDate :returns True if the expression is a date or can be converted to a valid date; otherwise, it returns False.
MyCheck = IsDate(MyDate) ' Returns True
35. Date Function: Returns the current system date
Dim MyDate
MyDate = Date ' MyDate contains the current system date(10/25/2006)
36 Day Function: Returns a whole number between 1 and 31
Current date: 26(today date)
myday=Day(date)
Msgbox myday
Specified date:19
Myday=day(“October 19, 2006”)
Msgbox myday
Disply:10/26/2006,5:32:20
Myday=now
Msgbox myday
Disply :currentHour (17)
Mytime=Hour(now)
Mytime=Minute(now)
Mytime=Second(now)
Mytime=Time (disply current time 5:39:28)
Msgbox mytime
DateAdd function: mydate=DateAdd(“m” ,1,”10/26/2006”) ans:11/26/2006
mydate=DateAdd(“m” ,2,”10/26/2006”) ans:12/26/2006
mydate=DateAdd(“D” ,2,”10/26/2006”) ans:10/28/2006
mydate=DateAdd(“YYYY” ,2,”10/26/2006”) ans:10/26/2008
mydate=DateAdd(“ww” ,1,”10/26/2006”) ans:11/2/2006
mydate=DateAdd(“w” ,1,”10/26/2006”) ans:10/27/2006
mydate=DateAdd(“h” ,1,”5:07:30”) ans:06:07:30
mydate=DateAdd(“m” ,20,”5:10:20”) ans:5:30:30
mydate=DateAdd(“s” ,10,”5:10:20”) ans:5:10:30
GetObject Function: to access an Automation object from a file and assign the object to an object variable.
GetObject([pathname] [, class])
Dim CADObject
Set CADObject = GetObject("C:\CAD\SCHEMA.CAD")
If pathname is a zero-length string (""), GetObject returns a new object instance of the specified type.
If the pathname argument is omitted, GetObject returns a currently active object of the specified type.
If no object of the specified type exists, an error occurs.
Abs Function: Abs(-1) and Abs(1) both return 1.
Dim MyNumber
MyNumber = Abs(50.3) ' Returns 50.3.
MyNumber = Abs(-50.3) ' Returns 50.3.
if it is an uninitialized variable, zero is returned.
Through Active Screen:standard ,Text and Bitmap check points.
Standard check point:Dialog("Login").WinEdit("Agent Name:").Check CheckPoint("Agent Name:_2")
Bitmap check points.: Dialog("Login").Static("Static").Check CheckPoint("Static")
Text check point:match case,Exact match,ignore spaces and Text not displayed.
Dialog("Login").WinEdit("Agent Name:").Check CheckPoint("FGGGG").
Out check point.: Dialog("Login").WinEdit("Agent Name:").Output CheckPoint("Agent Name:_3")
View/add objects:to add the objects to OR and add properties and view the properties.
CaptureBitmap Method: Saves a screen capture of the object as a .png or .bmp image using the specified file name.
Syntax: object.CaptureBitmap FullFileName
dialog("Login").Static("Static").CaptureBitmap "C:\CAD\SCHEMA.bmp",True
ChildObjects Method (ActiveX): Returns the collection of child objects contained within the object.
Syntax: object.ChildObjects (pDescription)
public Function CheckObjectDesription(parent, descr)
Dim oDesc
' Create description object
Set oDesc = Description.Create()
arProps = Split(descr, ",")
For i = 0 To UBound(arProps)
arProp = Split(arProps(i), ":=")
If UBound(arProp) = 1 Then
PropName = Trim(arProp(0))
PropValue = arProp(1)
oDesc(PropName).Value = PropValue
End If
Next
Get all child objects with the given description
Set children = parent.ChildObjects(oDesc)
If children.Count = 1 Then
CheckObjectDesription = "Object Unique"
ElseIf children.Count = 0 Then
CheckObjectDesription = "Object Not Found"
Else
CheckObjectDesription = "Object Not Unique"
End If
End Function
CheckObjectDesription (Flight Reservation , odesc)
environment variables: you can use one of QuickTest's built-in environment variables to insert current information about the machine running the test or component.
Random number parameters: to check how your application handles small and large ticket orders, you can have QuickTest generate a random number and insert it in a number of tickets edit field.
39 micLeftBtn 0 The left mouse button
micRightBtn 1 The right mouse button
micMiddleBtn 2 The middle mouse button
Double-clicks an ActiveX object : object.DblClick X, Y, [btn] ex:object.Dblclick ,20,20
Drag Method: object.Drag X, Y, [BUTTON Ex:object.Drag, 20,20
40 Drop Method: Performs the 'drop' part of a drag and drop operation.
Syntax: object.Drop X, Y, [BUTTON
Browser("Flight").Page("Flight").AcxButton("Calendar").Drag 10, 20 Browser("Flight").Page("Flight").AcxButton("Calendar").Drop 30, 40
FireEvent Method: Simulates an event on the ActiveX object.
Syntax: object.FireEvent EventName, [Args()]
EX: Browser("Homepage").Page("Welcome").AcxButton("Save").FireEvent "Click"
GetROProperty Method : Returns the current value of the test object property from the object in the application
Syntax: object.GetROProperty (Property, [PropData])
Ex: Set Value = Browser("Flight").Page("Flight").AcxCheckBox("LogicalName").GetROProperty("abs_y")
GetTextLocation Method (ActiveX): Checks whether the specified text string is contained in the specified window area.
object.GetTextLocation (TextToFind, Left, Top, Right, Bottom, [MatchWholeWordOnly])
This method is supported only in Windows 2000 and Windows XP
Ex:result = Window("Date").ActiveX("Calendar").GetTextLocation("2002", l, t, r, b)
41 GetTOProperties Method (ActiveX): Returns the collection of properties and values used to identify the object
Syntax: object.GetTOProperties
Dialog("Login").WinEdit("Agent Name:").Set "dfdfdgfdg"
Dim pro
set pro=Dialog("Login").WinEdit("Agent Name:").GetTOProperties
proCount = pro.Count
msgbox proCount ans:2
For i = 0 To proCount - 1
proName = pro(i).Name
proValue = pro(i).Value
MsgBox proName & " = " &proValue
next
42 GetTOProperty Method (ActiveX): Returns the value of the specified property from the test object description
Syntax: object.GetTOProperty (Property)
Dialog("Login").WinEdit("Agent Name:").Set "dfdfdgfdg"
Dim pro
pro=Dialog("Login").WinEdit("Agent Name:").GetTOProperty("nativeclass")
msgbox pro ans:Edit
GetVisibleText Method (ActiveX): Returns the text from the specified area.
Syntax: object.GetVisibleText ([Left], [Top], [Right], [Bottom])
This method is supported only in Windows 2000 and Windows XP
EX: Dialog("Login").WinEdit("Agent Name:").Set "dfdfdgfdg"
Dialog("Login").WinEdit("Password:").SetSecure "4546e5e21e3df5a6764eee2c38b7cd222d8c8e45"
Dim pro
pro=Dialog("Login").WinEdit("Agent Name:").GetVisibleText
msgbox pro ans: "dfdfdgfdg
pro=Dialog("Login").WinButton("OK").GetVisibleText
msgbox pro ans:OK
Dialog("Login").WinButton("OK").Click
MakeVisible Method (ActiveX): Scrolls an ActiveX object into view if it is not visible in the window.
object.MakeVisible
MouseMove Method (ActiveX): Moves the mouse pointer to the designated position inside the ActiveX object.
object.MouseMove X, Y
Ex: Dialog("Login").WinEdit("Agent Name:").MouseMove 10,10
SetTOProperty Method (Common): Sets the value of the specified property in the test object description.
Syntax: object.SetTOProperty Property, Val
EX: Dialog("Login").WinEdit("Agent Name:").Set "dhhdfhfdvj"
Dialog("Login").WinEdit("Agent Name:").SetTOProperty "length" ,20
Dim pro
set pro=Dialog("Login").WinEdit("Agent Name:").GetTOProperties
proCount = pro.Count
msgbox proCount ans:3
For i = 0 To proCount - 1
proName = pro(i).Name
proValue = pro(i).Value
MsgBox proName & " = " &proValue
next
Set Method (WinEdit): Sets the value of the edit box.
object.Set Text
Type Method (WinObject): Types the specified string in the object
object.Type KeyboardInput(A String value. The text string and/or constants representing non-alphanumeric keys.)
Note: This method is supported for all standard Windows test objects except the WinMenu object.
Note: if you enter a Type statement for an object in which a user cannot enter text, the method has no visual effect.
WaitProperty Method (ActiveX): Waits until the specified object property achieves the specified value or exceeds
the specified timeout before continuing to the next step.
Syntax: object.WaitProperty (PropertyName, PropertyValue, [lTimeOut])
WaitProperty("Enabled", True, 5000) = False Then Reporter.ReportEvent 1, "Calendar", "Object Disabled" Else
Exist Property (ActiveX) : Checks whether the object currently exists in the open application
object.Exist([TimeOut])
Object Property (ActiveX): Accesses the internal methods and properties of the ActiveX object.
Syntax: object.Object
activateCell Method : .Page("FlexGridDemo").AcxTable("MSFlexGrid").ActivateCell 3, 1
ActivateCell method to double click 'the third row and 1st column in the MSFlexGrid table
ActivateColumn Method: Browser("Mercury").Page("FlexGridDemo").AcxTable("MSFlexGrid").ActivateColumn 3
ActivateColumn method to double click 'the third column in the MSFlexGrid table.
ActivateRow Method:: Page("FlexGridDemo").AcxTable("MSFlexGrid").ActivateRow 3
ActivateRow method to double click 'the third row in the MSFlexGrid table.
Add Method (Dictionary: object.Add (key, item)
Function DicDemo
Dim a, d, i, s ' Create some variables.
Set d = CreateObject("Scripting.Dictionary")
d.Add "a", "Athens" ' Add some keys and items.
d.Add "b", "Belgrade"
d.Add "c", "Cairo"
a = d.Items ' Get the items.
itemcont=d.count
msgbox itemcont
for i = 0 To d.Count -1 ' Iterate the array.
s = s & a(i) & "<BR>" ' Create return string.
Next
DicDemo = s
msgbox s
d.Remove("b") ' Remove second pair.
End Function
DicDemo
Dictionary Object: Dictionary object is the equivalent of a PERL associative array. Items can be any form of
data, and are stored in the array. Each item is associated with a unique key.
The key is used to retrieve an individual item and is usually a integer or a string,
but can be anything except an array.
Len Function: Returns the number of characters in a string or the number of bytes required to store a variable
Dim MyString MyString = Len("VBSCRIPT") msgbox Mystring ans:8
SetCaretPos Method (WinEditor): Window("WordPad").WinEditor("RICHEDIT").SetCaretPos 3, 0
This text will be inserted at the beginning of the line 3".
SetSelection Method (WinEditor): object.SetSelection LineFrom, ColFrom, LineTo, ColTo
Window("WordPad").WinEditor("RICHEDIT").SetSelection 3, 0, 4, 16
SetSelection method to select text 'from the beginning of line 3 through column 16 of line four,
Exercise:If u want file created date and time:
Function ShowDateCreated(filespec)
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(filespec)
ShowDateCreated = f.DateCreated
msgbox ShowDateCreated //ans:10/30/2006:2:46:30//
End Function
ShowDateCreated("C:\CAD\SCHEMA.bmp")
Break Point: In order to detect and isolate defects in a test or component, you can use step commands and the
Pause command to control the run session.
You can also do this by setting breakpoints. When the test or component stops at a breakpoint,
you can use the Debug Viewer to check and modify the values of VBScript objects and variables.
Also, if QuickTest displays a run-error message during a run session, you can click the Debug button on the
error message to suspend the test or component and debug it.
Run from Step option: You can run a component from a selected step to the end.
1.: You can run a test from a selected step to the end of the current action, if running from the Expert View,
or to the end of the test, if running from the Keyword View:
2. Using Run from Step: in Expert view ignores any iterations. However, if the action contains nested actions,
QuickTest runs the nested actions for the defined number of iterations.
3. Using Run from Step in keyword view includes all iterations. The first iteration will run from the step
you selected until the end of the test; all other iterations will run from the beginning of the test.
4. If you only want to run one iteration of your test, choose Run one iteration only from the Run tab
in the Test Settings dialog box.
5. If you want to run your test until a specific point within the test , you can insert a breakpoint.
The test will then run from the selected step or action until the breakpoint
6.Note: Make sure that the step you choose is not dependent on previous steps.
7. Results Location tab : specify the location(Folder), in which you want to save the test results.
8.New run results folder—This option displays the default path and folder name in which the test results are saved
• 9 Temporary run results folder—Saves the test run results in a temporary folder. This option overwrites any
• results previously saved in this folder..By default, the results for a QuickTest test are stored in this test folder, and
the results for components are stored in a Quality Center cache folder on your computer.
10. If you are running a test from a Quality Center project, the Project name, Run name, Test set,
and Instance options are displayed instead of the New run results folder option.
TestResult Window:
1. The Test Results window contains a description of the steps performed during the run session.
2. For a component, or for a test that does not contain Data Table parameters, the Test Results window shows a single test iteration.
3. If the test contains Data Table parameters, and the test settings are configured to run multiple iterations, the Test Results window displays details for each iteration of the test run.
4. The Test Results window displays all aspects of the run session:
• a high-level results overview report (pass/fail status)• the data used in all runs• an expandable tree of the steps, specifying exactly where application
failures occurred• the exact locations in the test or component where failures occurred• application snapshots that highlight any discrepancies, for each stage
of the test or component• detailed explanations of each step and checkpoint pass or failure, at
each stage of the test or component
5.The Test Results window contains the following key elements:
• Test results title bar—Displays the name of the test or component.• Menu bar— Displays menus of available commands.• Test results toolbar—Contains buttons for viewing test results (choose View > Test
Results Toolbar to display the toolbar). • For more information, see Test Results Toolbar.• Test results tree— Contains a graphic representation of the test results in the test
results tree. For more information, see Test Results Tree.• Test results details—Contains details of the selected step. For more information, see Test
Results Details.
• Status bar— Displays the status of the currently selected command (choose View > Status Bar to view the status bar).
Test Results Tree:
Right symbol:indicates a step that succeeded. X: indicates a step that failed. Note that this causes all parent steps (up to
the root action or test) to fail as well. !: indicates a warning, meaning that the step did not succeed, but it did not
cause the action or test to fail. ! X: indicates a step that failed unexpectedly, such as when an object is not
found for a checkpoint i: indicates an optional step that failed and therefore was ignored. Note that
this does not cause the test to fail.• Smart Identification Symbol: indicates that the Smart Identification
mechanism successfully found the object. • Recovery symbol: indicates that a recovery scenario was activated• Hand icon: indicates that the run session was stopped before it ended
Reporter.Filter:
• This statement used in expert view ,it can be used to save only steps with Failed or Warning status.
• Reporter.Filter statement determines which steps are saved in the test
To retrieve the mode setting: CurrentMode = Reporter.Filter
To set the mode: Reporter.Filter = NewMode
Reporter.Filter = rfDisableAll or 3
Reporter.Filter = rfEnableAll or 0
TO RETRIEVE ONE COLUMN DATA FROM Excel sheet :-
DataTable.ImportSheet "C:\VMUOct1stweek.xls" ,1 ,"global"
For i= 1 to 10
DataTable.SetCurrentRow(i)
Var=DataTable.RawValue ("C", "Global")
msgbox var
next
note: The column header is the parameter name.
/***********************************************************************************************
Using Excel Object
The following code includes a set of complex and simple functions to serve as examples of the possible uses & work that can be done using Excel Objects
Dim ExcellApp 'As Excel.Application
Dim excelSheet1 'As Excel.worksheet
Dim excelSheet2 'As Excel.worksheet
Set ExcelApp = CreateExcel()
'Create a workbook with two worksheets
ret = RenameWorksheet(ExcelApp, "Book1", "Sheet1", "Example1 Sheet Name")
ret = RenameWorksheet(ExcelApp, "Book1", "Sheet2", "Example2 Sheet Name")
ret = RemoveWorksheet(ExcelApp, "Book1", "Sheet3")
'SaveAs the work book
ret = SaveWorkbook(ExcelApp, "Book1", "D:\Example1.xls")
'Fill worksheets
Set excelSheet1 = GetSheet(ExcelApp, "Example1 Sheet Name")
Set excelSheet2 = GetSheet(ExcelApp, "Example2 Sheet Name")
For column = 1 to 10
For row = 1 to 10
SetCellValue excelSheet1, row, column, row + column
SetCellValue excelSheet2, row, column, row + column
Next
Next
'Compare the two worksheets
ret = CompareSheets(excelSheet1, excelSheet2, 1, 10, 1, 10, False)
If ret Then
MsgBox "The two worksheets are identical"
End If
'Change the values in one sheet
SetCellValue excelSheet1, 1, 1, "Yellow"
SetCellValue excelSheet2, 2, 2, "Hello"
'Compare the worksheets again
ret = CompareSheets(excelSheet1, excelSheet2, 1, 10, 1, 10, True)
If Not ret Then
MsgBox "The two worksheets are not identical"
End If
'save the workbook by index identifier
SaveWorkbook ExcelApp, 1, ""
'Close the Excel application
CloseExcel ExcelApp
' ****************************************** Function Library ***********************************************************
Dim ExcelApp 'As Excel.Application
Dim excelSheet 'As Excel.worksheet
Dim excelBook 'As Excel.workbook
Dim fso 'As Scripting.FileSystemObject
' This function will return a new Excel Object with a default new Workbook
Function CreateExcel() 'As Excel.Application
Dim excelSheet 'As Excel.worksheet
Set ExcelApp = CreateObject("Excel.Application") 'Create a new excel Object
ExcelApp.Workbooks.Add
ExcelApp.Visible = True
Set CreateExcel = ExcelApp
End Function
'This function will close the given Excel Object
'excelApp - an Excel application object to be closed
Sub CloseExcel(ExcelApp)
Set excelSheet = ExcelApp.ActiveSheet
Set excelBook = ExcelApp.ActiveWorkbook
Set fso = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
fso.CreateFolder "C:\Temp"
fso.DeleteFile "C:\Temp\ExcelExamples.xls"
excelBook.SaveAs "C:\Temp\ExcelExamples.xls"
ExcelApp.Quit
Set ExcelApp = Nothing
Set fso = Nothing
Err = 0
On Error GoTo 0
End Sub
'The SaveWorkbook method will save a workbook according to the workbookIdentifier
'The method will overwrite the previously saved file under the given path
'excelApp - a reference to the Excel Application
'workbookIdentifier - The name or number of the requested workbook
'path - the location to which the workbook should be saved
'Return "OK" on success and "Bad Workbook Identifier" on failure
Function SaveWorkbook(ExcelApp, workbookIdentifier, path) 'As String
Dim workbook 'As Excel.workbook
On Error Resume Next
Set workbook = ExcelApp.Workbooks(workbookIdentifier)
On Error GoTo 0
If Not workbook Is Nothing Then
If path = "" Or path = workbook.FullName Or path = workbook.Name Then
workbook.Save
Else
Set fso = CreateObject("Scripting.FileSystemObject")
'if the path has no file extension then add the 'xls' extension
If InStr(path, ".") = 0 Then
path = path & ".xls"
End If
On Error Resume Next
fso.DeleteFile path
Set fso = Nothing
Err = 0
On Error GoTo 0
workbook.SaveAs path
End If
SaveWorkbook = "OK"
Else
SaveWorkbook = "Bad Workbook Identifier"
End If
End Function
'The SetCellValue method sets the given 'value' in the cell which is identified by
'its row column and parent Excel sheet
'excelSheet - the excel sheet that is the parent of the requested cell
'row - the cell's row in the excelSheet
'column - the cell's column in the excelSheet
'value - the value to be set in the cell
Sub SetCellValue(excelSheet, row, column, value)
On Error Resume Next
excelSheet.Cells(row, column) = value
On Error GoTo 0
End Sub
'The GetCellValue returns the cell's value according to its row column and sheet
'excelSheet - the Excel Sheet in which the cell exists
'row - the cell's row
'column - the cell's column
'return 0 if the cell could not be found
Function GetCellValue(excelSheet, row, column)
value = 0
Err = 0
On Error Resume Next
tempValue = excelSheet.Cells(row, column)
If Err = 0 Then
value = tempValue
Err = 0
End If
On Error GoTo 0
GetCellValue = value
End Function
'The GetSheet method returns an Excel Sheet according to the sheetIdentifier
'ExcelApp - the Excel application which is the parent of the requested sheet
'sheetIdentifier - the name or the number of the requested Excel sheet
'return Nothing on failure
Function GetSheet(ExcelApp, sheetIdentifier) 'As Excel.worksheet
On Error Resume Next
Set GetSheet = ExcelApp.Worksheets.Item(sheetIdentifier)
On Error GoTo 0
End Function
'The InsertNewWorksheet method inserts a new worksheet into the active workbook or
'the workbook identified by the workbookIdentifier, the new worksheet will get a default
'name if the sheetName parameter is empty, otherwise the sheet will have the sheetName
'as a name.
'Return - the new sheet as an Object
'ExcelApp - the excel application object into which the new worksheet should be added
'workbookIdentifier - an optional identifier of the worksheet into which the new worksheet should be added
'sheetName - the optional name of the new worksheet.
Function InsertNewWorksheet(ExcelApp, workbookIdentifier, sheetName) 'As Excel.worksheet
Dim workbook 'As Excel.workbook
Dim worksheet 'As Excel.worksheet
'In case that the workbookIdentifier is empty we will work on the active workbook
If workbookIdentifier = "" Then
Set workbook = ExcelApp.ActiveWorkbook
Else
On Error Resume Next
Err = 0
Set workbook = ExcelApp.Workbooks(workbookIdentifier)
If Err <> 0 Then
Set InsertNewWorksheet = Nothing
Err = 0
Exit Function
End If
On Error GoTo 0
End If
sheetCount = workbook.Sheets.Count
workbook.Sheets.Add , sheetCount
Set worksheet = workbook.Sheets(sheetCount + 1)
'In case that the sheetName is not empty set the new sheet's name to sheetName
If sheetName <> "" Then
worksheet.Name = sheetName
End If
Set InsertNewWorksheet = worksheet
End Function
'The RenameWorksheet method renames a worksheet's name
'ExcelApp - the excel application which is the worksheet's parent
'workbookIdentifier - the worksheet's parent workbook identifier
'worksheetIdentifier - the worksheet's identifier
'sheetName - the new name for the worksheet
Function RenameWorksheet(ExcelApp, workbookIdentifier, worksheetIdentifier, sheetName) 'As String
Dim workbook 'As Excel.workbook
Dim worksheet 'As Excel.worksheet
On Error Resume Next
Err = 0
Set workbook = ExcelApp.Workbooks(workbookIdentifier)
If Err <> 0 Then
RenameWorksheet = "Bad Workbook Identifier"
Err = 0
Exit Function
End If
Set worksheet = workbook.Sheets(worksheetIdentifier)
If Err <> 0 Then
RenameWorksheet = "Bad Worksheet Identifier"
Err = 0
Exit Function
End If
worksheet.Name = sheetName
RenameWorksheet = "OK"
End Function
'The RemoveWorksheet method removes a worksheet from a workbook
'ExcelApp - the excel application which is the worksheet's parent
'workbookIdentifier - the worksheet's parent workbook identifier
'worksheetIdentifier - the worksheet's identifier
Function RemoveWorksheet(ExcelApp, workbookIdentifier, worksheetIdentifier) 'As String
Dim workbook 'As Excel.workbook
Dim worksheet 'As Excel.worksheet
On Error Resume Next
Err = 0
Set workbook = ExcelApp.Workbooks(workbookIdentifier)
If Err <> 0 Then
RemoveWorksheet = "Bad Workbook Identifier"
Exit Function
End If
Set worksheet = workbook.Sheets(worksheetIdentifier)
If Err <> 0 Then
RemoveWorksheet = "Bad Worksheet Identifier"
Exit Function
End If
worksheet.Delete
RemoveWorksheet = "OK"
End Function
'The CreateNewWorkbook method creates a new workbook in the excel application
'ExcelApp - the Excel application to which an new Excel workbook will be added
Function CreateNewWorkbook(ExcelApp)
Set NewWorkbook = ExcelApp.Workbooks.Add()
Set CreateNewWorkbook = NewWorkbook
End Function
'The OpenWorkbook method opens a previously saved Excel workbook and adds it to the Application
'excelApp - the Excel Application the workbook will be added to
'path - the path of the workbook that will be opened
'return Nothing on failure
Function OpenWorkbook(ExcelApp, path)
On Error Resume Next
Set NewWorkbook = ExcelApp.Workbooks.Open(path)
Set OpenWorkbook = NewWorkbook
On Error GoTo 0
End Function
'The ActivateWorkbook method sets one of the workbooks in the application as Active workbook
'ExcelApp - the workbook's parent excel Application
'workbookIdentifier - the name or the number of the workbook
Sub ActivateWorkbook(ExcelApp, workbookIdentifier)
On Error Resume Next
ExcelApp.Workbooks(workbookIdentifier).Activate
On Error GoTo 0
End Sub
'The CloseWorkbook method closes an open workbook
'ExcelApp - the parent Excel application of the workbook
'workbookIdentifier - the name or the number of the workbook
Sub CloseWorkbook(ExcelApp, workbookIdentifier)
On Error Resume Next
ExcelApp.Workbooks(workbookIdentifier).Close
On Error GoTo 0
End Sub
'The CompareSheets method compares between two sheets.
'if there is a difference between the two sheets then the value in the second sheet
'will be changed to red and contain the string:
'"Compare conflict - Value was 'Value2', Expected value is 'value2'"
'sheet1, sheet2 - the excel sheets to be compared
'startColumn - the column to start comparing in the two sheets
'numberOfColumns - the number of columns to be compared
'startRow - the row to start comparing in the two sheets
'numberOfRows - the number of rows to be compared
Function CompareSheets(sheet1, sheet2, startColumn, numberOfColumns, startRow, numberOfRows, trimed) 'As Boolean
Dim returnVal 'As Boolean
returnVal = True
'In case that one of the sheets doesn't exists, don't continue the process
If sheet1 Is Nothing Or sheet2 Is Nothing Then
CompareSheets = False
Exit Function
End If
'loop through the table and fill values into the two worksheets
For r = startRow to (startRow + (numberOfRows - 1))
For c = startColumn to (startColumn + (numberOfColumns - 1))
Value1 = sheet1.Cells(r, c)
Value2 = sheet2.Cells(r, c)
'if 'trimed' equals True then used would like to ignore blank spaces
If trimed Then
Value1 = Trim(Value1)
Value2 = Trim(Value2)
End If
'in case that the values of a cell are not equal in the two worksheets
'create an indicator that the values are not equal and set return value
'to False
If Value1 <> Value2 Then
Dim cell 'As Excel.Range
sheet2.Cells(r, c) = "Compare conflict - Value was '" & Value2 & "', Expected value is '" & Value1 & "'."
Set cell = sheet2.Cells(r, c)
cell.Font.Color = vbRed
returnVal = False
End If
Next
Next
CompareSheets = returnVal
End Function
These examples can be found in the UsingExcel.vbs file
Environment Variable:
1.Built-in Variable:
a=Environment.Value("OS")
msgbox a
b=Environment.Value("LocalHostName")
msgbox b
2.UserDEfined Variable:internal
Test-settings-environment-select userdefined-click new -typevariable name and value then click “Apply” and “OK.”
Variable name: h
Value: 45
Script is:
str=environment.Value("h")
msgbox str ans:45
If u want export the internal environment variable:-
just click export button in environment window Then give the file name with .xml extention.
Then open that file,it will be like this.
<Environment>
<Variable> < <Name>h</Name> < <Value>45</Value>
</Variable> </Environment>
This export file can be used as a userdefined external file,like this. Test –settings-environment-select userdefined-click loadfile-select xmlfile-clickopen-apply-
click OK inscriptS write like this: v=Environment.value(“h”) msgbox v ans:45
3:user defined External Environment Variable:- Write function in notepad like this and save with extension .xml.
<Environment> <Variable> <Name>URL</Name> <Value>"C:\Documents and Settings\venkateswararao
acha\Desktop\samples\flight\app\flight4a.exe"</Value> </Variable> </Environment>
After save with extension with .xml.load a file byusing below path.
Test –settings-environment-select userdefined-click loadfile-select xmlfile-clickopen-apply-click OK
Inscript like this: F flightpath=Environment.Value("URL") msgbox flightpath ans: "C:\Documents and Settings\venkateswararao
acha\Desktop\samples\flight\app\flight4a.exe"
If u want open flight login window ,just use this script:- flightpath=Environment.Value("URL") msgbox flightpath SystemUtil.Run(flightpath) LoadFile:-it can be used to load the external environment file
Environment.LoadFromFile("C:\Documents and Settings\venkateswararao acha\Desktop\Url.xml")
Flightpath = Environment.Value("URL")
msgbox flightpath
SystemUtil.Run(flightpath)
To retrieve the path of the external environment loadfile:-
Flightpath = Environment .Value("d")
Msgbox flightpath
Str = Environment .ExternalFileName
msgbox str
To set the value forenvironment variable:_
Environment. Value("MyVariable")=10
MyValue = Environment.Value("MyVariable")
msgbox MyValue
To fill the cells in exel sheet:-have to solve it.
Dim ExcelSheet Set ExcelSheet = CreateObject("Excel.Sheet") ' Make Excel visible through the Application object. ExcelSheet.Application.Visible = True ' Place some text in the first cell of the sheet. ExcelSheet.ActiveSheet.Cells(1,1).Value = "This is column A, row 1" ' Save the sheet. ExcelSheet.SaveAs "C:\DOCS\TEST.XLS" ' Close Excel with the Quit method on the Application object. ExcelSheet.Application.Quit ' Release the object variable. Set ExcelSheet = Nothing *****************************************************#Keyword frame work functions for login screen#********************************************************************************Class WinEditBox Function Settext(Logical,LogicalName,text1) Dialog(Logical).WinEdit(LogicalName).Set text1End FunctionFunction WinButton(Logical,LogicalName) Dialog(Logical).WinButton(LogicalName).ClickEnd FunctionDim Obj_ButtonEnd ClassDim Obj_Win_Edit,Obj_Button Set Obj_Win_Edit= New WinEditBox Set Obj_Button=New WinEditBox
executeFile "C:\Documents and Settings\Satish Tanneru\Desktop\login_editbox.vbs"SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open"
Obj_Win_Edit.Settext "Login","Agent Name:","Satish"Obj_Win_Edit.Settext "Login","Password:","Mercury"Obj_Button.WinButton "Login","OK"
*********************************************************#putting the values in excel sheetcells#*******************************************************Dim ExcelSheetSet ExcelSheet = CreateObject ("Excel.Application")Set ExcelSheet = CreateObject ("Excel.Sheet")ExcelSheet.Application.Visible = TrueFor i=1 to 4 For j=1 to 2 x=i+j ExcelSheet.ActiveSheet.Cells (i,j).Value = x NextNextExcelSheet.SaveAs "C:\test.xls"ExcelSheet.Application.QuitSet ExcelSheet = Nothing
********************************************************#Updating script for retreing values from datatable single column and putting that values in excel sheet single column then that excelsheet save in specified location.#******************************************************* Dim ExcelSheetSet ExcelSheet = CreateObject ("Excel.Application")Set ExcelSheet = CreateObject ("Excel.Sheet")ExcelSheet.Application.Visible = True DataTable.ImportSheet "C:\test1.xls",1,Global c=DataTable.GetRowCount msgbox c For i = 1 to 10 j=1 For k=1 to c DataTable.SetCurrentRow (k) str = DataTable.RawValue ("Customer_Name",Global) ExcelSheet.ActiveSheet.Cells (i,j).Value = str i=i+j Next Next
Updating excelsheet script for retrieving the multiple column values and putting in excelsheet multiple columns.
DataTable.ImportSheet "c:\test1.xls",1,Global c=DataTable.GetRowCount
Function insert (n,colum_name) For i=1 to c
j=n ' For j=1 to 2 x=i+j DataTable.SetCurrentRow(i) str = DataTable.RawValue (colum_name,Global) ExcelSheet.ActiveSheet.Cells (i,j).Value = str 'Next NextEnd Function
Dim ExcelSheetSet ExcelSheet = CreateObject ("Excel.Application")Set ExcelSheet = CreateObject ("Excel.Sheet")ExcelSheet.Application.Visible = Truecall insert (1,"Customer_Name")Call insert (2,"Order_Number")Call insert (3,"Departure_Date")ExcelSheet.SaveAs "C:\test.xls"**************************************************************paste the values in excel sheet below format
Customer name vasuOrder 1 from datatable**********************************************************************************************************
Dim ExcelSheet
Set ExcelSheet = CreateObject ("Excel.Application")Set ExcelSheet = CreateObject ("Excel.Sheet")ExcelSheet.Application.Visible = True
DataTable.ImportSheet "c:\test1.xls",1,Globalc=DataTable.GetRowCountstr=DataTable.RawValue("Customer_Name",Global)str="Customer_Name:"+strstr1=DataTable.RawValue("Order_Number",Global)str3=DataTable.RawValue("Departure_Date",Global)ExcelSheet.ActiveSheet.Cells (1,1).Value = strExcelSheet.ActiveSheet.Cells (2,1).Value = str1ExcelSheet.ActiveSheet.Cells (3,1).Value = str3
ExcelSheet.SaveAs "C:\test.xls"ExcelSheet.Application.QuitSet ExcelSheet = Nothing
Database connection with sql quarries.
Set con=createobject("adodb.connection")con.open "dsn=QT_flight32"if(con.state=1)thenmsgbox "connected"
elsemsgbox "notconnected"end ifSet rs=createobject("adodb.recordset")set rs=con.execute("select Customer_Name from orders where Order_Number=1")wait(05)Set rs=con.execute("select Departure_Date from Orders where Order_Number=5")
************************************************************************Note:1.if u want, u print quaryresult in text file byusing createobject and writeline. 2.navigation for export the database table. Goto datatable-…..rightclick…..sheet….import….fromdatabase…..sql statement manually…enter rows…….create …machine database …select path(ex:flight_32)….writequary…finish then Table displayed in datatable.
//Updated database connection and read and write records in textfile through sql quary,but need update because written multiple records.//
Dim fsoDim con,texSet fso=CreateObject("scripting.FileSystemObject")set tex=fso.OpenTextFile("C:\qua.txt",2,true)Set con=createobject("adodb.connection")con.open "dsn=QT_flight32"if(con.state=1)then'msgbox "connected"else'msgbox "notconnected"end ifSet rs=createobject("adodb.recordset")set rs=con.execute("select Customer_Name from orders where Order_Number<10 ")'Set rs=con.execute("select departure_time from orders where order_number=5")For each x in rs.fields
str1=x.name'msgbox str1str2=x.value'msgbox str2
tex.WriteLine (str1) tex.WriteLine (str2)Next
Note: for Export the database tables from database. Navigation:Gotodatatable….sheet….Export…give filename….save.then its saved automatically.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Actions vs Functions in QTP 9.0 April 3, 2006
When deciding whether a piece of code should go in a reusable action or a function, we usually favored functions in QTP 8.2. When Mercury introduced QuickTest 9, they made the argument for
functions even more compelling with the Multi Document Interface. Now we can open as many function libraries as we want, but we are still limited to one test. So, if you want to edit a reusable action in another test, you have to close your current test, open the second test, make your changes, save and close the second test then reopen your original test.
Passing Data
Actions - can only accept primative data types as parameters (strings, integers, etc)
Functions - can accept arrays, dictionary objects and test objects (i.e. Pages, Frames, WebRadioGroups, etc.)
Resource Usage
Actions - For each action, there’s a folder, three separate vbs files, a local Object Repository, a subfolder containing snapshots, an Excel spreadsheet, and a few seconds of load time.
Functions - There’s the code contained in the Function, and that’s all
API
Actions - You cannot insert calls to Existing Actions through the QTP API, you can only do it through the interface
Functions - You can attach Function Libraries to Test Scripts through the QTP API
Return Values
Actions - Return values are difficult to understand and read in the syntax
Functions - Return values work like they do in other languages (i.e. as lvalues)
* Test Object Model Concept **************************************************
The test object model is a large set of object types or classes that QuickTest uses to represent the objects in your application. Each test object class has a list of properties that can uniquely identify objects of that class and a set of relevant methods that QuickTest can record for it.
ExitRun Statement:
************************
ExitRun(0)
exits the test and returns the value 0.
Input parameter:process.
Step – action properties -parameters then 1.enter parametername like str1:2.select string:3.enter value-ok
In script like this: Dialog("Login").WinEdit("Agent Name:").Set parameter("str1")
WEB METHODS:1.Sync Method (Page): Waits for the browser to complete the current navigationobject.SyncBrowser("MSN.com").Page("MSN.com").SyncBrowser-total pagePage-below dropdown of httpswebsitebox.
2.Navigate Method: Opens a specified URL in the browserobject.Navigate LocationBrowser("MSN.com").Navigate https://kproxy.com/
3.Dialog method: dialog box window in main window.
4.frame object:An Html frame Frame identification properties:abs_x,: absolute coordinate left abs_y:absolute coordinate top, HTml id: The object's HTML identifier Html tag:objects html tag. Index: to indicate the order in which the object appears in the code relative to other objects Locaton: to indicate where the object appears within the window. Text:text associated with the object. 4.Debug Viewer Pane: The Debug Viewer pane contains three tabs to assist you in debugging your test.
Watch Expressions :The Watch Expressions tab enables you to view the current value of any variable or other VBScript expression.
Variables :The Variables tab enables you to view the current value of all variables that have been recognized up to the last step performed in the run session.
Command :The Command tab enables you to execute a line of script in order to set or modify the current value of a variable
5. IF condition
If Mem_Type="paid" Then
RunAction "Paid_Mem", oneIteration
ElseIf Mem_Type = "free" Then
RunAction "Free_Mem", oneIteration
Else
RunAction "Preferred", oneIteration
End If
6. Shortcut Keys
New Test CTRL+N Creates a new test
Open Test CTRL+O Opens an existing test.
Business Component > New
CTRL+SHIFT+N Creates a new component.
Business Component > Open
CTRL+SHIFT+O Opens an existing component.
Business Component > Edit Template
CTRL+SHIFT+E Opens the component template of the current Quality Center project for editing.
Save CTRL+S Saves the active test or component.
Export to Zip File CTRL+ALT+S Creates a zip file of the active test or component.
Import from Zip File CTRL+ALT+O Imports a test or component from a zip file.
Print CTRL+P Prints the active test or component
Command Shortcut Key Function
Cut CTRL+X Removes the selection from your test or component (Expert View only).
Copy CTRL+C Copies the selection from your test or component.
Paste CTRL+V Pastes the selection to your test or component.
Delete DEL Deletes the selection from your test or component.
Undo CTRL+Z Reverses the last command or deletes the last entry you typed (Expert View only).
Redo CTRL+Y Reverses the action of the Undo command (Expert View only).
Rename Action
F2 Changes the name of an action.
Find CTRL+F Searches for a specified string (Expert View only).
Replace CTRL+H Searches and replaces a specified string (Expert View only).
Go To CTRL+G Moves the cursor to a particular line in the test or component (Expert View only).
Bookmarks CTRL+B Creates bookmarks in your script for easy navigation (Expert View only).
Complete Word CTRL+SPACE Completes the word when you type the beginning of a VBScript method or object (Expert View only).
Argument Info CTRL+SHIFT+SPACE Displays the syntax of a method (Expert View only).
Apply "With" to Script
CTRL+W Generates With statements for the action displayed in the Expert View (Expert View only).
Remove "With" Statements
CTRL+SHIFT+W Converts any With statements in the action displayed in the Expert View to regular (single-line) VBScript statements (Expert View only).
Checkpoint > Standard Checkpoint
F12 Creates a standard checkpoint for an object or a table.
Output Value > Standard Output Value
CTRL+F12 Creates a standard output value for an object or a table.
Step > Step Generator
F7 Opens the Step Generator.
New Step F8 Inserts a new step in the Keyword View (Keyword View only).
New Step After Block
Shift+F8 Inserts a new step after a conditional or loop block in the Keyword View (Keyword View only).
Record F3 Starts a recording session.
Run F5 Starts a run session from the beginning or from the line at which the session was paused.
Stop F4 Stops the recording or run session.
Analog Recording Ctrl+Shift+F4 Starts/ends analog recording mode.
Low Level Recording Ctrl+Shift+F3 Starts/ends low level recording mode
Pause Pause Stops the run session after the statement has been executed. The run session can be resumed from this point.
Step Into F11 Runs only the current line of the script. If the current line calls a method, the method is displayed in the view but is
not performed.
Step Over F10 Runs only the current line of the script. When the current line calls a method, the method is performed in its entirety, but is not displayed in the view.
Step Out Shift+F11 Runs to the end of the method then pauses the run session. (Available only after running a method using Step Into.)
Insert/Remove Breakpoint
F9 Sets or clears a breakpoint in the test or component.
Clear All Breakpoints Ctrl+Shift+F9 Deletes all breakpoints in the test or component.
Edit > Cut Ctrl+X Cuts the table selection and puts it on the Clipboard.
Edit > Copy Ctrl+C Copies the table selection and puts it on the Clipboard.
Edit > Paste Ctrl+V Pastes the contents of the Clipboard to the current table selection.
Edit > Clear > Contents
Ctrl+Del Clears the contents from the current selection.
Edit > Insert Ctrl+I Inserts empty cells at the location of the current selection. Cells adjacent to the insertion are shifted to make room for the new cells.
Edit > Delete Ctrl+K Deletes the current selection. Cells adjacent to the deleted cells are shifted to fill the space left by the vacated cells.
Edit > Fill Right Ctrl+R Copies data in the left-most cell of the selected range to all cells to the right of it, within the selected range.
Edit > Fill Down Ctrl+D Copies data in the top cell of the selected range to all cells below it within the selected range.
Edit > Find Ctrl+F Finds a cell containing specified text. You can search the table by row or column and specify to match case or find entire cells only.
Edit > Replace Ctrl+H
Finds a cell containing specified text and replaces it with different text. You can search the table by row or column and specify to match case and/or to find entire cells only. You can also replace all.
Data > Recalc F9 Recalculates the selected data in the Data Table.
Insert Multi-line value
Ctrl+F2 while editing a cell
Opens the Cell Text dialog box for multi-line value editing.
Activate next/previous data
Ctrl+Page Up / Ctrl+Page Down
Activates the next or previous sheet (global or action) in the Data Table.