QTP - Vbscript interview questions and answers



Hi friends - on this page you will find all interview questions on QTP and VB script

In QTP, vbscript is used as a scripting language. 80% of programming you do in QTP is based vbscript concepts. So There is no doubt that you will face interview questions based upon vbscript.

Q1. How to find the length of string in QTP?

Answer -You can find the length of the string using one vb script function called len.

Suppose you want to find the length of "salunke" then you will have the below statement which will print the length of string .

print len("salunke")


Q2. How to find the current system time in QTP?

Answer - You can find the current system time using Time function in vbscript.

Print time

Q3. How to remove all spaces from given string in QTP?

Answer - We can use replace function in vbscript to remove all spaces in string.

e.g. newstring = replace(stringwithspaces," ","")


Q4. How to find the modulus of a number in QTP?

Answer - We can find the modulus of given number using MOD operator.

a = 10 mod 5

print a

Q5. How to find the size of array in QTP?

Answer - To find the size of array, we can use ubound function in QTP.

print ubound(arr) - 'prints upper bound of array.

Q6. What is the difference between byref and byval in QTP?

Answer - You can pass the parameters to function or procedure using byref or byval method.

byref will pass the address of variable but byval will pass the copy of variable. So when you want the passed value to change, you can pass the value using byref method. Otherwise you can pass it using byval method.

Q7. How to find the difference between 2 dates in QTP?

Answer - You can find the difference between 2 dates using datediff function. You can get the difference in terms of minutes, seconds, hours, months or years.

Q8. How to generate the random number in given range in QTP?

Answer:
Min = 1
Max = 10
Randomize
RandomNumber = (Int((max-min+1)*Rnd+min))

Q 9. How to create an array of dictionaries in QTP?

Answer - We can create the array of dictionary like how we create array of scalar variables.
Syntax is shown below –
'Declare Array with 5 elements
Dim myArray(5)
'Make first element in array as a dictionary object
Set myArray(0) = createobject("scripting.dictionary")
'Once we have a dictionary object, We can use its methods like add, remove, removeall etc
myArray(0).Add"mykey","myvalue"
'display item value of mykey in dictionary myArray(0)
print myArray(0)("mykey")
myArray(0).removeall

Q 10. How Can we store array variable in dictionary in QTP?

Answer -
Dim a
a = array(2,3,4,5)
Set d = createobject("Scripting.Dictionary")
d.Add "mykey", a
print d("mykey")(0)
Q 11. What is win32 API and how to use it in QTP?
Answer -
win32 API is an API that can be used to perform different administrative tasks. It has many WIN32 classes like Win32_Process etc.

Below Example used Win32 API in QTP to close the process by its name.

'Get the WMI object
Set WMI = GetObject("winmgmts:\\localhost\root\cimv2")
'Get collection of processes for with name pname
Set allp = WMI.ExecQuery("Select * from Win32_Process Where Name = '" & pname & "'")
'Loop through each process and terminate it
For Each p in allp
p.Terminate()
Next
This is how we can use win32 API in QTP.

Here is the list of more QTP-Vbscript Interview Questions.

  1. Difference between Executefile and execute in QTP
  2. How to convert data types in qtp
  3. How to send mail from outlook in qtp
  4. How to fetch data from database in QTP
  5. How to get xml node value in QTP`
  6. How to Find Test Execution Time in QTP
  7. How to find screen resolution in QTP
  8. How to define Array in QTP
  9. How to convert date format in qtp

The list of Software (IT) Companies in Which above QTP interview Questions are asked is given below.


3i Infotech , Accel Frontline Ltd , Accenture , Aditi Technologies , Adobe Systems , ADP , Adrenalin eSystems , AES Technologies , Affiliated Computer Services , Aftek , Agilent Technologies , Allianz , Amazon , Amdocs , American Megatrends India , Anantara Solutions , Aptech , Arbitron , Aricent Group , Aspire Systems , Atom Technologies , Atos , Avaya , BancBox , Barclays , BatchMaster , BirlaSoft , Blackberry , Bluestar , BMC , Brahma Vision , Cadence Design Systems , Canon , Capgemini , Capita , C-DAC , CGI Group , Cisco Systems , CMC Limited , CMC Ltd , Cognizant , Comat Technologies , Computer Associates , Computer Sciences Corporation(CSC) , Comviva , Conexant Systems , CoWare , Cybage , Cynapse , D. E. Shaw Research , Datamatics , Dell , Deloitte , Directi , eBay , Eclerx , Ernst & Young , Essar , Etisalat DB Telecom , Evergreen , EXL Service , Fab.com , Facebook , FactSet , Firstsource , Fiserv , Fujitsu , Future Group , Genpact , Geometric , GlobalLogic , Google , Harbinger , HCL , Headstrong , Hewitt Associates , Hexaware , Hitachi Consulting , Honeywell , Hsbc , IBM , Iflex , iGate , Iken Solutions , Impetus Technologies , Infinite Computer Solutions , Infosys , Infotech Enterprises , Infrasoft Technologies Ltd , Ingram Micro , Intec , Intergraph , Investis , ITC Infotech , Ixia , JP Morgan , Kayako , KPIT Cummins , Larsen & Toubro , Lenovo , Lexmark , Lionbridge , Logica , Mahindra Satyam , Mastek , McKinsey , MediaTek , Melstar Information Technologies , Microland , Micromax Mobile , Microsoft , Mindfire Solutions , MindTree , MobME , Monsoon HAVA , MphasiS , Ness Technologies , NeST Software , Network Solutions , NIIT , Nokia Siemens , Novartis , NTT Data , Nvidia , NVISH , Omnitech , Onward , Oracle , Patni , PayPal , Persistent Systems , PGMS , Pitney Bowes , Polaris , Pramati Technologies , QuinStreet , R Systems Ltd , Ramco Systems , Red Hat , Rediff.com , Redington , Reliance , Robert Bosch , Rolta , RR Donnelley , SafeNet , Samsung , Sankalp Semiconductor , Sapient , Sasken , Serco , Siemens , Sonata Software , Sopra Group , STMicroelectronics , SunGard , SunTec , Surat , Sutherland , SUVI , Sybase , Symantec , Symbiosis , Symphony , SynapseIndia , Synechron , Synopsys , Syntel , Tally Solutions , Tata Consultancy Services , Tech Mahindra , Tejas Networks , Telcon Construction Solutions , Teradata , Thirdware , ThoughtWorks , Tibco , Tieto , Toonz , UST Global , Verizon , Virtusa , Wipro , WNS , Xansa , Xavient , Xerox ACS , Yash Technoloies , Zenith Computers , Zensar Technologies , ZOHO Corporation , ZS Associates

The list of Investment Banks in Which above QTP interview Questions are asked is given below.
  1. Goldman Sachs
  2. Morgan Stanley
  3. JP Morgan Chase
  4. Bank of America
  5. Merrill Lynch
  6. Deutsche Bank
  7. Citigroup
  8. Credit Suisse
  9. Barclays Capital
  10. UBS
  11. HSBC
  12. Nomura Holdings
  13. RBC Capital Markets
  14. BNP Paribas
  15. The Royal Bank of Scotland Group
  16. TD Securities
  17. Wells Fargo
  18. Lazard
  19. Jefferies Group
  20. Société Générale
  21. BMO Capital Markets

I am going to add more QTP vbscript questions. You can inform me by posting the comment below. Thanks for reading this blog.

You may also like -


QTP Questions and Answers for Experienced guys
Advanced QTP Questions and answers
Advanced QTP Tutorial


Dear friend - What do you think about this topic? Please express your thoughts via comment box.

No comments:

Post a Comment

Please Leave your reply. We value your feedback and inputs

Best QTP Books

Everything About QTP

Hello Friends,
You can find QTP study material, Multiple choice questions (mcq), QTP question bank, QTP question papers, QTP notes, QTP questionnaire, scenario based QTP interview questions, QTP tutorial and QTP training on this site.

If you are a fresher or experienced QTP professional with (1/2/3/4) years of experience, this blog is just for you.