简体   繁体   中英

Laravel Dusk is throwing up error

This is my test function

$this->browse(
    function (Browser $browser)
    {
        $browser->visit('/')->clickLink('Login')->value('#mobile', '9790772695')->value('#password', 'password')->check('remember')->click('#login')->assertPathIs('/dashboard');
        for ($i = 0; $i < 1024; $i++) {
            $browser->visit('/invoice/new')->assertPathIs('/invoice/new')->select('#ClientName');
            $browser->driver->executeScript('window.scrollTo(0, 100);');
            $browser->pause(1000)->check('#autoins')->keys('#item_1', 'freak')->keys('.qty', '1')->select('#invoiceStatus', 'paid')->value('#grand', 1251)->value('#amountPaid', 1251)->value('#amountPaid', 1251)->value('#amountDue', 0);
            $browser->driver->executeScript('window.scrollTo(0, 1000);');
            $browser->click('.invoice-save-btn')->pause(3000);
        }
    });

This is the error

1) Tests\\Browser\\InvoiceTest::testExample ErrorException: array_rand(): Array is empty

C:\\xampp\\htdocs\\agashtyav1\\vendor\\laravel\\dusk\\src\\Concerns\\InteractsWithElemen>ts.php:201 C:\\xampp\\htdocs\\agashtyav1\\tests\\Browser\\InvoiceTest.php:23 C:\\xampp\\htdocs\\agashtyav1\\vendor\\laravel\\dusk\\src\\TestCase.php:91 C:\\xampp\\htdocs\\agashtyav1\\tests\\Browser\\InvoiceTest.php:29

What is weird is that I don't get any errors if I remove the

->select('#ClientName');

command on line 23.

The issue is solved. The problem was not with dusk, but with a controller function which populates the drop down list

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM