Article Overview:
This article will cover how you can achieve the following:
Perform a double-click action on an element using a custom extension when the native mouse double-click NLP is not compatible with the AUT (Application Under Test).
Problem Statement:
If the Native Mouse double-click NLP in Virtuoso is not compatible with the AUT, making it difficult to perform a double-click action during test execution.
Solution:
-
Using Virtuoso's Native Mouse Action NLP: The standard command to perform mouse actions in Virtuoso is:
mouse double click "Element"
If the AUT supports this command, it will execute the double-click action on the specified element. -
Custom Extension for Double Click Action: If the native double-click NLP is incompatible, you can use the following custom JavaScript extension to simulate the double-click action:
function doubleClickElementByXPath(xpath) {
const element = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
if (element) {
const event = new MouseEvent('dblclick', {
bubbles: true,
cancelable: true,
view: window
});
element.dispatchEvent(event);
} else {
console.error('Element not found for the provided XPath.');
}
}
// Usage example:
//const xpath = '//tr//td[text()=" CBRE, Inc. "]'; // Replace with your element's XPath
return doubleClickElementByXPath(xpath)
-
Usage:
- Step 1: Identify the XPath of the element you wish to double-click on.
- Step 2: Pass the XPath into the code using the extension parameter doubleClick (xpath).
-
Step 3: Call the
doubleClick
extension into the journey to perform the double-click action.
Examples:
Here's how the extension looks in the extension manage (here):
Here's how we call the specific extension:
Comments
0 comments
Please sign in to leave a comment.