Skip to content
This repository was archived by the owner on Aug 7, 2019. It is now read-only.
This repository was archived by the owner on Aug 7, 2019. It is now read-only.

Input field should be focused when typing, even if typing an empty string #18

@thompsnm

Description

@thompsnm

In one of our projects, we have a scenario that looks like this:

Scenario: Input Invalid Information
  Given I go to the "Login" page
  When I type "" in the "User Name" field
    And I type "1234" in the "Pass Code" field
    And I click the "Submit" button
  Then the "Username Required Red Error Box" should be displayed

The intent of this scenario is to ensure that an error appears for the User Name field if no value is entered. We recently updated the business logic so that the error will appear on blur events. This scenario works for that situation on OS X, but it fails when run on Windows. It appears that this is because WebDriver doesn't alway focus on an input on Windows if an empty string is sent, so no blur event is triggered as focus shifts in later steps.

The 'When I type "**" in the "**" field' step should always focus on the element, even if no string is typed. This can be done by adding a call to click on the element in the Step Definition:

@When /^I type "([^"]*)" in(?:to)? the "([^"]*)" field$/, (text, fieldName, callback) ->
  field = @transform.stringToVariableName(fieldName + 'Field')
  @currentPage[field].click()
  @currentPage[field].clear()
  @currentPage[field].sendKeys(text).then ->
    callback()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions