Here is how I created automatic test for Anki's user interface. Those tricks may potentially be useful potentially for other (py)Qt project.