cancel
Showing results for 
Search instead for 
Did you mean: 

How to check menu item's state that popup by right click

SOLVED
Highlighted
Occasional Contributor

How to check menu item's state that popup by right click

Hi all. I'm using TC11 with VBScript and I'm trying to know the popup menu item is checked or unchecked. I studied Checking Menu Item's State but the structure of Notepad is different compare with my application. This is what I get from Additional Info after I ran the keyword test:

 

Tested object:
Aliases.RobotArm.wndRobotArm.Afx.AfxWnd90u.PopupMenu
(Sys.Process("RobotArm").Window("Afx:00007FF6A9B70000:0", "RobotArm", 1).Window("Afx:00007FF6A9B70000:b:0000000000010003:0000000000000006:0000000000000000", "", 1).Window("AfxWnd90u", "Image View 1", 10).PopupMenu)
 
Sub Test
  Dim w
  Set w = Sys.Process("RobotArm").Window("Afx:00007FF6A9B70000:0", "RobotArm", 1).Window("Afx:00007FF6A9B70000:b:0000000000010003:0000000000000006:0000000000000000", "", 1).Window("AfxWnd90u", "Image View 1", 10)
  
  If w.PopupMenu.Items(8).Checked Then
    Call Log.Message ("The ""Light"" option is checked.")
  Else
    Call Log.Message ("The ""Light"" option is unchecked.")
  End If
End Sub
I applied it into the script and run the keyword test but the error shows "Cannot obtain the popup menu." 
Possible reason: There was no click that invokes the popup menu.
 
I suspect the reason is due to Afx window but I have no idea how to deal with it. Does anyone know how to fix this? Thanks in advance. 
Tags (2)
1 ACCEPTED SOLUTION

Accepted Solutions
Occasional Contributor

Re: How to check menu item's state that popup by right click

Hi @TanyaGorbunova ,

 

I had tried to change the index number and there is no more issue. Thanks a lot!

View solution in original post

5 REPLIES 5
Community Hero

Re: How to check menu item's state that popup by right click

Hi,

 

a) I do not see anything in your code that supposed to open popup menu indeed (right-click, or pressing the menu key, or ...);

b) To exclude the dynamic part of window class name (Afx:...) you may substitute it with asterisk (e.g.: Afx:00007FF6A9B70000:0 => Afx:00007FF6A9B70000*).

 

However, considering the text of the error message, first point seems to be the real reason to me. If it were the second point, I would expect something like 'Window ... was not found'.

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Occasional Contributor

Re: How to check menu item's state that popup by right click

Hi AlexKaras,

 

There is an action in keyword test of right click on AfxWnd90u to open the popup menu, then I add the script and get some message to verify is the script really can check the menu state or not.

 

After I applied the asterisk and these are what shown in test log.

 

The menu item 'Light' was clicked. (add. info show the tested object is the PopupMenu)

Cannot obtain the popup menu. (add. info show the tested object is Image View 1)

 

Is it means that actually the script is testing the wrong object? Maybe due to this code?

w.PopupMenu.Items(8)

 

Community Manager

Re: How to check menu item's state that popup by right click

Hi @Josh_147,

 

Could you please explain a bit more about possible states of the menu item? That would be great if you can prepare a sample application with this control - in this case, the community can play with it and find a solution.

 

 

---------
Tanya Gorbunova
SmartBear Community Manager

 Join SmartBear Connect next April in Boston to meet with software development, API and testing experts from around the world! Get your ticket today!
Occasional Contributor

Re: How to check menu item's state that popup by right click

Hi @TanyaGorbunova ,

 

I had tried to change the index number and there is no more issue. Thanks a lot!

View solution in original post

Community Manager

Re: How to check menu item's state that popup by right click

Happy to hear this, @Josh_147 Smiley Happy

---------
Tanya Gorbunova
SmartBear Community Manager

 Join SmartBear Connect next April in Boston to meet with software development, API and testing experts from around the world! Get your ticket today!