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.
Does it work with a site like https://google.com?
$this->browse(function ($browser) {
$browser->visit('http://google.com/');
$browser->dump();
});
This returns a large HTML document (that is probably the expected result).
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?
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?
It's working?
Yes
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
It completely frozes the execution after I add '--ignore-certificate-errors' or
->setCapability('acceptInsecureCerts', true) definitely getting all from http://google.com
also app url on Browser class is correct. This is really annoying :(
What Chrome and ChromeDriver versions are you using?
I'm encountering exactly the same problem with the latest version of ChromeDriver (2.39)
Sounds like a problem caused by the ChromeDriver, not by Dusk.
@staudenmeir I'm sorry, how can I check this versions? I tried installing a fresh application and dusk works fine on a fresh laravel install. The app I am having issues with is a Laravel app upgraded to 5.6 from 5.5 coming all the way from 5.1, however no issues with the application at all on my browser or postman. I have ensured all is the same with the fresh installed application but no luck.
Run chromium-browser --version and vendor/laravel/dusk/bin/chromedriver-linux --v via SSH.
chromium-browser --version outputs this:
Chromium 66.0.3359.181 Built on Ubuntu , running on Ubuntu 18.04
and vendor/laravel/dusk/bin/chromedriver-linux --v outputs:
ChromeDriver 2.35.528139 (47ead77cb35ad2a9a83248b292151462a66cd881)
Thanks so much for the help!
Just wanted to clarify this had nothing to do with laravel dusk. I needed to add the site within laravel homested machine via the /etc/hosts file.
I'm having the same problem, however no suggest solution works for me.
This is how I build the driver:
$capabilities = DesiredCapabilities::chrome();
$chromeOptions = (new ChromeOptions())->addArguments(['headless', 'disable-gpu', 'no-sandbox', 'ignore-certificate-errors']);
$capabilities->setCapability(ChromeOptions::CAPABILITY, $chromeOptions);
$capabilities->setCapability(WebDriverCapabilityType::ACCEPT_SSL_CERTS, true);
$capabilities->setCapability('acceptInsecureCerts', true);
return RemoteWebDriver::create(
'http://localhost:9515', $capabilities
);
I started chromedriver with --verbose option, and I found this in output:
[3.072][DEBUG]: DEVTOOLS EVENT Log.entryAdded {
"entry": {
"level": "error",
"networkRequestId": "2530.1",
"source": "network",
"text": "Failed to load resource: net::ERR_CONNECTION_REFUSED",
"timestamp": 1535474446968.75,
"url": "https://www.mytestdomain/"
}
}
However, from within the docker container I can do this:
curl -k https://www.mytestdomain/ - I receive correct result.
Any suggestions?
@prolic What version of Dusk are you using?
v4.0
On Wed, Aug 29, 2018, 08:05 Jonas Staudenmeir notifications@github.com
wrote:
@prolic https://github.com/prolic What version of Dusk are you using?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/laravel/dusk/issues/480#issuecomment-416779667, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAYEvASvhyOl4vYmieliuwTEc8kwVh_Eks5uVdrigaJpZM4SjbWP
.
What do you mean by "I started chromedriver with --verbose option"? Did you start it manually?
Yes, tried to start manually.
Today I switched to docker container selenium/standalone-chrome - working perfectly fine out of the box.
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.
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
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.
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
Thanks a lot!!! this helped me
Hello all,
I installed new project and laravel /dusk when i run the php artisan dusk it always shows this i use the ubuntu 14.04 and tell me how to use chromium in place of chrome:
TypeError: Argument 1 passed to Facebook\WebDriver\Remote\DesiredCapabilities::__construct() must be of the type array, null given,
And Thanks to all Supporters!!!!!
@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
...
Most helpful comment
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:It should do the trick