question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cypress should fire 'mouseover' event on .click()

See original GitHub issue

Current behavior:

Unable to click on the first suggestion from google place auto complete

Video: https://drive.google.com/open?id=11dxli8EzoozjZ0LfAmDT6IJKHWKtlNKy

Desired behavior:

Can click on the first suggestion

Steps to reproduce:

The following script would fail. For some reason click wouldn’t pick the item here. I’ve tried selenium and the click worked for me.

cy
  .visit('https://developers.google.com/maps/documentation/javascript/examples/full/places-autocomplete')
  .get('#pac-input')
  .should('be.visible')
  .wait(1000)
  .type('22 Princes Highway, Darlington NSW, Australi')
  .get('.pac-item')
  .first()
  .should('be.visible')
  .click()
  .get('#pac-input')
  .then((result) => {
      expect(result.val()).to.eq('22 Princes Highway, Darlington NSW, Australia');
  });

Versions

Cypress 3.0.1 Mac 10.13.4 Electron 59

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

13reactions
kucebcommented, Dec 17, 2018

Hello all, I believe this issue is because we do not yet fire the mouseover event on cy.click. This will be fixed along with native events in #2956

Until then, please use this workaround when clicking on the auto-complete suggestion:

.trigger('mouseover').click()
11reactions
jdcumpsoncommented, Jul 4, 2018

I’m having the same issue, my workaround for now is to use the type() method, like

cy.get('input[placeholder="Street Address"]').click().type(queryAddress);
cy.get('.pac-item').first().should('contain', '<redacted address>');
cy.get('input[placeholder="Street Address"]').type('{downarrow}{enter}');

I found click() ensured more reproducible behaviour from the google component, since I was not able to catch the JSONP requests in my cy.server() routes. A fix here would be great.

Read more comments on GitHub >

github_iconTop Results From Across the Web

hover - Cypress Documentation
If the hover behavior depends on a JavaScript event like mouseover , you can trigger the event to achieve that behavior. Using .trigger()...
Read more >
Handling Touch and Mouse events using Cypress
If your apps are designed to handle right-click events then you can use the rightclick() command in Cypress to simulate the right-click actions....
Read more >
Handling Touch And Mouse Events In Cypress [Tutorial]
In this Cypress tutorial, we talk about handling touch and mouse events when running Cypress test automation scripts.
Read more >
Mouseover in cypress - Stack Overflow
You can use the cypress-real-events plugin and this worked with your webpage. ... it.only("Mouse hover using trigger ", () => { cy.viewport(1440, ...
Read more >
Handle mouse hover events in cypress – Part 2
Handle​​ mouse hover events​​ in cypress​​ using​​ trigger​​ method · it.skip to skip a test ·.first().click() to click first occurrence of​​ an​ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found