rightClick
Right Clicks the object specified by the locator. If it cannot click or cannot find the object, it throws an error.
Usage in test
To use it in the test, the rightClick.<child_method>('<locator>',propeties<object>)
method is used.
default child_method: xpath
className : Locates elements whose class name contains the search value (compound class names are not permitted)
css : Locates elements matching a CSS selector
id : Locates elements whose ID attribute matches the search value
name : Locates elements whose NAME attribute matches the search value
text : Locates anchor elements whose visible text matches the search value
partialText : Locates anchor elements whose visible text contains the search value. If multiple elements are matching, only the first one will be selected.
linkText : If the element we want to locate is a link, we can use the link text locator to identify it on the web page. Locates anchor elements whose visible text matches the search value
partialLinkText : If the element we want to locate is a link, we can use the link text locator to identify it on the web page. Locates anchor elements whose visible text contains the search value. If multiple elements are matching, only the first one will be selected.
tagName : Locates elements whose tag name matches the search value
xpath : Locates elements matching an XPath expression
Properties:
timeout: <seconds> // defaults: 30 seconds
/* LIBRARIES
*************/
const { sente } = require('#libraries');
const { rightClick } = sente;
/* TEST FLOW
*************/
test = async () => {
// Right Click with xpath
await rightClick('//div[@id="username"]');
// Right Click with xpath
await rightClick.xpath('//*[text()="SENTE IO"]');
// Right Click with id
await rightClick.id('username');
// With timeout Properties:
// If it cannot rightClick or find the object within 10 seconds, it throws an error.
await rightClick.id('username', {timeout: 10});
}
Last updated