无法使用多个方法参数调用命令

jak*_*sen 5 php selenium phpunit unit-testing

每次我尝试使用一个基本的PHPUnit Selenium断言时,测试都会出错并显示以下消息:

Exception: You cannot call a command with multiple method arguments.
Run Code Online (Sandbox Code Playgroud)

http://phpunit.de/manual/3.7/en/selenium.html上,它显示的用法是:

void assertElementValueEquals(string $locator, string $text)
Run Code Online (Sandbox Code Playgroud)

当我打电话给它时

$this->assertElementValueEquals( 'id=date_1_formatted', '2013-01-01' );
Run Code Online (Sandbox Code Playgroud)

每次测试都会产生上述错误,即使同样的格式似乎适用于其他人,例如在使用PHPUnit和Selenium的问题中,我如何测试元素是否包含某些内容?

rNi*_*Nix 3

Selenium2TestCase中未实现assertElementValueEquals。在您的链接上提到了SeleniumTestCase(Selenium RC 版本)。

此外,您使用了 $this->byXPath 的正确结构,如下所示https://github.com/sebastianbergmann/phpunit-selenium/blob/master/Tests/Selenium2TestCaseTest.php

您也可以使用$this->byId()

$element = $this->byId('date_1_formatted');
$this->assertEquals('2013-01-01', $element->value());
Run Code Online (Sandbox Code Playgroud)

PS:如果你熟悉Selenium IDE,你可以尝试这个命令行工具