1

I am new to QTP and trying out some Java GUI automation. I have to click a java button and sometimes the button may not be available to click. i.e it will be in disable state.

Because of this, my code is fail to click the button

JavaWindow("TestApp").JavaButton("Apply").Click

How can I make it to handle the error case ?

Note : I am using QTP's record and playback option only, not the descriptive programming.

4

1 回答 1

2

您可以使用 GetROProperty 方法检查对象的运行时属性。检查所有选项的 QTP/UFT 帮助文档。在这种情况下,你可以试试这个:

Dim isButtonEnabled
isButtonEnabled = JavaWindow("TestApp").JavaButton("Apply").GetROProperty("enabled")
If isButtonEnabled Then
    JavaWindow("TestApp").JavaButton("Apply").Click
Else
    Reporter.ReportEvent micFail, "Button Click", "The button is disabled"
End If
于 2014-07-15T12:29:15.433 回答