Find Interview Questions for Top Companies
Ques:- how to retrive the tooltip by using descriptive programming in qtp?
Asked In :-
Right Answer:
To retrieve the tooltip using descriptive programming in QTP (QuickTest Professional), you can use the following code snippet:

```vbscript
Set obj = Browser("browser_name").Page("page_name").WebElement("html tag:=*","title:=*")
tooltipText = obj.GetROProperty("title")
MsgBox tooltipText
```

Replace `"browser_name"` and `"page_name"` with the actual names of your browser and page. This code accesses the `title` property of the web element, which typically contains the tooltip text.
Comments
Admin May 17, 2020

Use the "title" property to get the tool tip of any button, hyperlink etc.

Admin May 17, 2020

Browser("micclass:=Browser").Page("micclass:=Page")or
Browser("name:=Browser").Page("title:=Page")

Ques:- how to declare a variable in vbscript using vbscript
Asked In :-
Right Answer:
To declare a variable in VBScript, use the `Dim` statement. For example:

```vbscript
Dim myVariable
```
Comments
Admin May 17, 2020

Dim

Admin May 17, 2020

Dim file1 as string

Ques:- Description.Create
Asked In :-
Right Answer:
In VBScript, you can create an object using the `CreateObject` function. For example:

```vbscript
Set obj = CreateObject("Scripting.FileSystemObject")
```
Ques:- hi, How will write a regular expression of date in VB scripting.
Asked In :-
Right Answer:
To write a regular expression for a date in VBScript, you can use the following pattern:

```vbscript
Dim regex
Set regex = New RegExp
regex.Pattern = "^(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[0-2])/(19|20)d{2}$"
regex.IgnoreCase = True
regex.Global = True
```

This pattern matches dates in the format `DD/MM/YYYY`.
Comments
Admin May 17, 2020

.*12/2/2016.*

Ques:- give me any information abou vb script books learn quckly
Asked In :-
Right Answer:
Here are some recommended VBScript books for quick learning:

1. **"VBScript in a Nutshell" by Paul Lomax** - A concise guide covering essential VBScript concepts.
2. **"Learning VBScript" by David I. Schneider** - A beginner-friendly book that provides practical examples.
3. **"VBScript Programmer's Reference" by Dan Rahmel** - A comprehensive reference for both beginners and experienced programmers.
4. **"Microsoft VBScript Step by Step" by Ed Wilson** - A hands-on approach to learning VBScript with step-by-step instructions.

These books can help you grasp VBScript quickly and effectively.
Ques:- How to use Text file (Notepad) as ur data source in QTP? Can u please provide some function code for it?
Asked In :-
Right Answer:
To use a text file as a data source in QTP (QuickTest Professional), you can use the following VBScript function to read data from a text file:

```vbscript
Function ReadFromTextFile(filePath)
Dim fso, file, line, data
Set fso = CreateObject("Scripting.FileSystemObject")

If fso.FileExists(filePath) Then
Set file = fso.OpenTextFile(filePath, 1) ' 1 = ForReading
data = ""

Do While Not file.AtEndOfStream
line = file.ReadLine
data = data & line & vbCrLf
Loop

file.Close
ReadFromTextFile = data
Else
ReadFromTextFile = "File not found."
End If
End Function
```

You can call this function by passing the path of your text file:

```vbscript
Dim fileData
fileData =
Comments
Admin May 17, 2020

For this you need create File system object.
Below code is for reading from text file
Const ForRead=1
Dim objFSO, objFile, strText
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Reading code
Set objFile=objFSO.OpenTextFile("z:filetext.txt", ForRead)
Do until objFile.AtEndOfStream
strText=objFile.ReadLine
msgbox strText
Loop
objFile.close
Set objFile = nothing
Set objFile1 = nothing
Set objFSO =nothing
"strText" variable will now contain data from text file.

Ques:- In QTP how to insert a data base check point for web based application and simultaneous link to code in expert veiw. hw to retrieve a data(single coulumn from server) that matches with inserted value manually or exported from excel sheet.
Asked In :-
Right Answer:
To insert a database checkpoint in QTP for a web-based application, follow these steps:

1. **Insert Database Checkpoint**:
- Open your test in QTP.
- Go to the "Insert" menu and select "Checkpoints" > "Database Checkpoint".
- In the dialog that appears, configure the database connection by providing the necessary connection string and credentials.
- Write your SQL query to retrieve the desired data.

2. **Link to Code in Expert View**:
- After inserting the checkpoint, switch to the Expert View.
- You will see the generated code for the database checkpoint, which you can modify as needed.

3. **Retrieve Data from Server**:
- Use the `Connection.Execute` method to run your SQL query and retrieve data.
- Store the result in a variable and compare it with the value from your Excel sheet.

Example code snippet:
```vbscript
Dim conn, rs, sqlQuery
Set conn = Create
Comments
Admin May 17, 2020

Even i have stuck with this database check point have you
got the solution for this how to insert a data base check
point pleace could you mail to my id
shiva_uma2003@rediffmail.com thaks in advance

Admin May 17, 2020

I have coded this, can anyone plz rectify and send
Dim con, rs, username1
Set con=Createobject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
con.connectionString="Drivers={SQLServer};
DSN=<dsn_name>; OPTION=0; PWD=konnects; PORT=<port name>;
SERVER=<server name>; UID=konnects"
con.open
rs.open SQL ,conn
SQL= "select user_name from t_member"
Set rs=con.Execute(SQL)
DbTable("DbTable").Check CheckPoint("DbTable")
on error resume next
while rs.EOF
Do Until username1=user_name
username1=rtrim(rs.fields("user_name"))
msgbox username1
If username1=username Then
Msgbox " User name already exist try another"
Username=inputbox("Username")
msgbox User_name
else
rs.MoveNext
end if
loop
wend
rs.close
con.close
Set rs = Nothing
Set con = Nothing
Browser("").Page("page name").WebEdit("UserName").Set
UserName

Ques:- can any body give the code to write the function for given suppose user login with usrer id and pwd to yahoomail.after cliking “sign in”if it is valid user id the next page will display userid’message box.( Note u have to use excel sheet to retrive the userid’s data)
Asked In :-
Comments
Admin May 17, 2020

Hello Mr.Badri,
Script is good,
if anybody don't know scripting they will feel difficult to understand your script, please reduce complexity while answering, here no need to use always reporter events you can display with msgbox or with print statements.
How do you think this is correct validation,
--> you get the user name from excel sheet and placed in user name field.
--> you get the text available in user name field again
--> validating these two values.
no test case will be fail if you do testing like this.
you forgot one more thing you have to click Sign In button with out doing this how could you conclude that the user is valid or not....!
Once you get Home page or mail box page then you can conclude that user name is valid
or
If you don't get any error msg or popup after clicking on Login In then also you can ensure that the user is valid.
If anybody want me to give code, I will give.
above code also correct but some what complexity...!

Admin May 17, 2020

'Create an excel sheet with username and password
'Get username and password from the excel sheet
Set excelobj=createobject("excel.application")
excelobj.workbooks.open("C:Documents and
Settings12Desktoptest data.xls")
usrname=excelobj.sheets(1).cells(2,1)
pwd=excelobj.sheets(1).cells(2,2)
excelobj.workbooks.close
' add the objects to the Object Repository
'Function for username
Function username
If Browser("Yahoo! Mail: The best").Page("Yahoo! Mail: The
best").WebEdit("login").Exist Then
If Browser("Yahoo! Mail: The best").Page("Yahoo!
Mail: The best").WebEdit("login").GetROProperty("disabled")
=false Then
Browser("Yahoo! Mail: The best").Page
("Yahoo! Mail: The best").WebEdit("login").Set usrname
reporter.ReportEvent
micpass,"WebEdit","UsernameEntered: "&usrname
End If
else
reporter.ReportEvent
micfail,"WebEdit","Username Not Entered"
End If
End Function
'Calling the username function
username
'Function for password
Function password
If Browser("Yahoo! Mail: The best").Page("Yahoo! Mail: The
best").WebEdit("passwd").Exist Then
If Browser("Yahoo! Mail: The best").Page("Yahoo!
Mail: The best").WebEdit("passwd").GetROProperty("disabled")
=false then
Browser("Yahoo! Mail: The best").Page
("Yahoo! Mail: The best").WebEdit("passwd").Set pwd
reporter.ReportEvent
micpass,"WebEdit","Password Entered: "&pwd
End If
else
reporter.ReportEvent
micfail,"WebEdit","Password Not Entered"
End If
End Function
'calling the password function
password
'checking the username is valid or not
username="bhadrudu_p"
getdata=Browser("Yahoo! Mail: The best").Page("(1 unread)
Yahoo! Mail").WebElement("bhadrudu_p").GetROProperty
("innertext")
Function usrvalid
If trim(getdata)=trim(username) Then
reporter.ReportEvent micpass,"WebElement","Valid
user"
else
reporter.ReportEvent micfail,"WebElement","Welcome
page not present"
End If
End Function
usrvalid

Ques:- how to get date format from system locale..format means neither long nor shor… format from system locale. i need like your date is mm/dd/yyyy formate or mm-dd-yy or with time like that. how to get.
Asked In :-
Comments
Admin May 17, 2020

i take cint that i will get mm/dd/yy format
first ofall i capture that value take help stepgenatator later
mm/dd/yyyy change into your format

Admin May 17, 2020

see the 'cdate' in the qtp help file .

Ques:- Can we create Crystal Report object in QTP?If yes then what it is and what are its various properties?
Asked In :-
Right Answer:
Yes, we can create a Crystal Report object in QTP (QuickTest Professional). The Crystal Report object is used to automate the generation and manipulation of Crystal Reports. Its various properties include:

1. **ReportSource** - Specifies the source of the report.
2. **Database** - Provides access to the database used in the report.
3. **Parameters** - Allows setting parameters for the report.
4. **ExportOptions** - Configures options for exporting the report.
5. **PrintOptions** - Sets options for printing the report.

These properties help in managing and customizing the report generation process in QTP.
Ques:- How to check the particular window is exist or not with out using check points
Asked In :-
Right Answer:
You can check if a particular window exists in VBScript by using the `FindWindow` API from the `user32.dll`. Here's an example:

```vbscript
Dim hwnd
hwnd = FindWindow("WindowClassName", "WindowTitle")

If hwnd <> 0 Then
MsgBox "Window exists"
Else
MsgBox "Window does not exist"
End If

Function FindWindow(className, windowName)
Dim objShell
Set objShell = CreateObject("Shell.Application")
On Error Resume Next
FindWindow = objShell.Windows.Item(windowName).hwnd
On Error GoTo 0
End Function
```

Replace `"WindowClassName"` and `"WindowTitle"` with the actual class name and title of the window you want to check.
Comments
Admin May 17, 2020

If window("Flight Reservation").Exist<>0 Then
msgbox "window exists"
else
msgbox "window doesnot exists"
End If

Admin May 17, 2020

Dim Expected
Dim Actual
Expected=Window("FlightReservation")
Actual=Window("FlightReservation")
If Actual=Expected Then
Reporter.ReportEvent micPass,Expected&"
"&Exist","CheckPoint Pass"
Else
Reporter.ReportEvent micFail,Expected&" "&Not
Exist","CheckPoint Fail"
End If

Ques:- What is difference between Active screen and movie screen recorder in QTP 9.2?
Asked In :-
Right Answer:
Active Screen captures the state of the application during a test run, allowing you to see the GUI at each step, while Movie Screen Recorder records the entire test execution as a video, showing all actions performed during the test.
Comments
Admin May 17, 2020

In active screen u can see the test objects i.e. the
application at the time of recording. but in movie screen
recorder u can see the screenshots of the application
during runtime.

Ques:- generic function for webedit box for web application
Asked In :-
Right Answer:
```vbscript
Function SetWebEditValue(webEdit, value)
If Not webEdit Is Nothing Then
webEdit.Set value
Else
MsgBox "WebEdit box not found."
End If
End Function
```
Comments
Admin May 17, 2020

if Browser("name:="abc").Page("title:= xyz").WebEdit
("name:=username").Exist(2) Then
Browser("name:="abc").Page("title:= xyz").WebEdit
("name:=username").Set "Chakri"
End if

Ques:- after medical test,when will be the police verification
Asked In :-
Right Answer:
The timing of police verification after a medical test can vary depending on the specific process and organization, but it typically occurs within a few days to a few weeks after the medical test is completed.
Ques:- How do I check that the names in a weblist are correct e.g in flight application the names of item are Denver, paris,London, etc. How do I ensure the correct item is displayed from the list after doing item count ?
Asked In :-
Right Answer:
You can use the following VBScript code to check the names in a weblist:

```vbscript
Dim weblist, itemCount, i, expectedItems
expectedItems = Array("Denver", "Paris", "London")

' Assuming weblist is already defined and refers to the web list object
itemCount = weblist.GetItemCount()

For i = 0 To itemCount - 1
If weblist.GetItem(i) <> expectedItems(i) Then
MsgBox "Item mismatch: " & weblist.GetItem(i)
End If
Next
```

This code compares the items in the weblist with the expected items and displays a message box if there is a mismatch.
Comments
Admin May 17, 2020

First save all item names in DataTable with column
name "FlyFrom" and follow the script:
Val1 = dataTable.Value("FlyFrom")
i = 0
itm = Window("F.R.").WincomboBox("Fly From:").GetItem(i)
If Val1 = itm then
reporter.reportevent 0,"<Step Name> ","<pass>"
else
reporter.reportevent 1,"<Step Name>","Fail"
EndIf
i = i+1

Admin May 17, 2020

Good Satyanj...
expected values in Datatable...!
'Code is here
dim obj_cnt,obj_val,exp_cnt,exp_val
set obj_cnt=object.getitemcount
for i=0 to obj_cnt-1
obj_val=object.getitem(i)
exp_cnt=datatable
("column_Name",dtGlobalSheet).getrowcount
for j=1 to exp_cnt
exp_val=datatable
("column_Name",dtGlobalSheet).value
if (exp_val=obj_val) Then
print "Expected Object is found in
List of Values"
reporter.reportevent
micpass,"Object has been found","Step is passed"
End if
End For
reporter.reportevent micfail,"Object doesn't found",
Next

Ques:- Write VB script to convert from feet to inches(hint 1feet=12 inches)
Asked In :-
Right Answer:
```vbscript
Function FeetToInches(feet)
FeetToInches = feet * 12
End Function

' Example usage:
Dim feet
feet = 5 ' Change this value to convert different feet to inches
WScript.Echo FeetToInches(feet) & " inches"
```
Comments
Admin May 17, 2020

function feet(x)
Inch=12
Res= x*Inch
msgbox x&"Feet"& "="& Res & "Inches"
end function
call feet(2)
Just change instead of 2 any number it ll calu and give u in inches
Hope i answered your question

Admin May 17, 2020

Dim feet,inches,c
feet=4
c=12
inches=feet*c
msgbox feet&"feet="&inches&"inches"

Ques:- how to set one column as primary key in QTP and fetch values accordingly
Asked In :-
Right Answer:
In QTP (QuickTest Professional), you can set a column as a primary key in a DataTable by using the `SetCurrentRow` and `GetParameter` methods. To fetch values accordingly, you can use the `DataTable.Value` method. Here’s an example:

```vbscript
' Set the primary key column
DataTable.SetCurrentRow(1) ' Assuming the first row is the header
DataTable.SetCurrentRow(2) ' Move to the row you want to set as primary key

' Fetch values based on the primary key
Dim primaryKeyValue
primaryKeyValue = DataTable.Value("ColumnName", dtGlobalSheet) ' Replace "ColumnName" with your actual column name

' Use the primary key value as needed
MsgBox primaryKeyValue
```

Make sure to replace `"ColumnName"` with the actual name of your primary key column.
Ques:- I have attended Anovatek Software QTP interview. They will give us computer and one web based application with QTP. We have to automate some records (already updated records or new records) using QTP Data driven testing. But we should use for loop? Can any one know how to do data driven testing using For loop?
Asked In :-
Right Answer:
To perform data-driven testing using a For loop in QTP (QuickTest Professional), you can follow these steps:

1. **Create a Data Table**: Load your test data into the Data Table in QTP.

2. **Use a For Loop**: Implement a For loop to iterate through the rows of the Data Table.

Here’s a sample code snippet:

```vbscript
Dim rowCount
rowCount = DataTable.GetRowCount()

For i = 1 To rowCount
DataTable.SetCurrentRow(i) ' Set the current row to the loop index

' Retrieve data from the Data Table
Dim username, password
username = DataTable("Username", dtGlobalSheet)
password = DataTable("Password", dtGlobalSheet)

' Perform actions using the retrieved data
Browser("YourBrowser").Page("YourPage").WebEdit("UsernameField").Set username
Browser("YourBrowser").Page("YourPage").WebEdit("
Ques:- Plz give the vb script for the following scenerio. In travel booking we have to select from delhi to mumbai from the combobox The prices will be display in another combo box .But i have to select the lowest price for it and submit it
Asked In :-
Right Answer:
```vbscript
Dim prices
Dim lowestPrice
Dim selectedPrice

' Sample prices for the route from Delhi to Mumbai
prices = Array(5000, 3000, 4500, 2500, 6000)

' Find the lowest price
lowestPrice = prices(0)
For i = 1 To UBound(prices)
If prices(i) < lowestPrice Then
lowestPrice = prices(i)
End If
Next

' Display the lowest price in the combo box
selectedPrice = lowestPrice

' Submit the selected price
MsgBox "The lowest price selected is: " & selectedPrice
```
Comments
Admin May 17, 2020

<Obj Hierch>.WinComboBox("From").Select "Delhi"
<Obj.Hier>.WinCombobox("TO").Select "Mumbai"
Itmscnt = <Obj.Hier>.WinComboBox("Price").GetItemsCount
val = <obj.Hier>.WinComboBox("Price").GetItem(0)
For itm = 1 to Itmscnt-1
itmval = <Obj.Hier>.WinComboBox
("Price").GetItem(itm)
If cint(Val) < cint(itmval) then
msgbox "Val is less than itmval"
else
val = itmval
end if
Next
msgbox "Lowest price is: "&val
<Obj.Hier>.WinComboBox("Price").Select val
<Obj.Hier>.WinButton("Submit").Click

Ques:- i created script for login in QTP,i parametirized that using global sheet,problem i am facing is first i want to login with first values provided in excelsheet and want to perform some operation,second time if call same action it should login with second values in excelsheet
Asked In :-
Right Answer:
To achieve this in QTP (now UFT), you can use a loop to iterate through the rows of the Global Data Table. Here’s a simple approach:

1. Use the `DataTable` object to access the Global Sheet.
2. Use a loop to read each row's login credentials.
3. Call your login action with the parameters from the current row.
4. Perform the required operations.
5. Repeat for the next row.

Here’s a sample code snippet:

```vbscript
Dim rowCount, i
rowCount = DataTable.GetRowCount

For i = 1 To rowCount
DataTable.SetCurrentRow(i)

' Get login credentials from the Global Sheet
username = DataTable.Value("Username", dtGlobalSheet)
password = DataTable.Value("Password", dtGlobalSheet)

' Call your login action
Login(username, password)

' Perform operations after login
PerformOperations()
Next
```
Comments
Admin May 17, 2020

hello we should change the settings for that
file-> settings->Run->run the row from 1 to 10 then we can
pass the all the parameter from the datatable.

Admin May 17, 2020

I am supposed to set the value in QTP under File-->
Settings to run on all rows. In your script, take the count
of all the rows in the Excel Sheet and then put in a For
loop and run your action. This is to move the pointer in
Excel Sheet to the next row in the Datasheet to pick the
newer data for execution.



The VBScript category on takluu.com is designed for IT professionals and developers who want to strengthen their skills in Visual Basic Scripting Edition (VBScript). VBScript is a lightweight scripting language primarily used for automation, web development, and administrative tasks in Windows environments.

This section covers essential topics such as VBScript syntax, variables, data types, control structures (loops and conditionals), functions, error handling, and interaction with the Windows operating system. You will also find questions on file handling, working with objects, and automating routine tasks using VBScript.

Interviewers often focus on practical scripting skills, asking questions like:

  • “How do you write a loop in VBScript?”

  • “Explain error handling in VBScript.”

  • “How can VBScript be used to automate system tasks?”

Our content explains VBScript concepts clearly, providing examples and scripts that make it easier to understand and apply. Whether you are preparing for an automation role or a developer position, this category helps you build confidence and master VBScript fundamentals.

At Takluu, we regularly update the VBScript category with new questions, coding examples, and best practices, keeping you prepared for scripting-related interviews and tasks.

AmbitionBox Logo

What makes Takluu valuable for interview preparation?

1 Lakh+
Companies
6 Lakh+
Interview Questions
50K+
Job Profiles
20K+
Users