Laravel - Browser Tests - Typing Values

Dusk provides a variety of methods for interacting with forms and input elements. First, let's take a look at an example of typing text into an input field:

    
    $browser->type('email', '[email protected]');
	

Note that, although the method accepts one if necessary, we are not required to pass a CSS selector into the type method. If a CSS selector is not provided, Dusk will search for an input or textarea field with the given name attribute.

To append text to a field without clearing its content, you may use the append method:

    
    $browser->type('tags', 'foo')
            ->append('tags', ', bar, baz');
	

You may clear the value of an input using the clear method:

    
    $browser->clear('email');
	

You can instruct Dusk to type slowly using the typeSlowly method. By default, Dusk will pause for 100 milliseconds between key presses. To customize the amount of time between key presses, you may pass the appropriate number of milliseconds as the third argument to the method:

    
    $browser->typeSlowly('mobile', '+1 (202) 555-5555');
    
    $browser->typeSlowly('mobile', '+1 (202) 555-5555', 300);
	

You may use the appendSlowly method to append text slowly:

    
    $browser->type('tags', 'foo')
            ->appendSlowly('tags', ', bar, baz');