JTabbedPane doesn't react to clicks when running tests

118 views
Skip to first unread message

viev

unread,
Aug 12, 2013, 9:39:16 AM8/12/13
to marathon...@googlegroups.com
Hi,

I'm using multiple JTabbedPanes in my application and i don't seem to get them functioning properly as test.

First of all, if i click directly on the label of a tab, marathon notes:
click('lbl:Control')
This however has no effect when running the test. It appears that the JLabel which is the tab label doesn't forward the event. This happens when custom JLabels as tab "heads" are set as well as when the tab just gets a string as name.

If i click next to the label but still on the same element, marathon reports
select('leftComponent', 'Control')
, which does actually change the tab. However i'm doing additional stuff on tab change (actually before the change) via listening for mousePressed-events on the tabbed pane. These events seem to not actually get forwarded.

Is it possible that some events which should be forwarded are just not? Is there anything i could try to make this work?
 
regards,
viev

Dakshinamurthy Karra

unread,
Aug 12, 2013, 12:18:43 PM8/12/13
to marathon...@googlegroups.com
Try recording in raw mode and see that helps.

-- KD



--
Looking for professional help with your Marathon projects?
Go visit: http://marathontesting.com
---
You received this message because you are subscribed to the Google Groups "Marathon Java GUI Testing" group.
To unsubscribe from this group and stop receiving emails from it, send an email to marathon-testi...@googlegroups.com.
To post to this group, send email to marathon...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

viev

unread,
Aug 13, 2013, 5:33:44 AM8/13/13
to marathon...@googlegroups.com
With raw mode, i get something like
click('lbl:Geometry', 137, 23)
and next to the label
click('plaf.basic.BasicTabbedPaneUI$TabContainer_1', 154, 9)
, but still no luck, the tabs aren't changed.

However i now realised that my second observation was wrong, the entries
select('leftComponent', 'Control')
actually do cause a tab change and are usually also recorded in combination with the click(lbl:..) events. The select-events are however not recorded in raw mode, so nothing happens there.

So the only real problem left are the missing mousePressed events of the JTabbedPane if the corresponding label is clicked via click().

Is there anything else i can try about that?

Dakshinamurthy Karra

unread,
Aug 13, 2013, 6:10:40 AM8/13/13
to marathon...@googlegroups.com
Only solution is to manually modify the script to include both the select() and click().

-- KD

viev

unread,
Aug 13, 2013, 2:52:26 PM8/13/13
to marathon...@googlegroups.com
Ok, but then i still don't get the mousePressed-events on the JTabbedPane when a click (or select) to the corresponding JLabel of the tab is made. What could i perhaps try about that?

Dakshinamurthy Karra

unread,
Aug 14, 2013, 12:18:01 AM8/14/13
to marathon...@googlegroups.com
When a click on JLabel is performed, Marathon generates pressed/clicked/release events. They should propagate to JTabbedPane if not handled by the label.

-- KD

Dakshinamurthy Karra

unread,
Aug 14, 2013, 2:40:57 AM8/14/13
to marathon...@googlegroups.com
In raw mode, marathon records keystrokes/mouse clicks rather than the select() calls. You select this option while recording from the control center window.

-- KD



On Wed, Aug 14, 2013 at 12:06 PM, subhash dhaka <dhaka...@gmail.com> wrote:
what is this RAW mode in marathon?

Thanks,
Subhash

viev

unread,
Aug 14, 2013, 4:12:15 AM8/14/13
to marathon...@googlegroups.com
Yes, that's what i'd like to happen, but somehow the events don't arrive at the JTabbedPane. Is there some way to debug it and see what happens with the event?

Dakshinamurthy Karra

unread,
Aug 14, 2013, 4:52:16 AM8/14/13
to marathon...@googlegroups.com
Get the marathon sources, setup a eclipse project, use remote launcher to start the application by changing Marathon configuration etc.

Too complicated.. why don't you just add some logging?

-- KD

viev

unread,
Aug 14, 2013, 8:29:17 AM8/14/13
to marathon...@googlegroups.com
I kind of tried that, but i only found out that mousePressed isn't called for the JTabbedPane listener. However i noticed also that if i add a listener to the JLabel, the JTabbedPane stops receiving events, also in a regular run of the program. The first answer of this stackoverflow question appears to explain that behaviour:

http://stackoverflow.com/questions/3087521/jpanel-does-not-generate-mouseevents-when-cursor-is-on-child-components

So if marathon adds a listener to the JLabel, it would explain the behaviour. Does it do that?

If not, i'm kind of out of ideas about what to still check or log..

Dakshinamurthy Karra

unread,
Aug 14, 2013, 12:34:32 PM8/14/13
to marathon...@googlegroups.com
Marathon hooks on to eventqueue using Toolkit#addAWTListener - I do not find it interfering it with normal flow. Can you try click() on the tabbed pane itself with coordinates and see how it goes?

-- KD

viev

unread,
Aug 14, 2013, 6:45:02 PM8/14/13
to marathon...@googlegroups.com
Ok, when not in raw mode, i get something like the following and it has the same effect as with the label. I.e. on click(), nothing happens (also no reaction to mouseClicked or mousePressed on the JTabbedPane), and select() changes the tab without any further events.

click('plaf.basic.BasicTabbedPaneUI$TabContainer_0', 86, 35)
select('leftComponent', 'Grids')

 With raw mode enabled, the select()-calls are missing and nothing at all happens.

Dakshinamurthy Karra

unread,
Aug 15, 2013, 2:42:47 AM8/15/13
to marathon...@googlegroups.com
The name for the tabbedPane doesn't seem right. Can you try inserting an assertion on tabbedPane and see what name it records and use it?

-- KD

viev

unread,
Aug 15, 2013, 4:28:42 AM8/15/13
to marathon...@googlegroups.com
It seems consistent with what is recorded, at least that's what i get from what is shown on the screenshots.
scrot.png
scrot2.png

Dakshinamurthy Karra

unread,
Aug 15, 2013, 6:01:30 AM8/15/13
to marathon...@googlegroups.com
Try control+clicking on different parts of the tabbed pane. I suspect the tabComponent is imposed over the tabbedPane and Marathon is recognizing only the tabComponent. Once you create/find the name for the component - use it in the click()

-- KD

viev

unread,
Aug 16, 2013, 9:38:37 AM8/16/13
to marathon...@googlegroups.com
There are no other clickable things besides the two elements from the screenshots, i think i've tried everywhere.

The ctrl-click-dialog shows that BasicTabbedPaneUI$TabContainer_0 has the actual tabbed pane, i guess that's about right..

Dakshinamurthy Karra

unread,
Aug 16, 2013, 10:20:10 AM8/16/13
to marathon...@googlegroups.com
The itemCount in the assertions window should show the number of tabs. What is the entry for BasicTabbedPaneUI$
TabContainer_0 in the objectmap file?

-- KD

viev

unread,
Aug 16, 2013, 10:34:20 AM8/16/13
to marathon...@googlegroups.com
Do you mean this part of omap/ApplicationName_4393811198943780164.yaml ?

- !!net.sourceforge.marathon.objectmap.OMapComponent
    componentRecognitionProperties:
    - {method: equals, name: type, value: plaf.basic.BasicTabbedPaneUI$TabContainer}
    - {method: equals, name: indexOfType, value: '0'}
    generalProperties:
    - {name: position, value: '[x=2151,y=184]'}
    - {name: type, value: plaf.basic.BasicTabbedPaneUI$TabContainer}
    - {name: enabled, value: 'true'}
    - {name: instanceOf, value: javax.swing.plaf.basic.BasicTabbedPaneUI$TabContainer}
    - {name: size, value: '[width=976,height=42]'}
    - {name: indexOfType, value: '0'}
    - {name: component.class.simpleName, value: TabContainer}
    - {name: component.class.name, value: javax.swing.plaf.basic.BasicTabbedPaneUI$TabContainer}
    name: plaf.basic.BasicTabbedPaneUI$TabContainer_0


There is no itemCount in any of the .yaml-files there, in case that means anything.
Reply all
Reply to author
Forward
0 new messages