Skip to content
This repository has been 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

Open
thompsnm opened this issue Jul 6, 2015 · 0 comments
Labels

Comments

@thompsnm
Copy link
Contributor

thompsnm commented Jul 6, 2015

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()
@thompsnm thompsnm added the bug label Dec 7, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant