dusk: $browser->dump() always returns empty or blank html content

I have the same problem as this person: https://stackoverflow.com/questions/46868606/get-laravel-dusk-to-run-properly-on-ubuntu-16-wt-laravel-5-5

        $this->browse(function (Browser $browser) {
            $browser->visit('/')
                ->dump()
            ;
        });

this returns "<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body></body></html>"

That HTML is not generated by any of my blade files and it is affecting all my URLs.

None of my assertions will work because dusk is getting that instead of my app.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 8
  • Comments: 27 (8 by maintainers)

Most upvoted comments

Indeed, this is probably due to invalid SSL certificates.

If you are running Chrome 65+ and Chrome Driver 2.35+ you can add the following in DuskTestCase:

->setCapability('acceptInsecureCerts', true)

It should do the trick

also you can comment ‘–headless’ and add ‘–ignore-certificate-errors’, in tests/DuskTestCase.php after in visit method use full url. I investigate this case and edit my response later

I was getting an empty HTML response when using selenium/standalone-chrome with a Docker service called selenium. I had to modify the driver() function to the following:

/**
 * Create the RemoteWebDriver instance.
 *
 * @return \Facebook\WebDriver\Remote\RemoteWebDriver
 */
protected function driver()
{
    $options = (new ChromeOptions)->addArguments([
        '--headless',
        '--disable-gpu',
        '--no-sandbox',
        '--ignore-certificate-errors',
    ]);

    return RemoteWebDriver::create(
        env('DUSK_BROWSER_URL', 'http://localhost:9515'),
        DesiredCapabilities::chrome()->setCapability(ChromeOptions::CAPABILITY, $options)
            ->setCapability(WebDriverCapabilityType::ACCEPT_SSL_CERTS, true)
            ->setCapability('acceptInsecureCerts', true)
    );
}

where DUSK_BROWSER_URL=http://selenium:4444/wd/hub on my .env.dusk.local

It was the correct path from my .env file. After changing the https:// to http://, it started returning results from my application.

APP_URL=http://dusk.myapp.com
BASE_URL=http://dusk.myapp.com

It looks like dusk silently breaks on SSL errors?

I was also facing the same issue and get it resolved by starting my server using “php artisan serve” command and changed value of APP_URL in .env.dusk.local file to the url returned after starting server. Hope this will help someone.

SSH to your homestead machine:

sudo su
nano /etc/hosts

Add

192.161.10.15    mysite.local

where 192.161.10.15 is the ip address defined in Homestead.yaml file and mysite.local is your local url.

@clemblanco Faced with the same issue. But your fix didn’t work. Here is my docker-compose.yml:

selenium:
    image: selenium/standalone-chrome
    depends_on:
      - app
    links:
      - app:app.test
    volumes:
      - /dev/shm:/dev/shm
    networks:
     - app-network

Update: My mistake. Just should use the correct URL during testing. Just change url to http://NAME_OF_CONTAINER_WHERE_NGINX_PLACED

In my case I’ve changed:

...
    links:
      - nginx:app.test
...

If you look at the value of $url in this line: https://github.com/laravel/dusk/blob/3.0/src/Browser.php#L136 Is it the correct URL to your site?

Are you running Laravel in Homestead?

Does it work with a site like https://google.com?