5

Every time I attempt to use one of the basic PHPUnit Selenium assertions, the tests errors out and displays this message:

Exception: You cannot call a command with multiple method arguments.

On http://phpunit.de/manual/3.7/en/selenium.html, it shows the usage to be:

void assertElementValueEquals(string $locator, string $text)

Be when I call it with

$this->assertElementValueEquals( 'id=date_1_formatted', '2013-01-01' );

the test produces the above error every time even though this same format seems to be working for others such as in the question Using PHPUnit with Selenium, how can I test that an element contains exactly something?

4

2 回答 2

3

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());

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

于 2013-11-01T09:34:23.693 回答
0

也走进了这个,就我而言,这是我自己的自定义方法,所以我认为这是一条线。
原来我在测试类和 phpunit 之间使用的“缓冲区”类与我想象的不同。但是因为它使用了很多 __call(),所以它给了 ↑ 那个错误而不是“未定义的方法”。

于 2016-11-01T12:59:44.387 回答