In this blog post category, I would like to share QTP Interview Questions and Answers and QTP Code Corner which helps test engineers to face technical interview.
QTP Interview Question #1 Get all characters from a string in QTP Below is the code snippet which extracts all characters from a string.
Dim a a = "QAInsights" l = Len(a) For i = 1 to l b = mid(a,i,1) MsgBox b Next
QTP Interview Question #2 In a given string, convert all UPPERCASE characters to lowercase, all lowercase letters to UPPERCASE in QTP.
Dim myStr myStr = "QAInsights" For i = 1 to Len(myStr) getChr = mid(myStr,i,1) If asc(getChr)>64 and asc(getChr)<91 Then convert = asc(getChr)+32 Elseif asc(getChr)>95 and asc(getChr)<122 then convert=asc(getChr)-32 End If output = chr(convert)+ output Next MsgBox StrReverse(output)
QTP Interview Question #3 Reverse a given string without using strreverse function
Dim myStr myStr = "QAInsights" For i = 1 to Len(myStr) getChr = mid(myStr,i,1) output = getChr + output Next MsgBox output
QTP Interview Question #4 Find *.txt files in a folder, if it is older than 1 day, delete it.
Set objFSO = CreateObject("Scripting.FileSystemObject") objStartFolder = "D:\MyFolder" Set objFolder = objFSO.GetFolder(objStartFolder) Set colFiles = objFolder.Files For Each objFile in colFiles a = Instr(1,objFile.Name,"txt",1) If a > 0 then MsgBox objFile.Name Msgbox objFile.DateCreated If Now-objFile.DateCreated > 1Then objFile.Delete End If End If Next
Thanks for visiting QAInsights! Check out our new portal Testifications.com to get updates on Software Testing related certifications. We’re always posting interesting articles on QAInsights. I request you to subscribe so you don’t miss out anything. Searching for QA Jobs Openings, check it at www.QAJobOpenings.com
Want to start a blog like this, please visit SpidyDomain to buy cheap web hosting and register domain.
Subscribe to our QAInsights YouTube Channel