-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cypress should fire 'mouseover' event on .click() #1847
Comments
I was about to open the very same one ✔️ In my case I even tried to add a cy
.get('.pac-container.pac-logo')
.find('.pac-matched')
.contains('Plaza de Olavide')
.then($el => {
$el[0].setAttribute('role', 'option');
cy.wait(500);
cy.wrap($el[0]).click({ force: true });
}); But still it does not work, Cypress performs the click but the field does not grab the data coming from googleapis. |
I'm using behat framwork for PHP and using native framwork methods or javascript methods I can't click on the first item. The exception thrown in my case is that another element will receive the click. The funny thing is that the "other" element it says it will receive the click is the same I'm trying to click... In fact in my test video, the element it's clicked but nothing is really selected. I also tried to generate some JQuery keyboward actions and it didn't work... var e = $.Event('keydown');
e.which = 40; // Character 'Down arrow'
$('#address_from').trigger(e);
ewhich = 13; // Character 'Enter'
$('#address_from').trigger(e); Another option I thought was getting the first item text and put them in the input trying to generate an exact match... But then I've got no results from Google places. That's magic. |
I'm having the same issue, my workaround for now is to use the 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 |
@jdcumpson thanks for the workaround, it's working for me! ✔️ |
Hi, could y'all try this in Cypress version 3.0.3? We made some improvements to focusing the browser since then that may have affected this behavior. |
Already tried it and it didn't work yet for me. Still cannot click on the elements coming from googleapis Now I can't even use the workaround shared by @jdcumpson , typing Verified version 3.0.3 |
Maybe my last comment is related to this new one #2261 |
This work for me. this.wrapper.get('input')
.type('address')
.wait(1000)
.type('{downarrow}{enter}') I have tried in other case, where I have a form, and the solution above it doesn't work because of the enter-submit connection. |
Any update on this? I'm using Google Autocomplete API in my Angular app and thus far have been unable to test forms with it. As said before, the ENTER key works, but it unfortunately forces a submit on the form. |
FYI, in case anyone is looking at this, I found a workaround that's not great, but it will do. First, I put a hdiden field in my form: <input type="hidden" data-cy="txtPreventSubmission" value=""> Then (I'm using Angular) I in the submitForm I check the value of this field, If it's got a value, I do NOT submit the form. Then, in my Cypress script, I have this line when I first open up the form: // HACK - we do this to prevent form submission when we hit the ENTER key
// we hit the enter key to make Google places work
// https://github.com/cypress-io/cypress/issues/1847
cy.get('[data-cy=txtPreventSubmission]').then(tx => tx.val('preventsubmission')); Now, I can test the Google Places autocomplete in my Cypress script like this: cy.get('[data-cy=rsHomeAddress]').find('[data-cy=tbAddressLookup]')
.type('901 Dunbar Drive Dunwoody', {force: true})
.type(' {downarrow}{enter}', {delay: 300, force: true}); Couple of things here. I have the Cypress script typing, and then hitting the Second, you can type as fast as you want, but you need 100ms delay in order to get the Autocomplete window to open. And in my limited experimentation, you need a 300ms delay in order to get the Third - that leading space in the second type command is important, it's what gets the Google Places Autocomplete to open. If you omit the leading space, the dropdown won't appear. Finally, I re-enable form submission in my Cypress script: // now we can submit the form
cy.get('[data-cy=txtPreventSubmission]').then(tx => tx.val('')); And I can successfully submit the form with the Google Places working. Thanks, |
Hello all, I believe this issue is because we do not yet fire the Until then, please use this workaround when clicking on the auto-complete suggestion: .trigger('mouseover').click() |
I found the following workaround: The suggested addresses are included within an element with a class Something like this: cy.get(‘#FIELD_ID').type(’YOUR_ADDRESS')
cy.get('.pac-item').first().click()
cy.get('#FIELD_ID').type('{downarrow}{enter}') |
The code for this is done in cypress-io/cypress#3030, but has yet to be released. |
Released in |
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.
Versions
Cypress 3.0.1
Mac 10.13.4
Electron 59
The text was updated successfully, but these errors were encountered: