Cypress Test - Google Places Autocomplete not functioning

Viewed 3116

I am trying to use Cypress as a testing tool for an Angular website I am working on. One of the tests is for a location search, which uses the google places service to autocomplete locations. Functioning correctly, it looks like in the picture below:

functioning autocomplete

However, in cypress testing, the autocomplete element does not appear, so a location cannot be chosen to proceed with the search. The test is firing the methods that it should to make it appear, but it does not. It will appear if I manually type in the cypress browser as well.

Does anyone know what may be causing this?

3 Answers

I had this issue, i had to slow the speed of the typing down.

One approach would be:

cy.get("input[data-name=autocomplete]")
  .type("AUTOCOMPLETE DATA")
  .wait(2000)
  .type("{enter}")
  .wait(500);

This allows time for the autocomplete to load the data from wherever it needs and then you can use .type("{enter}") to select the first element.

Related