Selenium IDE导出到Selenium 2

时间:2013-12-30 13:22:15

标签: php selenium-webdriver

为Selenium 2导出到PHP的Selenium IDE在isElementPresent等简单命令中显示错误。如何解决错误?

这就是我所做的:

安装Phpunit并正常工作 运行Selenium 2 server-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();
}
}

1 个答案:

答案 0 :(得分:0)

尝试重命名你的功能,适合我:)

    public function anOtherTest()
    {
        $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();
    }