Issue
I have bunch of phpunit tests, part of them using selenium, and i need to know wheteher selenium server is running or not (windows). Is there way to check it from php?
Solution
By default, Selenium server accepts commands on localhost port 4444.
So you could do this:
<?php
$selenium_running = false;
$fp = @fsockopen('localhost', 4444);
if ($fp !== false) {
$selenium_running = true;
fclose($fp);
}
var_dump($selenium_running);
I don't personally like using @
, but fsockopen
insists on throwing a PHP notice, when the connection fails. Having this warning in output or even in log file is just annoying.
Answered By - Anti Veeranna
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.