每次我尝试使用基本的 PHPUnit Selenium 断言之一时,测试都会出错并显示此消息:
Exception: You cannot call a command with multiple method arguments.
关于 http://phpunit.de/manual/3.7/en/selenium.html , 它显示用法为:
void assertElementValueEquals(string $locator, string $text)
当我调用它时是
$this->assertElementValueEquals( 'id=date_1_formatted', '2013-01-01' );
测试每次都会产生上述错误,即使这种相同的格式似乎适用于其他格式,例如在问题 Using PHPUnit with Selenium, how can I test that an element contains exactly something? 中
最佳答案
assertElementValueEquals 未在 Selenium2TestCase 中实现。在您的链接中,它提到了 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());
P. S.:如果您熟悉 Selenium IDE,可以试试这个 command line tool .
关于php - 无法调用具有多个方法参数的命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19364072/