QTP or UFT and Vbscript: Technical Interview Questions (Latest UFT Interview Questions) set 1
August 13, 2018
Latest QTP Technical Interview Questions and Answers (Latest UFT Interview Questions)-Set 1
Welcome to this post! -“Latest QTP Interview Questions and Answers (Latest UFT Interview Questions)-set 1”
If you are looking for latest HP UFT \ QTP interview Questions, then you are at right place. This post consists of some exhaustive questions which had been part of interviews. Usually these are assumed to be known after having some years of experience in using the UFT or QTP, Go ahead and enjoy reading…
Below post discusses about some important questions and answers on HPE UFT (Micro Focus) QTP/UFT interview.
1. Reverse the string without using any vbscript string functions?
Let us discuss the solution here:
Line 1,2 – create local variables for both input and output string,
Line 3 – use “inputbox” method to receive the input from msgbox and store it in the input string variable, “inpStr”,
Line 4 – use the “Len” method to get the length of string,
Line 5,6,7, – use “mid” method to get the single character at a time, and store plus add that into a variable of output “outStr”. Finally print the appended string using msgbox method.
Dim inpStr Dim outStr inpStr= inputbox(“Enter the desired string”) count= Len(inpStr) For i = 1 to count outStr= mid(inpStr,i,1)&outStr Next msgbox outStr
Below are the execution screens:
2. Close all opened browsers?
Let us discuss the solution here:
Step 1 – create the object of Description
Step 2 – set the description object “desc” with property value pair as ‘micclass’,’Browser’
Step 3 – now count the number of desktop child objects using the method Desktop.ChildObjects. This will return the child objects of type “desc” i.e. browser objects.
Step 4,5,6, – Use internal property of browser “creationtime” and close one by one in a loop.
Set desc = Description.Create desc( “micclass” ).Value = “Browser” If Desktop.ChildObjects(desc).Count > 0 Then For x = 0 To Desktop.ChildObjects(desc).Count – 1 Browser( “creationtime:=” & x ).Close Next End If
3. Regular Expression Example
Let us discuss the solution here:
Step 1 – create the object of regular expression.
Step 2,3 – set the regex object with properties value as true for ignorecase and global resp.
Step 4,5 – now set the pattern you are looking for in the given string.
Step 6, – Use regex.Execute method to get matches collection object.
Step 7 – iterate through each of the values in matches collection and output it using msgbox.
Set regex= New RegExp regex.IgnoreCase=true regex.global=true regex.Pattern=”[0-9]*a” testStr= “1a12ijk332a444lmo5895abc” Set totMatches= regex.Execute(testStr) msgbox totMatches.count For each match in totMatches msgbox match.Value Next
Below are the execution screens:
Continue Reading to UFT Technical\General interview questions set 2:
If you would like to keep track of further articles on UFT (QTP). I recommend you to subscribe by Email and have new UFT articles sent directly to your inbox.