php - 执行脚本一段时间后出现 "Could not connect to the Selenium RC server"

标签 php selenium phpunit selenium-rc

我的测试类中有一个测试用例,并且存在一些问题。我从控制台运行脚本。 脚本执行到某个点,然后测试失败并出现错误:

Could not connect to the Selenium RC server.

这是来自控制台的日志:

PHPUnit 3.5.15 by Sebastian Bergmann.

E

Time: 01:56, Memory: 4.00Mb

There was 1 error:

1) someTest::testSomething
PHPUnit_Framework_Exception: Could not connect to the Selenium RC server.

/var/www/path.../someTest.php:105

FAILURES!
Tests: 1, Assertions: 0, Errors: 1.

我的测试脚本中的第 105 行:

$this->clickAndWait("//a[text()='Next']");

这是 Selenium 日志:

14:00:40.983 INFO - Command request: click[//a[text()='Next'], ] on session 4222e17607254f41a6a52e13d0fd7cc5
14:00:41.205 INFO - Got result: OK on session 4222e17607254f41a6a52e13d0fd7cc5
14:00:41.207 INFO - Command request: waitForPageToLoad[600000000, ] on session 4222e17607254f41a6a52e13d0fd7cc5
14:02:11.328 INFO - Command request: testComplete[, ] on session 4222e17607254f41a6a52e13d0fd7cc5
14:02:11.328 INFO - Killing Firefox...
14:02:11.506 INFO - Got result: ERROR: Got a null result on session 4222e17607254f41a6a52e13d0fd7cc5
14:02:11.508 INFO - Got result: OK on session

我尝试使用 Selenium Server Standalone 2.19.0,然后使用 2.20.0 - 相同的结果。

即使在测试中断后,服务器仍在运行。

我的问题是: 为什么这个错误突然发生并意外中断了脚本?


PHPUnit 3.5.15
Selenium 服务器独立版 2.19.0 和 2.20.0
火狐浏览器 3.6.18
Ubuntu 10.04

最佳答案

尝试使用 $this->click("link=Next"); 这背后的原因是,当 selenium 尝试查找文本并且页面未完全加载或存在不明确的文本时,selenium 会抛出它并显示“无法连接到 Selenium RC 服务器”。文本的验证/断言有时会产生问题。

关于php - 执行脚本一段时间后出现 "Could not connect to the Selenium RC server",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9602826/

相关文章:

configuration - PHPUnit:仅过滤一个测试套件

php - 将数组转换为 JSON 字符串 php

php - SQL 查询仅从字符串列中获取第一个单词

PHP - 在类中定义常量

java - 如何使用 maven-jar-plugin 创建带有 .class 文件的测试 jar?

php - 无法调用具有多个方法参数的命令

php - 模拟 Eloquent 模型

php - 缓存所有查询

java - 如何循环浏览 webdriver 中的条形图元素?

java - Java 中的通用 FindElement 方法