I'm trying to create acceptance tests to work with reactJS. I first got Codeception running fine then added react. Thats when I noticed that codeception doesn't have JS enabled. I've tried adding phantomJS: same problem. Since I can't debug phantomJS, I decided to try selenium so I can see it run in firefox. I've been working on this for days and Codeception refuses to open firefox like a normal selenium test.
Things your gonna ask:
- Yes, I run codecept build
after every change.
- Yes I have java -jar selenium-server-standalone-2.48.0.jar
running. Though that doesn't matter. There is no difference in the test whether I have it running or not.
- Yes I've tried $I->waitForElement('#whatever')
. After like 20 seconds it dies.
- No, I have to use laravel
Here's my configuration:
acceptance.suite.yml
class_name: AcceptanceTester
modules:
enabled:
- WebDriver:
url: 'http://eagle.app/'
browser: firefox #This does nothing. I literally changed it to `fart` and it didn't error. just same failed tests due to no JS
window_size: 1024x768
capabilities:
webStorageEnabled: true
javascriptEnabled: true
firefox_binary: /Applications/Firefox.app
- \Helper\Acceptance
/tests/acceptance/AuthCest.php
<?php
//use \AcceptanceTester;
class AuthCest
{
public function _before(AcceptanceTester $I)
{
}
public function _after(AcceptanceTester $I)
{
}
// tests
public function register(AcceptanceTester $I)
{
// This should open firefox/selenium
$I->executeInSelenium(function (Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) {
$handles=$webdriver->getWindowHandles();
$last_window = end($handles);
$webdriver->switchTo()->window($last_window);
});
// This is my original test. I realize its not in executeInSelenium()
// but I'm just showing you what works in non-SPA laravel apps (which doesn't work for me)
$I->switchToWindow();
$I->am('an anonymous user');
$I->wantTo('Register');
$I->amOnPage('/');
$I->wait(1);
$I->see('Laravel 5'); #this is where it dies with react
$I->click('REGISTER');
$I->fillField(['name' => 'name'], 'testuser');
$I->fillField(['name' => 'email'], 'test@user.com');
$I->fillField(['name' => 'password'], 'testuserpass');
$I->fillField(['name' => 'password_confirmation'], 'testuserpass');
$I->click('Register', '#content form');
$I->see('LOG OUT');
$I->click('LOG OUT');
$I->see('REGISTER');
$I->click('LOG IN');
$I->fillField(['name' => 'email'], 'test@user.com');
$I->fillField(['name' => 'password'], 'testuserpass');
$I->click('Login', '#content form');
$I->see('LOG OUT');
}
}
codeception.yml
actor: Tester
paths:
tests: tests
log: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
settings:
bootstrap: _bootstrap.php
colors: true
memory_limit: 1024M
extensions:
enabled:
- Codeception\Extension\RunFailed
- Codeception\Extension\Recorder