write

Sends data to input or a similar keyboard input object.

Usage in test

To use it in the test, the write.<child_method>('<locator>',<keys>, 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 { write, keyboard } = sente;


/* TEST FLOW
*************/
test = async () => {
   
   // Write with xpath
   await write('//input[@id="username"], 'selcuk_surer'); 
   
   // Write with xpath
   await write.xpath('//input[@id="username"]' , 'selcuk_surer'); 
   
   // Write with id
   await write.id('username','selcuk_surer'); 
   
   // Write and Push ENTER button
   await write.id('username',['selcuk_surer', keyboard.ENTER]);    
   
   // With timeout Properties: 
   await write.id('username', ['selcuk_surer', keyboard.ENTER], {timeout: 10}); 
   
   // Send Multikey
   await write('//body', [keyboard.DOWN, keyboard.END, keyboard.CANCEL] );

        
}

Keyboard Properties

usage keyboard.<properties_key>

Sample
keyboard.ENTER
keyboard.META
keyboard.ESCAPE 
... etc.
All Keyboard Key
    NULL:         '\uE000',
    CANCEL:       '\uE001',  // ^break
    HELP:         '\uE002',
    BACK_SPACE:   '\uE003',
    TAB:          '\uE004',
    CLEAR:        '\uE005',
    RETURN:       '\uE006',
    ENTER:        '\uE007',
    SHIFT:        '\uE008',
    CONTROL:      '\uE009',
    ALT:          '\uE00A',
    PAUSE:        '\uE00B',
    ESCAPE:       '\uE00C',
    SPACE:        '\uE00D',
    PAGE_UP:      '\uE00E',
    PAGE_DOWN:    '\uE00F',
    END:          '\uE010',
    HOME:         '\uE011',
    ARROW_LEFT:   '\uE012',
    LEFT:         '\uE012',
    ARROW_UP:     '\uE013',
    UP:           '\uE013',
    ARROW_RIGHT:  '\uE014',
    RIGHT:        '\uE014',
    ARROW_DOWN:   '\uE015',
    DOWN:         '\uE015',
    INSERT:       '\uE016',
    DELETE:       '\uE017',
    SEMICOLON:    '\uE018',
    EQUALS:       '\uE019',

    NUMPAD0:      '\uE01A',  
    NUMPAD1:      '\uE01B',
    NUMPAD2:      '\uE01C',
    NUMPAD3:      '\uE01D',
    NUMPAD4:      '\uE01E',
    NUMPAD5:      '\uE01F',
    NUMPAD6:      '\uE020',
    NUMPAD7:      '\uE021',
    NUMPAD8:      '\uE022',
    NUMPAD9:      '\uE023',
    MULTIPLY:     '\uE024',
    ADD:          '\uE025',
    SEPARATOR:    '\uE026',
    SUBTRACT:     '\uE027',
    DECIMAL:      '\uE028',
    DIVIDE:       '\uE029',

    F1:           '\uE031',  // function keys
    F2:           '\uE032',
    F3:           '\uE033',
    F4:           '\uE034',
    F5:           '\uE035',
    F6:           '\uE036',
    F7:           '\uE037',
    F8:           '\uE038',
    F9:           '\uE039',
    F10:          '\uE03A',
    F11:          '\uE03B',
    F12:          '\uE03C',

    COMMAND:      '\uE03D',  // Apple command key
    META:         '\uE03D',  // alias for Windows key

Last updated