The task is to open (click) menu item, e.g. File >> Open using QTP 11.0

enter image description here

You can check here how to spy drop-down menu properties with object spy.

Below is the code that is autogenerated by QTP when I drag-and-drop JavaMenu "File" from object repository:

JavaWindow("File: Test.java").JavaMenu("File").Select 

I expected (from my experience of working with Java Tabbed Pane) that the next code should work:

JavaWindow("File: Test.java").JavaMenu("File").Select "Open"

But encountered Run Error: Inappropriate quantity of arguments or assigning value of property: JavaWindow("...").JavaMenu("...").Select (my translation of localized QTP message)

So it lools like Select should not take any arguments.


The solution is to access menu items on drop-down pane with descriptive programming and use Select function without arguments:

JavaWindow("File: Test.java").JavaMenu("File").JavaMenu("label:=Open").Select

This works fine, but finally I came to the usage of pure descriptive programming (DP) to avoid usage of object repository:

JavaWindow("label:=File: Test.java*").JavaMenu("label:=File").JavaMenu("label:=Open").Select
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.