0% found this document useful (0 votes)
65 views6 pages

Description Object

The document describes various utility objects that can be used in Mercury Test scripts including the Description object, Environment object, and provides examples of how to use them. The Description object can be used to create empty objects and add properties and values to them. The Environment object allows working with environment variables, including built-in, user-defined, loading variables from files, and creating/accessing variables. WSH scripting examples are also provided such as popping up messages, getting the username, sending keyboard inputs, reading/writing to the registry, and executing DOS commands.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views6 pages

Description Object

The document describes various utility objects that can be used in Mercury Test scripts including the Description object, Environment object, and provides examples of how to use them. The Description object can be used to create empty objects and add properties and values to them. The Environment object allows working with environment variables, including built-in, user-defined, loading variables from files, and creating/accessing variables. WSH scripting examples are also provided such as popping up messages, getting the username, sending keyboard inputs, reading/writing to the registry, and executing DOS commands.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Here is the list of utility objects

Crypt Object DataTable Object Description Object DotNetFactory Object DTParameter Object DTSheet Object Environment Object Extern Object LocalParameter Object MercuryTimers Object (Collection) MercuryTimer Object Parameter Object PathFinder Object Properties Object (Collection) QCUtil Object RandomNumber Object Recovery Object Reporter Object RepositoriesCollection Object Repository Object Services Object Setting Object TextUtil Object TSLTest Object XMLUtil Object

Description Object Description object is used to create an empty description object in the script. We can add properties and values to the created object. Using an empty Description object Set obj=Description. create Here obj is an empty object and contains no properties. This refers any object in application. Ex:Set obj=Description. create Set objList=Browser(micclass:=Browser).Page(micclass:=Page).Childobjects( obj) Msgbox objList.count Gives Total objects count in the page Using Description object with properties Set obj=Description. create obj(micclass).value=Link

Now objis a link object and it refers all link objects in application. Ex:1) Set obj=Description. create obj(micclass).value=Link Set objList=Browser(micclass:=Browser).Page(micclass:=Page).Childobjects( obj) Msgbox objList.count Gives Total Link objects count in the page 2) Set obj=Description. create obj(micclass).value=Link obj(name).value=Login Set objList=Browser(micclass:=Browser).Page(micclass:=Page).Childobjects( obj) Msgbox objList.count Gives only the link which is having Login name Description object is useful when object properties are changing dynamically or if objects are adding in application dynamically and also to handle the duplicate objects (repeated objects). '@@@@@@@@@@@ @@@@@@@@@ @@@@@@@@@ @@@@@@@@@ @@

Environment object is to work with environment variables. Environment variable is a global variable which can be accessible from entire test.

Two types of Environmental variables

1. Built-In Environmental variables 2. User Defined Environment variables

User defined environment variable and value can be created and changed at any time.

Accessing Environment Variable

Msgbox Environment. Value("OS" ) OR Msgbox Environment( "OS")

This gives current OS Name

Loading External Environment Variables from a File

Environment. LoadFromFile( "C:\demo. xml") OR Environment. LoadFromFile( "C:\demo. cnf")

Creating User Defined Environment Variable

Environment. Value("DemoVar" )="demo"

This statement will create a new variable (DemoVar) and assigns a value (demo) in runtime. With this logic we can easily exchange the values between actions.

For example I f you want to pass a value to other action Follow these steps.

1. Create an environment variable 2. Assign a value

Environment. Value("DemoVar" )="demo"

3. Access the value in other actions

Msgbox Environment( "DemoVar" ) Hi, Here iam giving some samples about WSH scripting. Regards, Sudhakar

'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@

WSH Samples

'How to popup a message with some wait

Set WshShell = CreateObject("WScript.Shell") WshShell.Popup "message body", 5, "Title"

'How to get the current UserName of logged in Set WshNetwork = CreateObject("WScript.Network") userName = WshNetwork.username Set WshShell = CreateObject("WScript.Shell") WshShell.Popup userName ", 50, " userName "

How to send keyboard inputs to application set WshShell = CreateObject("WScript.Shell") WshShell.SendKeys "gjhfghjfghjf"

How to get the value of the system environment variable Set WshShell = CreateObject("WScript.Shell") Set WshSysEnv = WshShell.Environment("SYSTEM") WScript.Echo WshSysEnv("NUMBER_OF_PROCESSORS")

How to write and read registry Set WshShell = CreateObject("WScript.Shell")

WshShell.RegWrite "HKCU\Software\ACME\FortuneTeller\", 1, "REG_BINARY" WshShell.RegWrite "HKCU\Software\ACME\FortuneTeller\MindReader", "Goocher!", "REG_SZ"

bKey = WshShell.RegRead("HKCU\Software\ACME\FortuneTeller\") msgbox WshShell.RegRead("HKCU\Software\ACME\FortuneTeller\MindReader")

'How to execute DOS commands

Set oShell = CreateObject ("WSCript.shell")

oShell.run "cmd /K CD C:\ & Dir"

'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@

You might also like