Laravel - Browser Tests - Javascript Dialogs

Dusk provides various methods to interact with JavaScript Dialogs. For example, you may use the waitForDialog method to wait for a JavaScript dialog to appear. This method accepts an optional argument indicating how many seconds to wait for the dialog to appear:

    
    $browser->waitForDialog($seconds = null);
	

The assertDialogOpened method may be used to assert that a dialog has been displayed and contains the given message:

    
    $browser->assertDialogOpened('Dialog message');
	

If the JavaScript dialog contains a prompt, you may use the typeInDialog method to type a value into the prompt:

    
    $browser->typeInDialog('Hello World');
	

To close an open JavaScript dialog by clicking the "OK" button, you may invoke the acceptDialog method:

    
    $browser->acceptDialog();
	

To close an open JavaScript dialog by clicking the "Cancel" button, you may invoke the dismissDialog method:

    
    $browser->dismissDialog();