240 likes | 415 Views
Utility Objects & Regular Expressions. Utility Objects. SystemUtil Object. Applications and processes during the run time session are controlled using the SystemUtil object. The associated methods of SystemUtil Object, are:. Run. CloseProcessByName. CloseDescendant
E N D
Utility Objects & Regular Expressions
SystemUtil Object Applications and processes during the run time session are controlled using the SystemUtil object. The associated methods of SystemUtil Object, are: Run CloseProcessByName CloseDescendant Processes
SystemUtil Object – Run The Run method of the SystemUtil object is used to launch an application or to open a file. Syntax Systemutil.Runfile, [params], [dir], [op], [mode] Note: A SystemUtil.Run statement is automatically added to a test when an application is run from the Start menu or the Run dialog box while recording a test. None Return Type: Systemutil.Run“C:\windows\system32\ notepad.exe”,”C:\test.txt” Example :
Run Method Types of Arguments: Mandatory File The file path of the application or file to open must be provided. Optional Params When the file argument is an executable file, params is used to pass the parameters to the application. Dir It is the working directory of the application. Generally it is the default directory of the application or file. Mode It is the action to be performed. If this argument is blank, then the open operation is performed. It specifies how the application is displayed on opening. To maximize the application, enter this argument value as 3. Open
SystemUtil – Run Method – Example - 1 SystemUtil.Run with Only File Argument
SystemUtil – Run Method – Example - 2 SystemUtil.Run Open Non-Executable File Note: When a non executable file is mentioned in the argument of Run method syntax, it opens in the associated application.
SystemUtil Object – Run Method – Example - 3 SystemUtil.Run Open Web Application
SystemUtil Object – Run Method – Example - 4 SystemUtil.Run Open Web Application Desired Web Browser
SystemUtil Object – CloseProcessByName Method The Close Process By Name method of the SystemUtil object closes a given process according to its name. Syntax: Systemutil.CloseProcessByName(ProcessName) Note: Return Type: Long The application of the process to be closed need not be opened by the QTP test script. Example: Systemutil.CloseProcessByName(“flight4a.exe”)
SystemUtil Object – CloseDescendantProcesses Method The CloseDescendantProcesses method is used to close all processes opened by QuickTest during the run session. Syntax: Systemutil.CloseDescendentProcesses Return Type : Long Example : Systemutil.CloseDescendentProcesses
SystemUtil Object – CloseDescendantProcesses Method – Example SystemUtil.Run"C:\sample.txt" Set objExcel= CreateObject("Excel.Application") objExcel.Visible = True SystemUtil.CloseDescendentProcesses
Reporter Object The Reporter Object enables us to send information to the test results. The associated properties and methods of Reporter Object, are: Report Event Report Path Filter
Reporter Object – ReportEvent Method The Report Event method reports an event to the test results. Reporter.ReportEvent (EventStatus, ReportStepName, Details , ImageFilePath) Syntax: String Return Type: Reporter.ReportEvent (1, "Custom Step", "The user-defined step failed.“) Example:
ReportEvent Method – Types of EventStatus Argument Pass Fail Warning Done
ReportEvent Method - Test Result Window - OverView Status Step Name Step Details
What is a Regular Expression? • Regular expression is a string that specifies a complex search phrase. The conditions of search can be defined using special characters. • Regular expressions enable QuickTest to identify objects and text strings with varying values
Using Regular Expressions in QTP In QTP, Regular Expressions are used in various instances Standard Checkpoint to verify the property values of an object Text checkpoint to verify the text displayed in an application or web page To define the Test Object Property in Object Repository
Commonly used Regular Expressions Period (.) Matches any single character Asterisk (*) Matches zero to any number of occurrences of the preceding character Plus(+) Matches one to any number of occurrences of the precedingcharacter Brackets[A-Z a-z] Matches a range of characters [0-9] Matches a range of numbers