https://cypress.io logo
I have this button that I need to click. This is ...
# general-chat
f
I have this button that I need to click. This is not working...
Copy code
cy.get('[data-cy="my_account_add_fav"]')
      .trigger('mouseover').click();
    cy.wait(500);
I have tried
.click()
and
.click({force: true})
and
trigger('click')
as well as the above. I have no idea why nothing is working. The error is coming up because the click doesn't actually click. If it does click a pop up box comes up which includes 2
buyNow
buttons. Which is what it would get and click on if the original
.click()
worked. So, it appears like it works in the test body and in the console when I check it BUT it doesn't bring up the pop up in the window to the right. It is very strange.
w
I'm curious about the implementation - if maybe the javascript listener for the click event, in the code, is not actually attached to the
[data-cy="my_account_add_fav"]
element you are selecting. Definitely looks like Cy is clicking something. The trigger mouseover shouldn't be needed, and if forcing it didn't work, definitely my first guess is that somehow this element we're clicking isn't responsible for opening the popup.
f
That's where I click to open the popup and inspecting the code, the
data-cy
is for the button.
d
@freezing-scientist-25758 I’d try to use smth like this: cy.get(your selector).should('be.visible').then((el) => {cy.wrap(el).click({force: true})
f
I will look into that. Thank you.
6 Views