withoptions Statement

Action

Opens a block of code in which agent options can be set for the duration of the block.

Syntax

withoptions 
statement

where statement is a single statement or a series of statements.

Notes

User-defined functions cannot be called on block entry or exit. The previous values of the agent options are restored on block exit, even if an error occurs. The error will be re-raised after the options are restored.

Use the BindAgentOption function to set an agent option for the duration of a block, because the withoptions statement does not work with the SetOption method of the AgentClass class.

Example

[-] testcase Test2() appstate none
	[ ] TestApplication.SetActive() 
	[-] withoptions 
		[ ] // slow down the mouse and keyboard 
		[ ] BindAgentOption(OPT_KEYBOARD_DELAY,500)
		[ ] BindAgentOption(OPT_MOUSE_DELAY,500) 
		[ ] TestApplication.Control.CheckBox.Pick()
		[ ] xCheckBox.TheCheckBox.Check() 
		[ ] xCheckBox.TheCheckBox.Uncheck() 
		[ ] xCheckBox.TheCheckBox.Check()
		[ ] xCheckBox.Close()   
	[ ] 
	[ ] //back to my usual settings, outside withoptions
	[ ] TestApplication.Control.CheckBox.Pick() 
	[ ] xCheckBox.TheCheckBox.Check()
	[ ] xCheckBox.TheCheckBox.Uncheck()
	[ ] xCheckBox.TheCheckBox.Check()
	[ ] xCheckBox.Close()