Search code examples
phpunit-testingacceptance-testingcodeception

seeInField finds the element, while fillField doesn't - CodeCeption


I am totally new to CodeCeption. I have the below html inside the body,

<div><input type="text" name="content_id" id="contentId" maxlength="10" value="123"></div>

In CodeCeption acceptance test I have a this below code

`<?php 
$I = new AcceptanceTester($scenario);
$I->wantTo('fillfield test');
$I->amOnPage('/');
$I->seeInField('#contentId', 123);
$I->fillField('#contentId', 222397);
?>`

seeInField Test passes successfully, but fillField throws an error

Sorry, I couldn't fill field "#contentId", 222397
InvalidArgumentException: The current node list is empty

This stops me to proceed further. Help me out on this.


Solution

  • Finally got answer to my own question. I used PhpBrowser module for testing, it won't allow the user to fill fields which are not inside the form. And other stuffs they mentioned in the Docs are,

    Common PhpBrowser drawbacks:

    1. You can click only on links with valid urls or form submit buttons
    2. You can't fill fields that are not inside a form
    3. You can't work with JavaScript interactions: modal windows, datepickers, etc.,