Skip to content

Instantly share code, notes, and snippets.

Last active December 17, 2015 13:10
What would you like to do?
Codeception Laravel4 module issue. Line 7 makes this fail for me. It only responds to the label's body. Not name or id of the input. 20 second video example:
$I = new TestGuy($scenario);
$I->wantTo('register for a new account');
$I->see('Register', 'h1');
$I->fillField('email', '');
$I->fillField('Password:', 'password');
<!doctype html>
<meta charset=utf-8>
{{ Form::open() }}
{{ Form::label('email', 'Email:') }}
{{ Form::text('email') }}
{{ Form::label('password', 'Password:') }}
{{ Form::text('password') }}
{{ Form::submit('Register') }}
{{ Form::close() }}
Copy link

It's ok. To match element by ID you should use CSS selector, or XPath locator.
Basically, smth like this:


$I = new TestGuy($scenario);
$I->wantTo('perform actions and see result');
$I->see('All Posts');
$I->click('Add new post');
$I->fillField('#title', 'Hello world again');
$I->fillField('#body', 'And greetings for all');
$I->see('All Posts');
$I->see('Hello world');

At first element is searched by label/text/etc (depending on element). There are pretty complex XPath locators in Mink and BrowserKit to guess the proper element. But if they fail Codeception retries with matching by CSS. If CSS matching fails, Codeception tries to use it as XPath.

Bruteforce that works:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment