Automation testing QTP with VB Script functions Interview questions


Total available count: 68
Subject - Software Testing
Subsubject - Automation testing QTP with VB Script functions

Method: CreateTextFile?

It creates a specified file name and returns a TextStream object that can be used to read from or write to the file.

Syntax: Set objfile = fso.CreateTextFile(filename[, overwrite[, Unicode]])

Arguments:
fso: (Required) The name of a FileSystemObject object previously instantiated.
filename: (Required) A string expression that identifies the file to create.
overwrite: (Optional) Boolean value that indicates whether you can overwrite an existing file. The value is True if the file.
can be overwritten, False if it can't be overwritten. If omitted, existing files are not overwritten (default False).
unicode: (Optional) Boolean value that indicates whether the file is created as a Unicode or ASCII file. If the value is True, the file is created as a Unicode file. If the value is False, the file is created as an ASCII file. If omitted, an ASCII file is assumed.

Example-1:   

'Create a filesystemObject
Set fso=createobject("Scripting.FileSystemObject")
'Create a non existing file "qtptest.txt "  with overwrite option as True
Set qfile1=fso.CreateTextFile("C:qtptest.txt",True,False) 
Output --> New File "qtptest.txt " is created
'Close the files
qfile1.Close
'Release the allocated objects
Set qfile1=nothing 

Example-2:   

'Create a filesystemObject
Set fso=createobject("Scripting.FileSystemObject")
'Create a   file "qtptest.txt "  in C Drive . 
'Then  run the below statement with overwrite option as False.
'Output --> Error message "Fie already exists" is displayed
Set qfile2=fso.CreateTextFile("C:qtpexist.txt",False,False)
Set fso=nothing

 




Next 5 interview question(s)

1
Method: CopyFile?
2
Method: DeleteFile?
3
Method: CreateFolder?
4
Method: CopyFolder?
5
Method: MoveFolder?

Comments