giorgiosironi / phpunit-selenium

Selenium RC integration for PHPUnit
http://www.phpunit.de/
Other
602 stars 271 forks source link

Tests are not executed #385

Closed burzum closed 7 years ago

burzum commented 7 years ago

I couldn't find any reliable documentation on how to set this up and got all kind of issues with Firefox. Guess it's related to the profile issues that are reported here as well. So I'm using the chrome webdriver. I'm running Windows 10.

My test case

<?php
namespace App\Test\Acceptance;

class UsersTest extends \PHPUnit_Extensions_Selenium2TestCase {

    public function setUp() {
        $this->setHost('localhost');
        $this->setPort(3000);
        $this->setBrowser('chrome');
        $this->setBrowserUrl('http://localhost:3000/');
    }

    public function testLogin() {
        $this->url('/en/login');
        $this->assertContains('Users', $this->title());
    }

}

Result:

C:\xampp\htdocs\wa3 [feature/112-cv +8 ~1 -0 !]
λ .\bin\phpunit .\tests\Acceptance\ -c .\phpunit.xml.dist
PHPUnit 5.4.8 by Sebastian Bergmann and contributors.

S                                                                   1 / 1 (100%)

Time: 4.29 seconds, Memory: 23.25MB

OK, but incomplete, skipped, or risky tests!
Tests: 1, Assertions: 0, Skipped: 1.

Expected result

It is obviously not running the testLogin() method. I've put a die('something') inside the method as well. When I run the test the output is the same as above.

How can I get it to run the actual test cases? Overall there is a huge lack of documentation on how to get all of this working.

giorgiosironi commented 7 years ago

Two things I would check:

burzum commented 7 years ago

I've checked the parent method before and seen it was empty but added the parent call back.

You were right about the server.

1) App\Test\Acceptance\UsersTest::testLogin
BadMethodCallException: The command http://localhost:3000/wd/hub/session is not recognized by the server.

Thought the port was the webserver and changed it to my selenium port (4444).

Now I'm getting this error. I've seen it before on Stackoverflow when I was looking for a solution to my first problem.

I know it's not the fault of phpunit-selenium, but maybe you know a solution to this? I think it could be my setup as well. See https://bugs.chromium.org/p/chromedriver/issues/detail?id=728 as well.

Edit: Solved it thanks to this comment https://github.com/rshf/chromedriver/issues/728#issuecomment-93446962

Feel free to close this issue here. I would just like to make one recommendation: Make this error more obvious so that it doesn't require verbose to immediately see the problem.

Thank you for your help.

C:\xampp\htdocs\wa3 [feature/112-cv +0 ~0 -1 | +9 ~5 -0 !]
λ .\bin\phpunit .\tests\Acceptance\ -c .\phpunit.xml.dist --verbose
PHPUnit 5.4.8 by Sebastian Bergmann and contributors.

Runtime:       PHP 5.6.0 with Xdebug 2.3.3
Configuration: C:\xampp\htdocs\wa3\phpunit.xml.dist

E                                                                   1 / 1 (100%)

Time: 5.16 seconds, Memory: 23.00MB

There was 1 error:

1) App\Test\Acceptance\UsersTest::testLogin
PHPUnit_Extensions_Selenium2TestCase_WebDriverException: <unknown>: Failed to set the 'cookie' property on 'Document': Cookies are disabled inside 'data:' URLs.
  (Session info: chrome=53.0.2785.116)
  (Driver info: chromedriver=2.9.248315,platform=Windows NT 6.3 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 8 milliseconds
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
System info: host: 'Asgard', ip: '192.168.178.24', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.7.0_75'
Session ID: 064166bada721ea6a2c792814e63daaa
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{platform=WIN8_1, acceptSslCerts=true, javascriptEnabled=true, browserName=chrome, chrome={userDataDir=C:\Users\Florian\AppData\Local\Temp\scoped_dir11304_21051}, rotatable=false, locationContextEnabled=true, version=53.0.2785.116, takesHeapSnapshot=true, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=true, browserConnectionEnabled=false, webStorageEnabled=true, nativeEvents=true, applicationCacheEnabled=false, takesScreenshot=true}]

C:\xampp\htdocs\wa3\vendor\phpunit\phpunit-selenium\PHPUnit\Extensions\Selenium2TestCase\Driver.php:165
C:\xampp\htdocs\wa3\vendor\phpunit\phpunit-selenium\PHPUnit\Extensions\Selenium2TestCase\Session\Cookie.php:122
C:\xampp\htdocs\wa3\vendor\phpunit\phpunit-selenium\PHPUnit\Extensions\Selenium2TestCase\Session\Cookie\Builder.php:127
C:\xampp\htdocs\wa3\vendor\phpunit\phpunit-selenium\PHPUnit\Extensions\Selenium2TestCase.php:343
C:\xampp\htdocs\wa3\vendor\phpunit\phpunit-selenium\PHPUnit\Extensions\Selenium2TestCase.php:314

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.