Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codecept Hidden field

Tags:

codeception

My Form contain a hidden field csrf and my Controller has a method to check CSRF attack. In my functional test, I tried by fillField to check my Controller's method redirect to specific page if someone temper form. I read somewhere that codecept works only with visible field.

Is there is any way that I can fill a hidden field in `functional` or `acceptance` test?

like image 568
Fazal Rasel Avatar asked Apr 27 '26 14:04

Fazal Rasel


2 Answers

This is the only system which worked for me :

$I->executeJS('$(".yourMethodClass").val("YOUR_VALUE_HERE");'); 

Of course u can call it by ID or any javascript selectors u want.

like image 167
Riccardo De Leo Avatar answered Apr 30 '26 05:04

Riccardo De Leo


You can use fillField for hidden inputs. I use it in my tests and it works just fine, it properly fills value of hidden input.

$I->fillField(['name' => 'email'], 'some email');
$I->fillField(['name' => 'password'], 'myPassword');

$I->fillField('privilegesList','read'); //this is hidden input
$I->click('submit button');
like image 37
Matěj Račinský Avatar answered Apr 30 '26 04:04

Matěj Račinský