How can I assert that the field is not empty using Codeception / PhantomJS?

I have a form that, when filled in and clicked, returns a list of zip codes in a hidden field. I want to assert that the field list is complete. However, I would not want to validate field values ​​against any particular list, allowing future census or postal information changes. How can I just assert that the field is not empty using the Codeception WebDriver? I tried to use

$set_zips = $I->grabValueFrom('#zips');
$this->assertFalse(empty($set_zips));

      

and

$I->cantSeeInField('#zips', '')`

      

but couldn't verify this even if the field is indeed filled.

+3


source to share


1 answer


I was able to create a helper to accomplish this:

function dontSeeFieldIsEmpty($value)
{
    $this->assertFalse(empty($value));
}

      



I put this in tests/_support/AcceptanceHelper.php

and named it in my Cest:

$I->dontSeeFieldIsEmpty($I->grabValueFrom('#set_zips'));

      

+3


source







All Articles