How to check if Selenium Server is running

I have a phpunit test suite, some of which are used by selenium, and I need to know if the selenium server is running or not (windows). Is there any way to check this with php?

+4
source share
1 answer

By default, the Selenium server accepts commands on the local host 4444

So you can do this:

<?php $selenium_running = false; $fp = @fsockopen('localhost', 4444); if ($fp !== false) { $selenium_running = true; fclose($fp); } var_dump($selenium_running); 

I personally don't like using @, but fsockopen insists on throwing a PHP notification when the connection fails. The presence of this warning in the output, or even in the log file, is simply annoying.

+6
source

All Articles