Forum Discussion

ASV's avatar
ASV
Contributor
13 years ago

Problem with Popupmenu

HI

I am tesing an application. When I click the mouseright button appears operations. I must check, if my wanted operation exists in them.

I write this code



1.Dim nstorage()

2.

3.        wappl.Keys("[X93]")

4.        menuCount = wMainForm.PopupMenu.Count


5.        ReDim nStorage(menuCount)


6.        For j = 0 To menuCount - 1


7.            nStorage(j) = wMainForm.PopupMenu.Items(j).Caption


8.        Next

9.

10.n = "my wanted name"  

11.

12. If nStorage(j) = n then

13.         Log.message("Operation with "&n&" name is exist")

14. Else

15.           Log.Error("Operation with "&n&" name isn't exist")

16. End If



But when i run test and in lines 6-8 colecting the operations' name it passes over popupmenu twice and "menucount" is not equal the exact count of operations.
  

6 Replies

  • ASV's avatar
    ASV
    Contributor
    Also I try in this way

                

    wappl.Keys("[X93]")

    BuiltIn.Delay(1000)


    Call wMainForm.PopupMenu.Check("My wanted name", False)



    one of the operations have it's submenu and when i run test this submenu strangely opens and "Check" method works for submenu. Therefore I receive wrong results.

    If anybody knows why must happen such a strange things.

    Thanks in advance 
  • ASV's avatar
    ASV
    Contributor
    This is an attachment in which is popupmenu. I must check if selected operations in it exist or not(there are some cases when there are not exist).

    But the submenu(you can see it in attacment) is opened and my codes in two posts work for submenu. Sometimes the first code works  such that I descirbe in first post. It is begun from "Edit"(not "View") and after one cycle(when it pass over whole popupmenu and returns to "Edit") continues passing over next 7 operations.I don't understand why. I will thanks any help?
  • Vahagn,

    Can you reproduce a similar problem with the context menu of Notepad? Please try this. If the problem can be reproduced, please send us your TestComplete project.
  • ASV's avatar
    ASV
    Contributor
    Hi Irene

    I write your code in "How convert Log error to Log message" thread. It works properly only for first menuitem which I want to know exists or not.

    For the second menuitem the submenu is opened and the function "MenuItemexists" works for submenu. To avoid this I decided to close popupmenu and open it again. Now it works properly.

    For notepad it will be equivalent that I want to know if exist menuitems "Open IME" and "Reconversion" in popupmenu, but for "Reconversion" the "Insert Unicode control character" would be opened and the function "MenuItemexists" will work for this and will not find it.

    But in Notepad your code works fine:)

    Best Regards
  • Hello Vahagn,

    I have checked my script with the "Reconversion" and the "Insert Unicode control character" menu items of Notepad's context menu. It works correctly. Do I get it right that the script fails only with your application? Can you create a sample application that I could use to reproduce the behavior here?
  • ASV's avatar
    ASV
    Contributor
    Yes Irene you get right your code failed only in my application. In notepad it works excellent.

    Anyway I solve problem.

    Thank you very much