How to check whether Selenium Server is running

送分小仙女□ 提交于 2020-01-03 12:11:50

问题


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?


回答1:


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 dont 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.



来源:https://stackoverflow.com/questions/3657803/how-to-check-whether-selenium-server-is-running

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!