Menu
Choose a product
Viewing: v1.7.x (latest)
Find another version
Scroll for more
Open source
Mouse
Mouse provides a way to interact with a virtual mouse.
| Method | Description |
|---|---|
| click(x, y[, options]) | Mouse clicks on the x and y coordinates. |
| dblclick(x, y[, options]) | Mouse double clicks on the x and y coordinates. |
| down([options]) | Dispatches a mousedown event on the mouse’s current position. |
| up([options]) | Dispatches a mouseup event on the mouse’s current position. |
| move(x, y[, options]) | Dispatches a mousemove event on the mouse’s current position. |
Example
JavaScript
import { browser } from 'k6/browser';
export const options = {
scenarios: {
ui: {
executor: 'shared-iterations',
options: {
browser: {
type: 'chromium',
},
},
},
}
}
export default async function () {
const page = await browser.newPage();
await page.goto('https://test.k6.io/', {
waitUntil: 'networkidle'
});
// Obtain ElementHandle for news link and navigate to it
// by clicking in the 'a' element's bounding box
const newsLinkBox = await page.$('a[href="/news.php"]');
const boundingBox = await newsLinkBox.boundingBox();
const x = newsLinkBox.x + newsLinkBox.width / 2; // center of the box
const y = newsLinkBox.y;
await page.mouse.click(x, y);
await page.close();
}Was this page helpful?
Related resources from Grafana Labs
Additional helpful documentation, links, and articles:
Video

Performance testing and observability in Grafana Cloud
Optimize user experiences with Grafana Cloud. Learn real-time insights, performance testing with k6, and continuous validation with Synthetic Monitoring.
Events

User-centered observability: load testing, real user monitoring, and synthetics
Learn how to use load testing, synthetic monitoring, and real user monitoring (RUM) to understand end users' experience of your apps. Watch on demand.