Example of SendKeys in UFT


Scenario1:
User wants to click Right Arrow to access particular tab in Microsoft Excel?

Code:
Set objClick = CreateObject(“WScript.Shell”)

objClick.SendKeys “{RIGHT}”

Set objClick = Nothing




Scenario2:-

How to launch Task Manager in windows?

Note:-Shortcut for Windows Key in Windows 7/8 is “CTRL+SHIFT+ESC”.



Code:

Launch Task manager using Sendkeys
Launch Task Manager in windows

What is SendKeys?
Keystrokes in SendKeys?

Manual testing v/s Automation component testing

I came across a video on Testing Maturity Model in  “Tip of the Week” program by HP’s engineers and product experts.


 This video features Andrew Flick, Senior Product Manager at HP Software. Andrew talks about saving execution time , framework and test maintenance costs while increasing test coverage.



Hope we as UFT automation lovers will learn from this


















 Test Maturity Model

SendKeys Keystrokes

Key
Keystroke
Alt
{ALT},%
Backspace
{BACKSPACE}, {BKSP} or {BS}
Delete
{DELETE}
Down Arrow
{DOWN}
End
{END}
Enter
{ENTER} or ~
Escape
{ESCAPE}
F1, F2……F15, F16 
{F1},{F2}…..{F15}, {F16}
Page Down
{PGDN}
Space     
{SPACE}
Tab
{TAB}
Up Arrow
{UP}
Caps Lock
{CAPSLOCK}
Break
{BREAK}
Ctrl
^
Shift 
+
+
{+}
Page Up
{PGUP}
Print Screen
{PRTSC}


Usage Example

Sending Keyboard strokes in UFT 11.5

Scenario:-
How we can perform events like Click down Arrow  Enter, Tab Using UFT?

Approach:-
We need to use “SendKeys” method of “Wscript

Definition:-
Sendkeys, is used to send one or more keystrokes to the active window as if they were typed at the keyboard

Syntax:-
Object.Sendkeys Keystrokes

Example:-
How to activate windows Key /Startup Program?

Note:-Shortcut for Windows Key in Windows 7 is “CTRL+ESC“.

Code:-

Launch Start manager


Keys and Keystrokes in sendkeys method?
Examples in UFT
Selenium Example of Sendkeys



Examples of Vbscript

Basic Examples:- 

Scenario 1:– 
To get Output message “Welcome to Vbscript” 

Steps:- 

  • Open any editor(Say Notepad) 
  • Type the code MsgBox(“Welcome to Vbscript”
  • Save file with extension .VBS with Save as Type: All files 
  • Double click the Icon of newly created file.

Output:-


Vbscript Icon UFT
vbscript icon(Double click to run the script)



Vbscript Example Message
Output Message













Note:- Follow the above Steps to create new VBS file each time for new example.

Scenario 2:-
Checking Current Hour of the day. 

Concept:– 
Understand if-Else code 

Code:-

'Taking the Current Hour
Dim iHour
iHour = Hour(time)
'Incase time is less than 12
If iHour < 12 Then
msgbox "Good Morning!! Dude"
else
msgbox "Good Afternoon!! Dude"
End If

Scenario 3:
Taking the specified part form the given string.

Concept:-
Used Mid Function

Syntax of Mid:-
Mid(InputString,Start position,Length(optional))

Code:-

Mid function in UFT
Mid function 

Scenario 4:-
Running the Loop from 1 to 10 in reverse order

Concept:-
Looping using For-Next

Syntax of For-Next loop:-
For Iterator = 1 To 1 Step 1

Next

Code:-

For-Next loop

More Advance Examples
DataTypes in VbScript

Some Key Concepts in VbScript

Meaning of VBScript


What is VBScript?

·    VBScript is a scripting language.(Other example JavaScript)

·    Being a scripting language code of Vbscript  is interpreted (lightweight programming language)

·    VBScript is a subset of  Microsoft’s programming language Visual Basic

·   While it doesn’t offer the same functionality of Visual Basic, it does provide a powerful tool that can be used to add interaction to web pages.

·   It uses the Component Object Model like ADO(ActiveX) object to work with databases or File SystemObject(FSO) to work with files)

Learning VBScript





Helping points?


·    Firstly introduced in as part of the Microsoft Windows Script Technologies, launched in 1996.

·    VBScript has been installed by default in every desktop release of MicrosoftWindows since Window98

·   It is used to write executable functions that can be part of HTML and THUS  interact with the DocumentObject Model (DOM) of the page, to perform tasks not possible in HTML alone.

·    When VBScript is run on the client side, the user’s browser needs to support VBScript. When run on the server side, the server needs to support it

Examples

Photo courtesy 

QTP-11 (HP0-M47) Certification Questions(Part-1)

Following are list of some important questions that I thought of sharing with QTP lovers. Request you all experienced certified professionals to share your knowledge and questions for aspirants preparing for certification.
1.   What is the use of Data table in custom checkpoint?
a.   To fetch data from external data source
b.   As input value to script
c.   To compare values
d.   For storing Output values and Formulas

2.   QTP-11 gives feature to record steps from which browser?
a.   Chrome
b.   IE
c.   Firefox
d.   Safari

3.   Why we use Virtual Object?
a.   To point to an object name that might be located in any object repository
b.   To map an area of your application to a standard class
c.    To utilize an object without pre-defining the object type
d.   To point to an object that will be defined later, possibly by another tester

4.   Conflicts resolved by object repository merge tool?
a.   Same object different parent, similar description
b.   Same name extra properties, different name same properties
c.   Same name different description, similar description
d.    Same name different parent, same parent different name
5.   Easiest approach to bundle QTP whole code to be taken from one source to another?
a.   Using the Export to Zip feature
b.   Using Save Test with Resources feature.
c.   Using Save as option
d.   Using Save feature to save all the resources individually

Answers(Part-1)

Exam Syllabus- QTP

Syllabus Topics & Weight age:-
The following testing objectives represent the specific areas of content covered in the exam. Use this outline to guide your study and to check your readiness for the exam. The exam measures your understanding of these areas. 
WeightAge                                 Topics
10% Automated test planning
 • Plan for general testing and automation.
 • Plan for QTP testing.
 • Identify and describe features and settings.
 • Explain QTP licensing and packaging.
19% Basic test creation and how QTP works with objects
 • Create the basic test.
 • Explain how QTP works with objects.
 • Add steps without recording.
 • Explain the purpose and operation of Smart Identification feature.
24% Basic test verification and enhancement
 • Add standard and custom verification points.
 • Enhance tests with parameters.
 • Add custom checkpoints. 
 • Add database checkpoints.
 • Add bitmap checkpoints. 
 • View test results.
11% Modular automated test builds
 • Explain how to build modular QTP tests with Actions.
 • I Use a Shared Object Repository.
7% QTP and ALM integration
 • Explain the QTP/ALM connection.
 • Define ALM management of QTP resources.
 • Explain versioning features in QTP
10% Automated test troubleshooting 
 • Troubleshoot Object Recognition problems. 
 • Use Recovery scenarios.
 • Use the Debugging Tool. 
 • Measure System Performance. 
 • Configure log tracking.
4% Advanced QTP Scripting 

• Import and export Excel sheets.
• Get and set object properties.
• Identify descriptive programming to bypass repository.
7% Expert View Describe
 • Expert View features.
 • Describe dynamic object programming.
 • Identify and describe VBScript elements.
8% Web applications
 • Recognize Web Add-in Extensibility.
 • Describe Web event recording use and configuration.
 • Identify new web testing capabilities

Reference:-HP ExpertOne

Exam details QTP-11 Certification


Exam details:-

 Questions?

 Number of Questions: 72

Question Types?

Multiple choice, drag-and-drop, and point and click

Exam Duration?

Exam time: 105 minutes

Passing Cutoff?
 75%

Exam fee?

$100

Exam centre?

Pearson

Some Important Points:-

·        Test will be On-line
·        No on-line or hard copy reference material will be allowed at the testing site.
·        It will be held at Pearson VUE centre.
·        Exam can be video recorded 
·        Person has to submit all his belongings at the exam centre 
·        Plastic board and marker will be given at the centre
·        Closed circuit cameras will be placed to monitor the examiner
·        Paper will be divided into sections.
·        Questions of each section needs to be submitted before starting new section
·        Generally there will be 10-12 sections in a exam
·        Each section can have questions varying from 2 to 10
·        In particular section person can Flag the (doubtful) questions
·        Inside individual section person can move forward and backward to re-answer the questions.
·        Minutes timer on computer screen will be there to track the time left(So no need to have Your own watch)