1

I'm using squishtest library for manipulating Qt application from my Python code and attempting to use event handlers as follows:

import squishtest


def handle_mouse_event(event):
    print 'Clicked!'


squishtest.startApplication('application')
squishtest.installEventHandler('QMouseEvent', handle_mouse_event)

Unfortunately this doesn't work, i.e. nothing happens on clicking elements inside the app, however it works in case I run equivalent of this code inside the Squish IDE in Squish runtime:

import squish


def handle_mouse_event(event):
    print 'Clicked!'


squish.startApplication('application')
squish.installEventHandler('QMouseEvent', handle_mouse_event)

What is the difference and how to get event handlers working with squishtest?

Python 2.7.14, Squish 6.3.1, Ubuntu 16.04

Vader
  • 3,675
  • 23
  • 40
  • This works for me on Linux and Windows with Squish 6.3.x+, using the Python installation in the Squish package - but admittedly I have added a snooze(5) at the end of the scripts to have some time to "mouse around" over the application's window, then even the mouse movement based events trigger execution of the event handler function. If it still does not work for you I recommend to contact the technical support of froglogic Squish. – frog.ca Mar 05 '18 at 19:39
  • @frog.ca I've used endless loop with `time.sleep` first, but now tried `snooze` instead and it works. Probably sleeps are blocking event loop somehow. You may post your comment as an answer as it probably answers my question. – Vader Mar 06 '18 at 22:40

1 Answers1

0

(Reposting as answer as suggested by original poster.)

This works for me on Linux and Windows with Squish 6.3.x+, using the Python installation in the Squish package - but admittedly I have added a snooze(5) at the end of the script to have some time to "mouse around" over the application's window, then even the mouse movement based events trigger execution of the event handler function.

Another side effect of using snooze() is that the event loops keep being spun, which is not the case when using time.sleep() (which you later mentioned to have used before).

If it still does not work for you I recommend to contact the technical support of froglogic Squish.

frog.ca
  • 684
  • 4
  • 8