see

Returns the object specified by locator. If the object does not exist, it throws an error.

Usage in test

To use it in the test, the see.<child_method>('<locator>',propeties<object>) method is used.

default child_method: xpath

Child Methods:
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
tests/sample1.js
/* LIBRARIES
*************/
const { sente } = require('#libraries');
const { see } = sente;


/* TEST FLOW
*************/
test = async () => {
   
   // Search with xpath
   await see('//div[@id="username"]'); 
   
   // Search with xpath
   await see.xpath('//*[text()="SENTE IO"]'); 
   
   // Search with id
   await see.id('username'); 
   
   // With timeout Properties: 
   // If it cannot find the object within 10 seconds, it throws an error.
   await see.id('username', {timeout: 10}); 

        
}

Last updated