0

I've started working in robot framework's swing library, gui testing a java application in swing.

I have to select the jcheckboxmenuitem "waveMenu" from a jpopupmenu "menu" on a jtextarea "showText". Running the keyword:

Select From Popup Menu      showText        menu|waveMenu

Results in a very unhelpful error.

Fail: Popup menu

If I try to right click on the component showText, it simply passes without bringing up the menu associated with it. The menu is attached by a regular mouselistener.

showText.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            if (e.isPopupTrigger()) {
                menu.show(e.getComponent(), e.getX(), e.getY());
            }
        }
    });

Listing components in context from the top results in this

Level: 0 Component: ca.acme.myApplication
Index: 0 Name: the name I select when I run Select Window
    Level: 1 Component: javax.swing.JRootPane Index: 0 Name: null
       Level: 2 Component: javax.swing.JPanel Index: 0 Name: null.glassPane
       Level: 2 Component: javax.swing.JLayeredPane Index: 0 Name: null.layeredPane
          Level: 3 Component: javax.swing.JPanel Index: 1 Name: null.contentPane
             Level: 4 Component: javax.swing.JPanel Index: 2 Name: null
                Level: 5 Component: javax.swing.JButton Index: 0 Name: fileOpenButton
                Level: 5 Component: javax.swing.JTextField Index: 0 Name: fileText
                Level: 5 Component: javax.swing.JButton Index: 1 Name: fileSendButton
                Level: 5 Component: javax.swing.JLabel Index: 0 Name: null
                Level: 5 Component: javax.swing.JTextField Index: 1 Name: hostText
                Level: 5 Component: javax.swing.JComboBox Index: 0 Name: formatSelect
                   Level: 6 Component: javax.swing.plaf.metal.MetalComboBoxButton Index: 2 Name: null
                   Level: 6 Component: javax.swing.CellRendererPane Index: 0 Name: null
                      Level: 7 Component: javax.swing.plaf.basic.BasicComboBoxRenderer$UIResource Index: 1 Name: null
                Level: 5 Component: javax.swing.JComboBox Index: 1 Name: voiceSelect
                   Level: 6 Component: javax.swing.plaf.metal.MetalComboBoxButton Index: 3 Name: null
                   Level: 6 Component: javax.swing.CellRendererPane Index: 1 Name: null
                      Level: 7 Component: javax.swing.plaf.basic.BasicComboBoxRenderer$UIResource Index: 2 Name: null
                Level: 5 Component: javax.swing.JComboBox Index: 2 Name: delaySelect
                   Level: 6 Component: javax.swing.plaf.metal.MetalComboBoxButton Index: 4 Name: null
                   Level: 6 Component: javax.swing.CellRendererPane Index: 2 Name: null
                      Level: 7 Component: javax.swing.plaf.basic.BasicComboBoxRenderer$UIResource Index: 3 Name: null
                Level: 5 Component: javax.swing.JTextField Index: 2 Name: messageText
                Level: 5 Component: javax.swing.JButton Index: 5 Name: messageSendButton
                Level: 5 Component: javax.swing.JLabel Index: 4 Name: portLabel
                Level: 5 Component: javax.swing.JTextField Index: 3 Name: portText
                Level: 5 Component: javax.swing.JComboBox Index: 3 Name: requestSelect
                   Level: 6 Component: javax.swing.plaf.metal.MetalComboBoxButton Index: 6 Name: null
                   Level: 6 Component: javax.swing.CellRendererPane Index: 3 Name: null
                      Level: 7 Component: javax.swing.plaf.basic.BasicComboBoxRenderer$UIResource Index: 5 Name: null
                Level: 5 Component: javax.swing.JComboBox Index: 4 Name: speedSelect
                   Level: 6 Component: javax.swing.plaf.metal.MetalComboBoxButton Index: 7 Name: null
                   Level: 6 Component: javax.swing.CellRendererPane Index: 4 Name: null
                      Level: 7 Component: javax.swing.plaf.basic.BasicComboBoxRenderer$UIResource Index: 6 Name: null
                Level: 5 Component: javax.swing.JComboBox Index: 5 Name: siteSelect
                   Level: 6 Component: javax.swing.plaf.metal.MetalComboBoxButton Index: 8 Name: null
                   Level: 6 Component: javax.swing.CellRendererPane Index: 5 Name: null
                      Level: 7 Component: javax.swing.plaf.basic.BasicComboBoxRenderer$UIResource Index: 7 Name: null
                Level: 5 Component: javax.swing.JScrollPane Index: 0 Name: null
                   Level: 6 Component: javax.swing.JViewport Index: 0 Name: null
                      Level: 7 Component: javax.swing.JTextArea Index: 4 Name: showText
                   Level: 6 Component: javax.swing.JScrollPane$ScrollBar Index: 0 Name: null
                      Level: 7 Component: javax.swing.plaf.metal.MetalScrollButton Index: 9 Name: null
                      Level: 7 Component: javax.swing.plaf.metal.MetalScrollButton Index: 10 Name: null
                   Level: 6 Component: javax.swing.JScrollPane$ScrollBar Index: 1 Name: null
                      Level: 7 Component: javax.swing.plaf.metal.MetalScrollButton Index: 11 Name: null
                      Level: 7 Component: javax.swing.plaf.metal.MetalScrollButton Index: 12 Name: null

Going down a level and attempting even the most basic interactions with the application results in failure

I don't mind providing more detail if needed. I've been stuck on this problem for ages.

  • Please provide more information. What errors are you seeing? – DarthOpto Mar 08 '18 at 20:41
  • Running Right Click On Component doesn't fail, but instead completes and is considered a pass without the desired outcome. I'm able to read text from it with Get Text Field Value, strangely enough, but asserting that it exists results in Fail: "org/junit/assert". Descending any further than the application window and running something like Right Click On Component results in "Fail: Wait for subcomponent showText to appear" – TheMoreILearnTheLessIKnow Mar 08 '18 at 21:27

1 Answers1

0

I've found the issue.

if (e.isPopupTrigger()) {
            menu.show(e.getComponent(), e.getX(), e.getY());
        }

Javadoc:

Returns whether or not this mouse event is the popup menu trigger event for the platform. 

I think the windows popup menu trigger is different from the one that the robot framework swing library sends. Right clicking on the component passed and did nothing because it did, in fact, pass; it just got negated by the if statement.