2017 up to now  | 2016 | 2015 | 2014 | 2013 | 2012 | 2011 | 2010 | 2009 | 2008 | 2007

(older archive entries before 2007 are not shown here, but included in the onsite-search)

Mailing List - Entries of 2011


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [QF-Test] AWT sub-popup-menu


  • Subject: Re: [QF-Test] AWT sub-popup-menu
  • From: Gregor Schmid <Gregor.Schmid@?.de>
  • Date: Mon, 24 Jan 2011 11:31:31 +0100

Hi Ghada,

looks like you've got almost everything in place. Given your code
below, popups[0] is an AWT PopupMenu, this

popups[0].getItem(0) 

is the first item in the popup. If you have an item in a sub-menu, you
just get the menu and then the item, e.g.

menu = popups[0].getItem(2)
item = menu.getItem(0)

of course with the correct indexes for sour popup menu.

Best regards,
    Greg

"ElSawy, Ghada" <ghada_elsawy@?.com> writes:

> Hi All,
>
> I am trying to write test cases for some AWT popup menus
>
> So I used the below script to access the AWT menu items:
>
> from java.awt.event import ActionEvent
>
> from javax.swing import SwingUtilities
>
> from java.lang import Runnable
>
> from de.qfs.lib.util import Reflector
>
> class InvokeListeners(Runnable):
>
>     def __init__(self, event, listeners):
>
>         self._event = event
>
>         self._listeners = listeners
>
>     def run(self):
>
>         for i in range(len(self._listeners)):
>
>             self._listeners[i].actionPerformed(self._event)
>
> # Get the component which holds the popup
>
> com = rc.getComponent("myComponent")
>
> popups = Reflector.get(com, "popups", True) # Get the item to simulate the click on
>
> item = popups[0].getItem(0)
>
> event = ActionEvent(item, ActionEvent.ACTION_PERFORMED,item.getActionCommand())
>
> listeners = item.getActionListeners()
>
> SwingUtilities.invokeLater(InvokeListeners(event, listeners))
>
> But What if there are sub-menu items that I would like to access, is it possible??
>
> Thanks,
>
> Ghada El-Sawy

-- 
Gregor Schmid                                Gregor.Schmid@?.de
Quality First Software GmbH                     http://www.qfs.de
Tulpenstr. 41                               Tel: +49 8171 38648-0
DE-82538 Geretsried                         Fax: +49 8171 3864816
GF: Gregor Schmid, Karlheinz Kellerer          HRB München 140833