1 / 24

Utility Objects & Regular Expressions

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

ovid
Download Presentation

Utility Objects & Regular Expressions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Utility Objects & Regular Expressions

  2. Utility Objects

  3. 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

  4. 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 :

  5. 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

  6. SystemUtil – Run Method – Example - 1 SystemUtil.Run with Only File Argument

  7. 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.

  8. SystemUtil Object – Run Method – Example - 3 SystemUtil.Run Open Web Application

  9. SystemUtil Object – Run Method – Example - 4 SystemUtil.Run Open Web Application Desired Web Browser

  10. 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”)

  11. SystemUtil Object – CloseProcessByName Method– Example

  12. 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

  13. SystemUtil Object – CloseDescendantProcesses Method – Example SystemUtil.Run"C:\sample.txt" Set objExcel= CreateObject("Excel.Application") objExcel.Visible = True SystemUtil.CloseDescendentProcesses

  14. 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

  15. 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:

  16. ReportEvent Method – Types of EventStatus Argument Pass Fail Warning Done

  17. ReportEvent Method - Test Result Window - OverView Status Step Name Step Details

  18. Regular Expressions

  19. 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

  20. 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

  21. 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

  22. Regular Expression – Example 01

  23. Regular Expression – Example 02

  24. Regular Expression – Example 03

More Related