【发布时间】:2014-06-02 16:16:04
【问题描述】:
Selenium IDE 导出到 PHP for Selenium 2 会在 isElementPresent 等简单命令中显示错误。如何修复错误?
这就是我所做的:
安装并运行 Phpunit 运行 Selenium 2 服务器-selenium-server-standalone-2.39.0.jar 使用 selenium IDE 2.4.0 记录测试用例 将测试用例导出到 php 文件。 (我使用了这个格式化程序:https://github.com/suzuki/PHP-Formatter-PHPUnit_Selenium2) 使用phpunit执行测试。
问题是格式化程序输出错误,因为它找不到 isElementPresent。 这是错误:
ERROR: Caught exception [TypeError: WDAPI.Utils.isElementPresent is not a function]
这是格式化程序的输出:
class Test2 extends PHPUnit_Extensions_Selenium2TestCase
{
/**
* Setup
*/
public function setUp()
{
$this->setBrowser('firefox');
$this->setHost('127.0.0.1');
$this->setPort(4444);
$this->setBrowserUrl('http://mydomain.com/');
}
/**
* Method test2
* @test
*/
public function test2()
{
$this->url("/dvp/index.php?option=com_binja&controller=csinfo&task=loginThenFetchMoreItemsForFranchise&franchiseId=1&itemId=56&poiId=");
// ERROR: Caught exception [TypeError: WDAPI.Utils.isElementPresent is not a function]
$this->assertTrue($this->byXPath("//*[@id='authorize']")->displayed());
$this->byId("binjaEnteredZip")->value("01945");
$this->byId("btnZipSubmit")->click();
}
}
【问题讨论】:
-
看来你的phpunit环境有问题。尝试更新它。