LJenkins
LJenkins

Reputation: 11

Squish GUI testing for Java, use windows primary mouse button rather than set mouse button manually?

My workplace uses Squish for testing our Java gui, and I recently had an issue where no tests would run properly on my machine, we eventually worked out that this was due to the fact that I use a left-handed mouse, and on windows have set right-click as my primary mouse button. However our squish setup seems to manually call left click, I'm looking to find a way to make squish respect the primary mouse button as set by windows? We use python as our scripting language for Squish tests.

Any help on this front would be appreciated, its definitely an edge-case, but one that took long enough to solve that we don't want to run into it again.

Upvotes: 1

Views: 330

Answers (1)

Joel Duffie
Joel Duffie

Reputation: 11

I had a similar problem, but Qt doesn't document this very well in the API documentation, which is very annoying. I had to dig through my squish directory to find the answer. I opened the folder in VSCode and did a search for "primaryButton". I found a file called mouseconstants.def (at SQUISH_DIR/sdk/common), inside which I found multiple mouse buttons defined as integers. Each is set to a power of 2, which I suppose makes sense, as I believe they're reading the mouseButton parameter as a byte, so each button is associated with a specific bit flag. Nevertheless, here are the values:

SQUISH_CONSTANT(LeftButton, 1)
SQUISH_CONSTANT(MiddleButton, 2)
SQUISH_CONSTANT(RightButton, 4)
SQUISH_CONSTANT(Wheel, 8)
SQUISH_CONSTANT(PrimaryButton, 16)
SQUISH_CONSTANT(SecondaryButton, 32)
SQUISH_CONSTANT(XButton1, 64)
SQUISH_CONSTANT(XButton2, 128)

To solve your problem, I would try to use 16 whenever you need a primary ("left") button, and 32 whenever you need a secondary ("right") click.

This may only work on Windows, as there's this note on Squish's API:

Note: Windows test suites also support two more possible mouse button specifiers, MouseButton.PrimaryButton and MouseButton.SecondaryButton. These values respect the global Windows setting used to swap the mouse buttons. If the buttons are not swapped (the default), the left button is the primary button. Otherwise, the right button is the primary button.

Upvotes: 1

Related Questions