Note: These FAQ's from UFT 11.5 on-wards (only for UFT FAQ's here)
UFT FAQ's
VBScript FAQ's
1) Explain how to read registry key in UFT ?
‘Create a shell object
Set MyShell= CreateObject (“WScript.Shell”)
Read the value of key from the registry
RegValue =MyShell.RegRead (varpathofkey)
‘in above function we have to pass the path of key in registery’.
e.g. HKCU\software\ie\settings
msgbox RegValue5
2) What are the ways in UFT to get system environment variables in UFT?
There are three ways to get system environment variables in UFT
2.1 Use the WSH shell object
- Use WMI’s Win32_Environment Class
- Read variables from the registry
Set myShell = CreateObject (“WScript.Shell”)
WScript.Echo myShell.ExpandEnvironmentStrings( "%PATHEXT%" )
myShell=Nothing
The output will be
.BAT; .CMD;.VBS; .VBE; .JS; .JSE
2.2 Other user variable, like TEMP, overwrite their system counterpart
Set myShell = CreateObject( "WScript.Shell" )
WScript.Echo myShell.ExpandEnvironmentStrings( "TEMP=%TEMP%" )
myShell=Nothing
The output will be
TEMP:C:\DOCUME~1\You\LOCALS~1\Temp
2.3 By using the UFT Tool Method we get
Environment.Value("Dir") -> get the QTP Result Directory path
Environment.Value("OS") -> get the OS Name
Environment.Value("LocalHost") -> get the Local host name
3) Mention the steps required in UFT to send mail from outlook?
To send mail from outlook in UFT,
Set Outlook = CreateObject ("Outlook.Application")
Dim Message 'As Outlook.MailItem
Set Message = Outlook.CreateItem(olMailItem)
With Message
.Subject = Subject
.HTMLBody = TextBody
.Recipients.Add (aTo)
Const olOriginator = 0
.Send
End With
4) Explain how you can fetch data from database in UFT?
To fetch data from database in UFT, you have to follow the code below
Set db= createobject (“ADODB.Connection”)
db.Open “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:\guru99\vb6\admission_project.mdb;
Persist Security Info= False”
Set rst=createobject(“ADODB.Recordset”)
rst.Open “select*from Course”, db, 3
id=rst. RecordCount
For i=0 to id-1
Print rst.field (0) & rst.fields (1) & rst.fields (2) & rst.fields (3)
rst.Movenext
Next
5) What are the codes we can use to get files from ftp server in UFT?
To get ftp files from ftp server, you have to use below code
a) put- To store single file on server
b) get- To download single file from ftp server
c) mget- To download multiple files from server
d) mput- To store multiple files on server
e) delete- To delete files on ftp server
MyShell.Run "%comspec% /c FTP -n -s:" & commandstoworkwithftp & " " & Site, 0,True
6) In UFT how you can prevent the system from getting locked?
To prevent system getting locked, any of the two ways can be used
I. Create a simple vbs file having code to press numlock key and run that vbs file
II. Edit one registry key "DisableLockWorkstation =1" to disable locking
No comments
Post a Comment