List Icon
Archive de la liste de diffusion

La liste de diffusion est fermée depuis juillet 2022, mais sert toujours d'archive d'informations sur QF-Test.
Cependant, si vous souhaitez rester informé des nouveautés concernant QF-Test, vous pouvez simplement vous abonner à la newsletter :
abonner à la newsletter 


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

Re: [QF-Test] Mouse events with QF-Test


  • Subject: Re: [QF-Test] Mouse events with QF-Test
  • From: Gregor Schmid <Gregor.Schmid@?.de>
  • Date: Fri, 04 Aug 2017 15:16:10 +0200
  • Delivered-to: qftest-list@?.net

Hi Cédric,

that code looks OK but there's one subtle point: I was talking about a
'Server script'. You are using an SUT script because you need to
compute geometry information based on the SUT's component.

However, while the SUT script is running, it is blocking the Event
Dispatch Thread. Normally the events should be processed after the
script finishes, but it might make a difference in your case.

I suggest that you compute x and y coordinates in the SUT script, pass
the values to QF-Test and perform the Robot operations in a server
script as follows.

SUT script:
-----------

from javax.swing import SwingUtilities

robot = Robot()

coordLabelComp = rc.getComponent("<someName>")

comp = rc.getComponent("<someName>")
comp.grabFocus()
# Start on the upper left corner
point = comp.getLocation()
SwingUtilities.convertPointToScreen(point, comp)
        
x = int(point.getX())
y = int(point.getY())
# The following call pushes the values to QF-Test
# as global Jython variables
rc.toServer(x=x, y=y)


Server script:
--------------

from java.awt import Robot

# x and y are automatically available here
robot.mouseMove(x, y)


In case it still fails, please set the option

Run-log->Content->Number of events to log for error diagnosis 

to 1000 and send a run-log to our support.

Best regards,
    Greg


BENHAROUS Cedric <cedric.benharous@?.com> writes:

> Hi all,
>
> We are on the right track.
> First off, we implemented the second solution, as it would be easier to maintain.
>
> To be as precise, we are trying move the mouse inside a component (called "comp") according to the content of a JLabel  (called "coordLabelComp", which contains coordinates of some type).
>
> Here is a Jython snippet :
>
> -------------------------------------------------------
>
> from java.awt import Robot
> from javax.swing import SwingUtilities
> from java.awt.event import InputEvent
>
> robot = Robot()
>
> coordLabelComp = rc.getComponent("<someName>")
>
>         
>         comp = rc.getComponent("<someName>")
>         comp.grabFocus()
>         # Start on the upper left corner
>         point = comp.getLocation()
>         SwingUtilities.convertPointToScreen(point, comp)
>         
>         x = int(point.getX())
>         y = int(point.getY())
>
> robot.mouseMove(x, y)
>
> #Then there is a loopback using robot.mouseMove() with x, y updated with a translation
>
> -------------------------------------------------------
>
> Unfortunately, the JLabel is not refreshed for each mouse movement using the robot, even if grab focus is successful:
> We tried:
>
> robot.mousePress(InputEvent.BUTTON1_MASK)
> robot.mouseRelease(InputEvent.BUTTON1_MASK)
> comp.grabFocus()
>
> Have you an idea concerning the issue regarding the lack of JLabel updates when using Jython mouse moves ?
>
>
> On the other hand, as a short test for the first solution, we tried three QF-Test mouse click, for which the JLabel is correctly updated, but not within a Jython script.
>
>
> Regards,
> Cédric
>
> [@@ THALES GROUP INTERNAL @@]
>
> -----Message d'origine-----
> De : Gregor Schmid [mailto:Gregor.Schmid@?.de] 
> Envoyé : mercredi 2 août 2017 16:23
> À : qftest-list@?.de
> Cc : BENHAROUS Cedric
> Objet : Re: [QF-Test] Mouse events with QF-Test
>
>
> Hello Cedric,
>
> I suggest you try to replay hard MOUSE_MOVED events. Soft events might work as well but that depends on how the mouse coordinates listener is implemented.
>
> To get the event, just record a mouse click, change its event type to MOUSE_MOVED and possibly activate 'Replay as hard event'). Make X and Y coordinate variable and put the event in a procedure.
>
> If you need to use screen coordinates instead of coordinates relative to some target component it may be easier to use a 'Server script'
> based on the AWT Robot. Here's a Jython example:
>
> from java.awt import Robot
> robot = Robot()
> robot.mouseMove(rc.getInt("x"), rc.getInt("y"))
>
> This assumes that you place the script into a procedure with parameters x and y for the screen coordinates.
>
> Best regards,
>     Greg
>
> BENHAROUS Cedric <cedric.benharous@?.com> writes:
>
>> Hi all,
>>
>> We are using QF-Test to test a Java application that is displaying mouse coordinates in a status bar.
>>
>> We would like to be able to move the mouse using QF-Test, at least inside this java application.
>>
>> How can we do this ? Is there any internal QF-Test Jython API for that ?
>>
>> Best regards,
>>
>> Cédric
>>
>> [@@ THALES GROUP INTERNAL @@]
>>
>> _______________________________________________
>> qftest-list mailing list
>> qftest-list@?.de
>> https://movement.qfs.de/mailman/listinfo/qftest-list
>
> --
> Gregor Schmid
>
> E: gregor.schmid@?.de
> T: +49 8171 38648-11
> F: +49 8171 38648-16
>
> Quality First Software GmbH | www.qfs.de Tulpenstr. 41 | 82538 Geretsried | Germany GF Gregor Schmid, Dr. Martina Schmid, Karlheinz Kellerer HRB München 140833
> _______________________________________________
> qftest-list mailing list
> qftest-list@?.de
> https://movement.qfs.de/mailman/listinfo/qftest-list

-- 
Gregor Schmid

E: gregor.schmid@?.de
T: +49 8171 38648-11
F: +49 8171 38648-16

Quality First Software GmbH | www.qfs.de
Tulpenstr. 41 | 82538 Geretsried | Germany
GF Gregor Schmid, Dr. Martina Schmid, Karlheinz Kellerer
HRB München 140833