如何检查Selenium Server是否正在运行 [英] How to check whether Selenium Server is running

查看:191
本文介绍了如何检查Selenium Server是否正在运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一堆phpunit测试,其中一部分使用硒,并且我需要知道硒服务器是否正在运行(Windows).有没有办法从php检查它?

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?

推荐答案

默认情况下,Selenium服务器在本地主机端口4444上接受命令

By default Selenium server accepts commands on localhost port 4444

所以您可以这样做:

<?php
$selenium_running = false;

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

var_dump($selenium_running);

我个人不喜欢使用@,但是fsockopen坚持在连接失败时抛出PHP通知.在输出甚至日志文件中出现此警告只是令人讨厌.

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.

这篇关于如何检查Selenium Server是否正在运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆