Pages

Tuesday, November 13, 2012

Quick Test Professional (QTP) - Setting Object


You can use the Setting object to control how QuickTest run tests by setting and retrieving testing options during a run session.

QuickTest testing options affect how you work with tests. For example, you can set the maximum time that QuickTest allows when loading a Web page, before determining that the URL address cannot be found.



Some options are global and others affect only the current test. After you use a Setting object to set a testing option, the setting remains in effect until it is changed again or until the end of your current QuickTest session. You can also use the Setting object to change a setting for a specific part of a specific test.


Some of the testing options that you can set using the Setting object are also available in the Options dialog box (global options) or the Test Settings dialog box (test specific settings). When you use the Setting object to set these options, the change is reflected in the relevant dialog box. Other test settings can be accessed using only one method, either the relevant dialog box or the Setting object.



This object provides the following properties and method to modify test properties at run-time:
  • Add method
  • Exists method
  • Remove method
  • Item property

The Add method:
This method is used to define user-defined settings to the object:

'Add the setting to QTP
Setting.Add "LogErrors", "Yes"
Msgbox Setting.Item("LogErrors")  'Will return "Yes"

'Since Item is the default property for Setting object, we can also use the following syntax:
Msgbox Setting ("LogErrors")  'Will return "Yes"

The Exists method:
This method is used to check if a setting is currently defined:

'Check if LogErrors setting exists or not
If Setting.Exists("LogErrors") then
  Msgbox Setting("LogErrors")  'Will return "Yes"
Else
  Setting.Add "LogErrors", "Yes"
  Msgbox Setting("LogErrors")  'Will return "Yes"
End If

The Remove method
This method is used to remove user-defined settings from the object:

'Will return False
Msgbox Setting.Exists("LogErrors")
Setting.Add "LogErrors", "Yes"

'Will return True
Msgbox Setting.Exists("LogErrors")

Setting.Remove "LogErrors", "Yes"

'Will return False
Msgbox Setting.Exists("LogErrors")

QTP also provides the following build-in Setting object values:
  • AutomaticLinkRun
  • DefaultLoadTime
  • DefaultTimeOut
  • ReplayType
  • SnapshotReportMode
  • WebTimeOut

No comments:

Post a Comment