You are on page 1of 6

QTP Questions

VB Script Syntax (50 Examples)


1 Print Hello World
2 Find whether given number is a odd number
3 Print odd numbers between given range of numbers
4 Find the factorial of a given number
5 Find the factors of a given number
6 Print prime numbers between given range of numbers
7 Swap 2 numbers with out a temporary variable
8 Write a program to Perform specified Arithmetic Operation on two given numbers
9 Find the length of a given string
10 Reverse given string
*11 Find how many alpha characters present in a string.
12 Find occurrences of a specific character in a string
13 Replace space with tab in between the words of a string.
14 Write a program to return ASCII value of a given character
A: ASC(Char)
***15 Write a program to return character corresponding to the given ASCII value
************************
16 Convert string to Upper Case
17 Convert string to lower case
18 Write a program to Replace a word in a string with another word
19 Check whether the string is a POLYNDROM
20 Verify whether given two strings are equal
21 Print all values from an Array
22 Sort Array elements
23 Add two 3X3 matrices
24 Multiply Two Matrices of size 2X2
25 Convert a String in to an array
26 Convert a String in to an array using I as delimiter
27 Find number of words in string
28 Write a program to reverse the words of a given string.

29 Print the data as a Pascal triangle


30 Join elements of an array as a string
31 Trim a given string from both sides
32 Write a program to insert 100values and to delete 50 values from an array
33 Write a program to force the declaration of variables
34 Write a program to raise an error and print the error number.
35 Finding whether a variable is an Array
36 Write a program to Convert value into a currency
37 Write a program to Convert an expression to a date
38 Display current date and Time
39 Find difference between two dates.
40 Add time interval to a date
41 Print current day of the week
42 Convert Date from Indian Format to US format
43 Find whether current month is a long month
44 Find whether given year is a leap year
45 Format Number to specified decimal places
46 Write a program to Generate a Random Number
47 Write a program to show difference between Fix and Int
48 Write a program to find subtype of a variable
49 Write a program to print the decimal part of a given number
50
51
52
53
54

Write
Write
Write
Write
Write

a
a
a
a
a

Function to return a random number


Function to add and multiply two numbers
Sub Procedure to print Hello World
Sub Procedure to add and multiply two numbers
program to list the Timezone offset from GMT

VB Script Advanced Programming (100 Examples)


1 Write a program to read data from a text file
2 Write a program to write data into a text file
3 Write a program to print all lines that contains a word either infics or solution
s
4 Write a program to print the current foldername
5 Write a program to print files in a given folder
6 Write a program to print subfolders in a given folder
7 Write a program to print all drives in the file system
8 Write a program to print current drive name
9 Print the last modified and creation date of a given file

10 Print the size of the file and size on the disk.


11 Write a program to display files of a specific type
12 Write a program to print the free space in a given drive
13 Write a program to display all subfolders in a given folder
14 Write a program to find whether a given folder is a special folder
15 Write a program to remove all empty files in the folder
16 Write a program to Copy contents of one folder to other folder
17 Write a program to check whether a given path represents a file or a folder
18 Write a program to compress a folder
19 Write a program to rename a folder
20 Write program to display all folders created on a specific date
21 Write a Program to enable disk quotas
22 Write a program to create, modify and delete disk quota
23 Write a program to display all files containing demo in their name
24 Write a program to print all lines in a file that ends with world
25 Write a program to check whether string starts with Error
26 Write a program to Replace all words that contains demo in a file with the word
infics
27 Write a program to check whether a string contains only alpha numerics
28 Write a program to check whether a string is in email format
29 Write a program to check whether given string is in date format
30 Write a program to print all the lines ending with $
31 Check whether middle three characters in a word contains alphanumeric
32 Check whether a given line is an empty
33 Write a program to Add elements to a dictionary
34 Write a program to display items in a dictionary
35 Write a program to check whether specified Key exists in a Dictionary
36 Write a program to Store dictionary items in an array
37 Write a program to delete Key Value pair in the dictionary
38 Write a program to monitor operating system performance
39 Write a program to monitor operating system objects
40 Write a program to monitor web server performance
41 Write a program to monitor browser service performance
42 Write a program to list the PID and PPID of a process
43 Write a program to create a registry key
44 Write a program to list registry files
45 Write a program to list registry value and types
46 Write a program to delete registry key
47 Write a program to Stop and Start alerter service
48 Write a program to list services running and their statuses.
49 Write a program to list services that can be stopped
50 Write a program to start auto start services that have stopped
51 Write a program to Invoke command prompt and execute dir command from the she
ll
52 Write a program to schedule a task
53 Write a program to list and delete scheduled tasks
54 Write a program to add a local user account
55 Write a program to disable and delete a local user account
56 Write a program to list all user accounts in the local computer
57 Write a program to display logged in user name
58 Write a program to list cache memory information
59 Write a program to list physical memory properties
60 Write a program to list memory devices
*****************************************************
61 Write a program to find Hard Disk size
62 Write a program to find RAM size
63 Write a program to restart a computer
64 Write a program to shutdown a computer
65 Write a program to Execute Perl script from VB Script
66 Find the systems present in the LAN

67 Write a program to Print using remote printer


68 Verify whether IE enhanced security is enabled for logged on user
69 Write a program to add a website to a favourite menu
70 Write a program to list IE LAN settings
71 Write a program to list cache, connection and security zone settings
72 Find the arguments passed to a Windows Script Host
73 Write a program to Map a network drive
74 Write a program to Print to the local printer
75 Write a program to Print to remote printer
76 Write a program to Print Computer name
77 Write a program to Print free memory in the drive
78 Write a program to Print memory and CPU utilized by a process
79 Write a program to Find the ipaddress of a local system
80 Write a program to find Network Drives
81 Write a program to find the Full path name of a shortcut
82 Write a program to Retrieve all the rows in a table
83 Write a program to find the name of columns in a table
84 Write a program to find number of rows in each column
85 Write a program to connect and print data from oracle database
86 Write a program to connect and print data from SQL Server database
87 Write a program to retrieve specific field from the database table
88 Write a program to check whether a column in the database is in ascending ord
er
89 Write a program to insert a new row into the database table
90 Write a program to open the two record sets
91 Write a program to Update the specific field in the database table
92 Write a program to delete all records whose username starts with demo
93 Write a program to sort the record set
94 Write a program to find number of rows in a table
95 Write a program to Write simple text to windows word
96 Write a program to Write table to windows word
97 Write a program to apply style to a table in word document
98 Write a program to open and print a word document
99 Write a program to send an email using outlook
100 Write a program to print data present in all sheets of an excel files

QTP Scripting (100 Examples)


1 Write a program to enter data in login screen
2 Write a program to find the x and y coordinates of a button
3 Write a program to Read items in a list box
4 Write a program to Read items on a desktop
5 Write a program to Capture Desktop Screen shot
6 Write a program to Read tab names from a tabbed window
7 Write a program to Check whether scrollbars exists inside a editor
8 Write a program to check whether edit box is enabled or writable
9 Write a program to Check scroll bars in a web page
10 Write a program to Check whether dialog is middle of the window
11 Write a program to Check whether Window is middle of the screen
12 Write a program to Check whether country contains all the states
13 Write a program to Check whether edit box is focused
14 Write a program to Check default selection in a list box
15 Write a program to Capture webbutton image

16 Write
17 Write
18 Write
19 Write
20 Write
21 Write
22 Write
23 Write
24 Write
25 Write
26 Write
27 Write
28 Write
29 Write
30 Write
file
31 Write
32 Write
33 Write
35 Write
36 Write
37 Write
38 Write
39 Write
40 Write
41 Write
ions
42 Write
43 Write
44 Write
45 Write
46 Write
47 Write
48 Write
49 Write
50 Write
51 Write
52 Write
53 Write
54 Write
55 Write
56 Write
57 Write
58 Write
59 Write
60 Write
61 Write
62 Write
63 Write
64 Write
65 Write
66 Write
67 Write
68 Write
69 Write
70 Write
71 Write
72 Write
73 Write
74 Write

a
a
a
a
a
a
a
a
a
a
a
a
a
a
a

program
program
program
program
program
program
program
program
program
program
program
program
program
program
program

to
to
to
to
to
to
to
to
to
to
to
to
to
to
to

List all links in the web page


Check whether given link exists
Find image width and Height
Print URL displayed in the address bar
Check whether webpage downloaded completely
Refresh a web page
Verify page title is displayed correctly
Verify whether page contains frames
Find page load time
Check given text is displayed on the web page
Find whether image contains tool tip
Invoke the Browser with specified URL
Import an excel file to a Data table
Read data from first parameter of Global sheet
Read data from all sheets and all parameters of the excel

a
a
a
a
a
a
a
a
a
a

program
program
program
program
program
program
program
program
program
program

to
to
to
to
to
to
to
to
to
to

place data in a specific sheet in the excel file


Import data to data table from a database
Read and display data from CSV file
Find number of rows and columns in a web table
Display entire data in the web table
Display all images in the webpage
Check whether table contains headers
Find the background colour of a webobject
Print results in a HTML format
Select different radio buttons for different script iterat

a program to Find the dialog Height whose window name is Appointments


a program to Read all the items from a services window
a program to Find screen resolution
function to compare two bitmaps
a program to Add and Remove Repositories to the action
a program to Load Library files
a program to Enable and Disable Recovery scenarios programmatically
a program to Report Results status to Results file
a program to Find the active window name
a program to List out the windows that are open
a program to Call reusable actions from different script
your own standard checkpoint
your own synchronization function
a program to Check whether there is a memory leak in the process
a program to Close all the dialogs open in a window
a program to Read menu names
a program to Read menu items
a program to Check whether a check button is selected or not
a program to Check whether we can select multiple items in the listbox
a program to Check whether edit box allows exactly 15 characters
a program to Check whether items in the page are aligned properly
a program to Check whether data in the webtable is left aligned
a program to Find which add-ins are loaded.
a program to Find available add-ins in the tool
a program to Change window title
a program to Find whether specified window is there on the desktop
a program to Check whether a window is in minimized or maximized
a program to Check window is resizable
a program to Check whether logo displayed is correct?
a program to Read all items in a tree
a program to Read all elements in the XML file
a program to Read attributes of a particular element in the XML file
a program to Modify attribute value

75 Write a program to Add one more elements to XML file


76 Write a program to Display complete contents of an XML file
77 Write a program to Find font type.
78 Write a program to Find Font size
79 Write a program to Check whether text is bold and underlined
80 Write a program to Find the memory utilized by a process
81 Write a program to Verify flash image
82 Write a program to Check pointed link is having different back ground colour?
83 Write a program to Check Marquee
84 Write a program to Check whether selected tab is having different appearance?
85 Write a program to Check whether a link contains image to its left side.
86 Write a program to Check whether stock prices are updating an hourly basis
87 Write a program to Retrieve Action Parameters
88 Write a program to Disable active screen programmatically
89 Write a program to Modify Mandatory and Assistive properties programmatically
90 Write a program to Configure Run options programmatically
91 Write a program to Define test results location through program
92 Write a program to Disable Run settings
93 Write a program to Read and Update data from user defined environmental varia
ble
94 Write a program to Configure maximum timeout value for web page to load
95 Write a program to read and delete cookies
96 Write a program to Verify whether status indicator is moving as the movie is
playing
97 Write a program to Clear the cache in the webpage
98 Write a program to Check whether webpage is loaded from server or from cache
99 Write a program to Configure web options programmatically
100 Write a program to Instruct Quicktest to Capture Movie Segments of Each Erro
r and Warning
101 Write a program to Check whether new items can be added to a listbox
102 Write a program to Check whether link s pointing to correct URL
103 Write a program to invoke the application
104 Write a program to Read parameters in the data table
105 Write a program to List out the windows that are minimized
106 Write a program to add environmental variables during run time
107 Write a program to check whether tab order is left to right and top to botto
m
108 Write a program to find the maximum text length that can be entered in a edi
t box
109 Write a program to verify min and max length constraints of text in an edit
box
110 Write a program to find the kind of data edit box accepts
111 Write a program to add objects to object repository file
112 Write a program to export object repository file to XML
113 Write a program to check whether a column in the database table is a primary
key