php - 无法调用具有多个方法参数的命令

标签 php unit-testing selenium phpunit

每次我尝试使用基本的 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/

相关文章:

javascript - 如何处理 webelement is - not attribute id(!) in javascript from selenium-python?

selenium - Protractor 在 AngularJS 之外的可用性

php - mysqli_error() 无法进行转换

php - 如何在我自己的本地 PHP 服务器上造成拒绝服务?

php - 从 5.6 更新 php 7.2 后,MYSLI_QUERY 返回 false 但 MYSQLI_ERROR 未显示错误

php - 您为 Symfony 使用哪个单元测试框架?

swift - 如何在 swift 单元测试中验证方法是否在具体类中被调用

php - zend 框架 2 : How to create action in specific controller in specific action

node.js - 我怎样才能 Jest 用 es6(没有 typescript )模拟 Prisma 客户端?

python - 网络驱动程序异常 : Message: 'geckodriver' executable needs to be in PATH