Laravel - Browser Tests - Executing Javascript

You may use the script method to execute arbitrary JavaScript statements within the browser:

    
    $browser->script('document.documentElement.scrollTop = 0');
    
    $browser->script([
        'document.body.scrollTop = 0',
        'document.documentElement.scrollTop = 0',
    ]);
    
    $output = $browser->script('return window.location.pathname');