doumei1908
doumei1908
2010-09-07 10:31
浏览 129
已采纳

如何检查Selenium Server是否正在运行

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条回答 默认 最新

  • douzhanlai4671
    douzhanlai4671 2010-09-07 17:04
    已采纳

    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.

    点赞 评论

相关推荐