HTML5 Geolocation Testing with Cucumber


  @javascript
  Scenario: User is geolocalized
    When I go to the home page page
    And I share my location and it returns "41.8954656,12.4823243"
    Then I should see a "Location found at: 41.8954656, 12.4823243" message
  $.location = {
    // window.geolocation_provider is useful for testing purposes, not used in
    // development/staging/production envs.
    geolocation_provider: window.geolocation_provider || navigator.geolocation
  }

   // usage:
  $.location.geolocation_provider.getCurrentLocation(successCallback, errorCallback)
// simplified code
var state = null;

function getCurrentPosition( success, error, options ) {
  if( state == 'timeout' )
    simulateTimeoutError();
}
# Cucumber step
page.execute_script "state = 'timeout';"

Luca Guidi

Family man, software architect, Open Source indie developer, speaker.

Rome, Italy https://lucaguidi.com