Laravel - Browser Tests - Pressing Buttons
The press
method may be used to click a button element on the page. The first argument given to the press
method may be either the display text of the button or a CSS / Dusk selector:
$browser->press('Login');
When submitting forms, many application's disable the form's submission button after it is pressed and then re-enable the button when the form submission's HTTP request is complete. To press a button and wait for the button to be re-enabled, you may use the pressAndWaitFor
method:
// Press the button and wait a maximum of 5 seconds for it to be enabled...
$browser->pressAndWaitFor('Save');
// Press the button and wait a maximum of 1 second for it to be enabled...
$browser->pressAndWaitFor('Save', 1);