How to perform a mouse click on a certain position

150 views
Skip to first unread message

GerhardH

unread,
Feb 25, 2011, 9:25:38 AM2/25/11
to robotframework-users
Hello all,

I run a local Java application, where I can access almost all GUI
objects via SwingLibrary.

Now I want to perform a click on a table header cell (to sort the
table by the clicked column). But SwingLibrary does not support this.
So I try to implement that in my own Java library.

Also in Jemmy lib I did not find a method that directly supports a
click on a table header cell. But I found a class
org.netbeans.jemmy.drivers.MouseDriver which provides a method
clickMouse. The documentation to that class is rather poor, and my
first trials failed with ...

I assume I will be able to calculate the position of the header cell,
but I need to pass a ComponentOperator object. I assume that I created
the wrong object here.

Can anyone describe me how to use that clickMouse method? How do I
have to create this ComponentOperator? The other parameters seem to be
clear. Is there any trick besides the right ComponentOperator?

Any hint is welcome, thanks in advance.

Best regards
Gerhard

Janne Härkönen

unread,
Mar 1, 2011, 3:33:16 AM3/1/11
to gerhard....@nsn.com, robotframework-users
Hello Gerhard,

On Fri, Feb 25, 2011 at 4:25 PM, GerhardH <gerhard....@nsn.com> wrote:
> Now I want to perform a click on a table header cell (to sort the
> table by the clicked column). But SwingLibrary does not support this.

I found out that Jemmy supports getting coordinates of a table header
column via JTableHeaderOperator. I created an enhancement request for
SwingLibrary about this [1]

[1] http://code.google.com/p/robotframework-swinglibrary/issues/detail?id=184

thanks,
--J

--
Janne Härkönen | http://reaktor.fi
http://twitter.com/#!/janneharkonen

Heil, Gerhard (EXT-Other - FI/Tampere)

unread,
Mar 1, 2011, 8:59:23 AM3/1/11
to ext Janne Härkönen, robotframework-users
Hello,

I just solved it by implementing my own Java keyword, but only for this special application, so it is only a workaround. I loop through all the components and subcomponents to find the JTableHeader object; from that object I call getLocationOnScreen and from the columns getWidth. So I can calculate the position to click.

With these values I call mouseMove of class java.awt.Robot and then mousePress and mouseRelease.

Using mouseClick from jemmylibs MouseDriver always crashed, with not helpful exception text.

Best regards
Gerhard

Reply all
Reply to author
Forward
0 new messages