Laravel - Browser Tests - Waiting For Selectors

The waitFor method may be used to pause the execution of the test until the element matching the given CSS or Dusk selector is displayed on the page. By default, this will pause the test for a maximum of five seconds before throwing an exception. If necessary, you may pass a custom timeout threshold as the second argument to the method:

    
    // Wait a maximum of five seconds for the selector...
    $browser->waitFor('.selector');
    
    // Wait a maximum of one second for the selector...
    $browser->waitFor('.selector', 1);
	

You may also wait until the element matching the given selector contains the given text:

    
    // Wait a maximum of five seconds for the selector to contain the given text...
    $browser->waitForTextIn('.selector', 'Hello World');
    
    // Wait a maximum of one second for the selector to contain the given text...
    $browser->waitForTextIn('.selector', 'Hello World', 1);
	

You may also wait until the element matching the given selector is missing from the page:

    
    // Wait a maximum of five seconds until the selector is missing...
    $browser->waitUntilMissing('.selector');
    
    // Wait a maximum of one second until the selector is missing...
    $browser->waitUntilMissing('.selector', 1);
	

Or, you may wait until the element matching the given selector is enabled or disabled:

    
    // Wait a maximum of five seconds until the selector is enabled...
    $browser->waitUntilEnabled('.selector');
    
    // Wait a maximum of one second until the selector is enabled...
    $browser->waitUntilEnabled('.selector', 1);
    
    // Wait a maximum of five seconds until the selector is disabled...
    $browser->waitUntilDisabled('.selector');
    
    // Wait a maximum of one second until the selector is disabled...
    $browser->waitUntilDisabled('.selector', 1);