简体   繁体   中英

Using Qt Event Handlers in squishtest

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, ie 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

(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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM