Juliatzin del Toro Juliatzin del Toro - 2 months ago 12
PHP Question

functional testing with select id in laravel 5.4

In my form, I have several select, all the same name, but different Ids.

<form method="POST" action="/"
accept-charset="UTF-8">
<select name="directElimination_fighters[]" class=directElimination_select id="1_1">
<option selected></option>
<option value="1639"> Esteban Prohaska </option>
<option value="1640"> Vicenta Walsh </option>
</select>
<select name="directElimination_fighters[]" class=directElimination_select id="1_2">
<option selected></option>
<option value="1639"> Esteban Prohaska </option>
<option value="1640"> Vicenta Walsh </option>
</select>

<button type="submit" class="btn btn-success" id="update">
Update
</button>
</form>


I'm making my functional tests, so I do :

$this->visit('/')
->select('Esteban Prohaska', '1_2')
->press('update');


But PHPUnit says:

InvalidArgumentException: Unreachable field "1_2"


When I add
->dump()
, I can see in HTML the id="1_2" field. So what's wrong with my code???

Answer Source

Change it to:

->select('#1_2', '1639')