Show List

Double click, right click, and hover actions

Here's a sample TestCafe test script that demonstrates working with double click, right click, and hover actions:


import { Selector } from 'testcafe'; fixture('Mouse Actions Test') .page('https://www.example.com'); test('Perform Mouse Actions', async t => { // Selectors for elements to perform mouse actions on const doubleClickElement = Selector('.double-click'); const rightClickElement = Selector('.right-click'); const hoverElement = Selector('.hover'); // Perform double click await t.doubleClick(doubleClickElement); // Perform right click await t.rightClick(rightClickElement); // Perform hover action await t.hover(hoverElement); });

In this test:

  • We import the Selector function from TestCafe to select elements on the web page.
  • We define a fixture named 'Mouse Actions Test' and set the page to 'https://www.example.com'.
  • Inside the test function, we define selectors for elements on the page that we want to perform mouse actions on (replace .double-click, .right-click, and .hover with appropriate selectors for your web page).
  • We use TestCafe's doubleClick, rightClick, and hover actions to perform double click, right click, and hover actions respectively on the selected elements.

Make sure to replace 'https://www.example.com' with the URL of the website you want to test, and adjust the selectors accordingly based on the structure of the webpage you are testing. Additionally, ensure that the elements you are trying to interact with have appropriate classes or attributes for selection.


    Leave a Comment


  • captcha text