Can start ChromeDriver within CLI tool but won't allow connections - laravel

I'm using Laravel homestead and I'm writing a little artisan command line tool that I need to browse my site with javascript execution.
I run dusk test regularly with no difficulty, so I thought I would use Laravel's tools for this script.
I started out by running this early in my script:
\Laravel\Dusk\TestCase::startChromeDriver();
This started the driver fine running on port 9515 running as user vagrant (default homestead user)
But when I tried to access it (also from within the script) I would get an error:
Failed to connect to localhost port 9515: Connection refused
If I instead started it manually on the command line:
$ ./vendor/laravel/dusk/bin/chromedriver-linux --port=9515
The driver started fine again running on port 9515 as user vagrant, but this time my tool runs fine.
But I really want to be able to start the ChromeDriver from within the tool. So I also tried:
$process = new \Symfony\Component\Process\Process('./vendor/laravel/dusk/bin/chromedriver-linux --port=9515');
$process->start();
Connection was refused again.
Any idea why this works when I start it from the command line but not within my artisan command?

I can't explain why this makes a difference but it has. If I launch the driver with the full path:
/home/vagrant/Code/mysite/vendor/laravel/dusk/bin/chromedriver-linux --port=8888
all works fine now.

Related

cannot run commands in tinkerwell over ssh connection (laravel)

Tinker works just fine when I am ssh'd into my box, but I cannot get it to work in tinkerwell.
I'm trying to connect to my local vagrant box with tinkerwell. It is a vagrant box running in windows: ubuntu 20, laravel 5.7, php7.3.33. Tinkerwell 2.25 in Windows 10. I can connect over ssh, but it errors out whenever I run any command:
In Shell.php line 79:
Argument 1 passed to _PhpScoperc223a629f245\Psy\Shell::add() must be
an ins tance of
_PhpScoperc223a629f245\Symfony\Component\Console\Command\Command, instance of Psy\Command\ParseCommand given, called in
phar:///tmp/vagrant_t
inker.phar/vendor/symfony/console/Application.php on line 316
I get the same error whenever I try to run any command. On google I found a thread where someone had the same issue, except they were not connecting over ssh, they were on a mac, and the thread had no resolution in it (https://github.com/beyondcode/tinkerwell-community/issues/215).
I have checked that the correct version of php is in my $PATH, so the default path of php for the php executable that tinkerwell picks seems correct. I have also tried specifying /usr/bin/php but it doesn't change anything.

Cannot run styleguidist along side with laravel development server

I am trying to document my React Components and I am running styleguidist server along side with Laravel development server but the styleguidist server crashes with this error.
You have another server running at port 6060 somewhere, shut it down first
You can change the port using the `serverPort` option in your style guide config:
https://react-styleguidist.js.org/docs/configuration.html
I have configured the styleguidist server to run at port 6060 as to resolve this issue and succeeded to run the server only once. After that I am getting this issue again.
How can i resolve this??
The error is saying you have something else running at that port. Have you tried a different one? If you are running a UNIX system, you can see what is running on that port with:
lsof -i tcp:6060

Running dusk tests on Homestead for Windows

I'm using homestead on windows 10 and installed laravel 5.4 when I'm trying to run dusk tests I get the following error:
1) Tests\Feature\ViewProductListingTest::user_can_view_product_listing
Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session with params: {"desiredCapabilities":{"browserName":"chrome","platform":"ANY"}}
Failed to connect to localhost port 9515: Connection refused
Has anybody had any luck getting around this?
Thanx.
I encountered this very problem today. I spent like 2 hours researching and finally resolved it by following the steps posted on this comment.
I ran the original basic test and it passed. I'll try to run more complex test and hopefully the solution still works.
It seems to me that the Homestead lacks some necessary software(Chrome, xvfb etc.) to run browser tests with Laravel Dusk. That's what that comment is trying to install.
Hope this helps!
I ran into this issue before and was not able to completely resolve it.
The connection refused error occured for me because the execution scripts for dusk in /vendor/laravel/dusk/bin were not set executable inside Homestead.
So i used a chmod 777 on those scripts.
After that it complained that if couldn't find an executable chrome binary, so i installed google-chrome in Homestead.
After I installed google chrome, the tests ran, but timed out before they could finish which i am researching now.
I ran into the same issue (but I'm on macOS Sierra). If you can, instead of running Dusk from the Homestead VM, run it from your host machine. Just make sure the DB_HOST value in your .env file is set to the hostname you use to access the site in your browser.
So for example, if you configured the Homestead site to be accessible at mycoolsite.app, use that as your DB_HOST value.
I know this is more of a workaround for situations where your host machine might be able to run it OK, but it's working for me at the moment if you can give it a try.

Screen freezes on connecting to mongodb in Windows 10

I was trying to set up mongo server on Windows 10.
It looked like everything alright and the service was listening on 27017.
However on another command prompt, mongo failed to connect and the screen just froze as follow
I've checked the firewall rule, port 27017 is open. And ping 127.0.0.1 is responding.
Any idea why the connection would get stuck?
Try running mongo.exe with verbose mode
c:\mongodb\bin>mongo.exe --verbose
This will help you diagnose this further.
I have just got this situation.
Solution: Edit mongo configuration
mongodb.conf
linux: sudo nano /etc/mongodb.conf
and disable auth=true. Then restart mongo server service.
linux: sudo service mongodb restart
Incorrect config authentication steps lead to this hanging in mongo shell.
After that, config following this link: https://medium.com/#matteocontrini/how-to-setup-auth-in-mongodb-3-0-properly-86b60aeef7e8
Then re-enable auth=true

To run selenium server

When I try to run server(rc) in command prompt it is saying it is already used. So, I run the server in 5555 and changed the same in script. However, it still shows
WARN - Failed to start: SocketListener0#0.0.0.0:4444
Have you tried to stop the server using the below link?
http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer
Just open the above link in the browser you are using to run the tests.
After the opening the above link, the selenium server stops.
Then you can proceed with starting the server from port 4444.
Close the browser that is running on port 4444 and then restart the selenium server
I had the same problem,
type this instead
webdriver-manager --seleniumPort 4455 start
it will start it on port 4455 (you can try different numbers as well)

Resources