I'm following examples from the book PHPUnit Essentials by Zdenek Machek and I'm on the section about functional tests using Selenium.
I already downloaded the server, the webdrivers and the firefox IDE.
The test class exported by Firefox IDE:
class SeleniumFirstTest extends PHPUnit_Extensions_Selenium2TestCase {
protected function setUp() {
$this->setBrowser('firefox');
$this->setHost('127.0.0.1');
$this->setPort(4444);
$this->setBrowserUrl('https://www.google.com.br/');
}
public function testCasephp()
{
$this->url("/?gws_rd=ssl");
$this->byId("lst-ib")->value("phpunit");
$this->byLinkText("Documentation")->click();
$this->byLinkText("13. PHPUnit and Selenium")->click();
$result = $this->byCssSelector("h1.title")->text();
$this->assertEquals("Chapter 13. PHPUnit and Selenium", $result);
}
}
When I try to run the tests in NetBeans I get the following output:
"C:\bin\phpunit.bat" "--colors" "--log-junit" "C:\Users\MARCOS~1.PRA\AppData\Local\Temp
b-phpunit-log.xml" "--configuration" "C:\WebServer\Apache 2.2\htdocs\DataBaseTests\tests\phpunit.xml" "C:\Program Files\NetBeans 8.0.2\php\phpunit\NetBeansSuite.php" "--run=C:\WebServer\Apache 2.2\htdocs\DataBaseTests\tests"
PHPUnit 4.5.0 by Sebastian Bergmann and contributors.
Configuration read from C:\WebServer\Apache 2.2\htdocs\DataBaseTests\tests\phpunit.xml
E......
Time: 25.44 seconds, Memory: 5.75Mb
There was 1 error:
1) SeleniumFirstTest::testCasephp
Argument 1 passed to PHPUnit_Extensions_Selenium2TestCase_Element::fromResponseValue() must be of the type array, null given, called in C:\WebServer\Apache 2.2\htdocs\DataBaseTests\vendor\phpunit\phpunit-selenium\PHPUnit\Extensions\Selenium2TestCase\Element\Accessor.php on line 136 and defined
C:\WebServer\Apache 2.2\htdocs\DataBaseTests\tests\Marco\Test\Functional\SeleniumFirstTest.php:26
C:\WebServer\Apache 2.2\htdocs\DataBaseTests\tests\Marco\Test\Functional\SeleniumFirstTest.php:26
C:\Dev\PHPUnitTest\vendor\phpunit\phpunit\src\TextUI\Command.php:152
C:\Dev\PHPUnitTest\vendor\phpunit\phpunit\src\TextUI\Command.php:104
FAILURES!
Tests: 7, Assertions: 14, Errors: 1.
Generating code coverage report in HTML format ...teste done
Done.
I can't understand why the test is failing, considering it passes when executed on the Firefox IDE.
May someone help me to understand this?
Thanks