XClick (target, click type), XMove (target, mouse event)

The XClick and the XMove commands allows you to send real user mouse clicks to web page elements. The advantage of this approach is that the web app reacts 100% the same way as if a real human user executes this click. In contrast the standard Selenium IDE Click and ClickAt commands operate on the Javascript level inside the browser DOM, and can sometimesr require dedicated debugging and tweaking to make them work (e. g. finding the right locator) or they can fail completely on complex websites, as the website logic swallows the click event and does not send it to right element. XClick avoids all these problems by simulating a real user.

The XClick, XMove and XType command need the RealUser XModules to be installed. And please note that the RealUser module requires n unlocked user desktop to simulate events - no real human user can work with a locked desktop either.

What is the difference between XClick/XMove and the Selenium IDE Click and ClickAt commands?

The classic Click commands as used by Kantu and any other Selenium IDE or browser automation tool do not simulate real mouse clicks! Instead they operate on the Javascript level inside the browser DOM. This the reason why these commands all first require a locator to identify a web page element, and then send a Javascript mouseclick event to this element. On simple websites this is often enough and works well. But on modern complex websites (e. g. Google Gmail, Google Spreadsheet, Microsoft Office 365, Facebook, Instagram,...) it is often difficult to find the right element locator in the first place. And even if you found the right locator, it can happen that the website logic swallows the Javascript click event event and it never reaches the target right element. In contrast the XClick and XMove commands avoid all these problems by simulating a real user click and mouse events.


Example of a web app click that fails with the standard CLICK command, but works just fine with XCLICK. Note that the same locator is used in both cases.

This sounds great, so why would one use the classic Click or ClickAt command at all?

Well, the real user commands XClick and XMove have one drawback: As they simulate real user input, they require an unlocked user desktop to simulate events, and the browser window has to be in the foreground. This is just the same requirement that you would have for a real human operator - no human can click on something if the desktop has been locked. Here the classic click/clickAt commands wins: They work just fine with the browser in the background and/or hidden, as everything happens just inside the web browser.

So for standard websites we recommend to first test if the classic Click command works. If it works, great. And if not, you have XClick in your toolbox. It will work for sure!

How to test canvas elements?

Automating websites with canvas elements (e. g. drawing apps like Sketchpad.io and most online games) using the ClickAt command could work, but it is impossible to find a XPath or CSS locator for ClickAt inside the canvas element. The best solution for canvas test automation is to use Kantu's computer vision image search. It searches visually for the image (e.g. a button image) that you want to click. For more details about image-driven test automation, see the Visual UI Testing page. Kantu's computer vision plus XClick/XMove/XType can automate everything inside canvas elements. More about using images as locator in the next paragraph below.

XClick and XMove "Locator" options - Computer vision, XPath or X/Y

The locator input tells the command the location on the browser viewport where to send the native click and move events.

"Locator" for XClick/XMove Comment
(xpath or ID) XClick can work with a normal page element locator, exactly the same one as you would use for the standard Click or Type commands. In this case Kantu locates the element, runs element.getBoundingClientRect() and then sends a click event to the center of the rectangle.
image@conf.Level XClick can use images as input! - this works exactly the same way as with other visual commands like visualAssert. This is the easiest method to locate places to click, as it works 100% image-driven. Kantu's built-in computer vision finds the image in the browser viewport and then sends a click event to the center of the image.
x,y The raw way to send clicks by using x/y coordinates is also available. This can be useful if you know or can calculate the exact x/y position. For example, you can first do an image search, then calculate the coordinates as offset to this initial position.

XClick Click types

XClick can simulate all kinds of mouse clicks.

Click event command Comment
„“ (empty) or #left Standard left mouse click
#doubleclick Simulates double-click of the left mouse button
#middle Simulates click of the middle mouse button
#right Simulates a mouse right-click. Typically this is used to bring up the context menu.

XMove Mouse events

XMove simulates mouse events. For simulating mouse clicks, use XClick.

Click event command Comment
„“ (empty) or #move Simulates mouse move events. A move over an element also triggers the mouse over effect.
#up Simulates mouse up event of the left mouse button
#down Simulates mouse down event of the left mouse button

XClick Example

(This page is work in progress. You find a full example in the Demo-XClick that gets installed with Kantu.)

Command Target Pattern/Text
open https://a9t9.com/
XClick button.png #doubleclick
echo done

Works in

Kantu for Chrome and Kantu for Firefox with the XRealUser module installed.

The XType, XClick and XMove need the RealUser Simulation XModule to be installed.

Related Demo Macros

Demo-XClick

The ready-to-import-and-run source code of all demo macros can be found in the Github repository testmacros folder.

See also

XMove, XType, XModules User Manual

Real User's problem where Real User simulation is the answer

As inspiration of what can be with the XClick, XMove and XType commands, we compiled an interesting list of web automation feature requests that we received from users over the last months before the release of the RealUser XModule. Now, all of these tasks can automated with the RealUser XModule.

How do I press "Ctrl C" and "Ctrl V" for copy and paste? It says can't find element - I'm trying to target cells on an excel sheet in google sheets and they don't have unique identifiers so I need to target "by coordinates" and then submit copy and paste WITHOUT caring what element i'm "sending" to.

I was trying to automate actions at https://www.ibm.com/... (URL removed) and would click on main documentation navigation headings (on the left) but the system couldn't detect when the AJAX response finished so it could verify an element. In retrospect I think it wasn't detecting the frame I was accessing.

It can't detect bootstrap modal.

Didn't work in Google Slides: I tried to record changing color and it didn't record anything except opening Google Slides (when it was already open)

I wanted to record click/drag operations in screen space, not on page elements. Kantu does not appear to support this.

add either the ability to send control keys or run an extension

I want mouseMove, mouseDown, mouseUp, keyboard events and timeline to record use cases for debugging purposes

Selenium IDE failed on my tests with our website (SPA, multiple frames). The error message was "can't access dead object"

compatibility with arrow, command/control etc. keys

In the website I'm testing, most links are accessed by hovering over a menu and then a submenu. When re-running a recorded macro, it failed after a time-out period when the link did not appear (because it did not perform the hover).

Probably outside the scope of the program, I'm looking for something with position based clicking rather than dom targeting.

flash support?

looked like it worked but didn't actually activate buttons within gmail app to delete emails. Nothing appeard in the Trash folder??

Add the possibility to handle the closing of the actual tab.

I needed to click on an icon extension, but it did not work

When the website is created with Angular JS, the widgets change dynamically so the IDs of the elements change and Kantu is not able to see the elements.

doubleclick not supported,

it doesnt work on calendars year navigation,

Don't record angular webs

I need it to simulate all mouse movements not just controls being clicked or text boxes being filled

All of this can be done now - so if one if these questions is similar to yours, and you are not sure how to solve it, please ask in our forum.

Anything wrong or missing on this page? Suggestions?

...then please contact us.

Subscribe to the a9t9 automation software newsletter . We'll send you updates on new releases that we're working on.