Set Object Reference in UFT with or without the “Execute” Statement

核能气质少年 提交于 2019-12-10 11:44:01

问题


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.


回答1:


As long as the Executed code is pre-defined and doesn't contain any parts that are determined dynamically by the test I don't see any benefit of using Execute.

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.

Execute "Set obj" & theType & " = XamRibbonWindowAddin(""XamWindow_DashBoard"").Wpf" & theType & "(""Save"")"

Then if theType is Button it will define the variable objButton and if it's Edit it will define objEdit.

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.



来源:https://stackoverflow.com/questions/44156333/set-object-reference-in-uft-with-or-without-the-execute-statement

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!