Recently I have been assigned a project wherein the object references are set using the "Execute" Statements as shown below:
Execute "Set objButton = XamRibbonWindowAddin(""XamWindow_DashBoard"").WpfButton(""Save"")"
Whereas, my approach for setting the object references has always been like this(without the "Execute" Statement):
Set objButton = XamRibbonWindowAddin("XamWindow_DashBoard").WpfButton("Save")
I have been using the latter method as it allows me to make use of Intellisense in UFT which is quite an advantage sometimes.
Is there any reason I need to switch to the 1st approach or Should I ask How is one approach better than the other? I could not get much from the internet.
As long as the
Execute
d code is pre-defined and doesn't contain any parts that are determined dynamically by the test I don't see any benefit of usingExecute
.An example of dynamic code may be something like this contrived example which determines what the variable is called according to some previously computed value
theType
.Then if
theType
is Button it will define the variableobjButton
and if it's Edit it will defineobjEdit
.As I said this is a contrived example, I've never ran across anything that would require you to use
Execute
in UFT.Since you're entering into an existing code base, consistency has it's values. If possible I would ask one of your more experienced co-workers what motivated them to use this construct to better form an opinion.