【发布时间】:2013-02-10 16:28:17
【问题描述】:
我正在使用PHPUnit_Selenium 扩展,如果元素不存在,我会遇到一些不需要的行为:
硒测试用例:
$this->type('id=search', $searchTerm);
测试输出:
RuntimeException: 在 'http: 访问 Selenium 服务器时响应无效: //localhost:4444/selenium-server/driver/': ERROR: Element id=search not 找到了
所以,我收到一个错误,但我想将其转换为失败
我考虑过这个:
try {
$this->type('id=search', $searchTerm);
} catch (RuntimeException $e) {
$this->fail($e->getMessage());
}
但我真的不想将所有运行时异常都转换为失败,也没有找到一种清晰的方法来区分它们。
额外的断言会很棒,但我找不到适合我需要的断言。比如:
$this->assertLocatorExists('id=search'); // ???
$this->type('id=search', $searchTerm);
我错过了什么吗?还是有其他我没有想到的方法?
使用过的版本:
- PHPUnit 3.7.14
- PHPUnit_Selenium 1.2.12
- 硒服务器 2.30.0
【问题讨论】:
标签: php testing selenium phpunit selenium-webdriver