Question

I have the following input field generated by symfony:

<input type="text" id="my_project_localebundle_citytype_name" 
name="my_project_localebundle_citytype[name]" required="required" 
maxlength="45" class="text">

And I am writing my scenario like this:

  @javascript
  Scenario: Add a city
    Given I follow "Locales"
    And I follow "Add city"
    Then I fill in "name" with "Testing 1 2 3"
    ...

However the field can't be found

 Form field with id|name|label|value "name" not found.

I know I could put my complete id or name but It's too long and I want to keep it, Is there any way easier to fill it in my scenario without editing my input?

Was it helpful?

Solution

What I understood with gherkin is, it shows what's wrong with our design and UX. And if we can't tell the program what field fill, how a human could he?

Also the main purpose of your scenario is not to fill the form but add a city. So you should change Then by And on the line Then I fill in "name" with "Testing 1 2 3".

On the other side, you can simply add a specific validation method and keep a readable feature, something like :

And I fill the city's creation form field with "Testing 1 2 3"

Then in your context :

/**
 * @Given /^I fill the city's creation form field with "([^"]*)"$/
 */
public function fillCitysCreationForm($arg1)
{
    $this->fillField('my_project_localebundle_citytype_name', $arg1);
}

PS: I didn't test the previous code, you may have to improve it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top