Form field not found when executing feature file in Behat with Selenium

2.5k Views Asked by At

I'm running a Behat feature file where I try to select an option in a form field

When I select "Lisa Hayes" from "settings_custom[Counselor][]"

where "Lisa Hayes" is one of the values in form name "settings_custom[Counselor][]". The element details are as follows:

<select id="settings_customCounselor" name="settings_custom[Counselor][]" multiple="multiple" size="4" class="valid">
<option value="" selected="">(does not matter)</option>
<option value="685572">Lisa Hayes</option>
<option value="685573">Ricky Hunter</option>
<option value="685574">Max Sterling</option></select>

I get an error when I execute the feature file on the command line

Form field with id|name|label|value "settings_custom[Counselor][]" not found.

My default driver is selenium2 (I have selenium-server-standalone-2.32.0.jar server running in the background and my browser is firefox).

Note that this works perfectly when I change my default driver to goutte (headless) from selenium (web driver).

I tried to search this forum and Googled for any specifics and did not find any helpful information.

Let me know if you need more information. Thanks!

1

There are 1 best solutions below

0
On

I just solved the issue.

The problem was not with the syntax on the feature. The step before the statement

When I select "Lisa Hayes" from "settings_custom[Counselor][]"

was for some reason not loading the correct page. Thus the step definition could not find the element.

I tried to replace the statement to go directly to the page where the form was and implemented a wait statement to ensure all elements load

And I am on "some URL"
And I wait "2000"
When I select "Lisa Hayes" from "settings_custom[Counselor][]"
...

This now works.