Skip to content
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

How to test styles changes on hover with cypress #7952

Closed
Hamidrezana opened this issue Jul 11, 2020 · 4 comments
Closed

How to test styles changes on hover with cypress #7952

Hamidrezana opened this issue Jul 11, 2020 · 4 comments

Comments

@Hamidrezana
Copy link

Hamidrezana commented Jul 11, 2020

I want to test styles when hover on element but it doesn't work:

This is my test code:

  it("Table rows hover styles should be correct", () => {
    cy.get("table>tbody>tr").each(($el, index, $list) => {
      $el.trigger("mouseover");
      expect($el).to.have.css("background-color", "rgb(242, 242, 242)");
    });
  });

but the background-color value is what is before hover.

This is cypress error:

expected '<tr>' to have CSS property 'background-color' with the value 'rgb(242, 242, 242)', but the value was 'rgba(0, 0, 0, 0)'

@jennifer-shehane
Copy link
Member

@Hamidrezana How are the hover styles applied, via JavaScript, listening to the mouseover event? If so, this will work. If you are applying styles based on the :hover pseudo class in css, then this will not work. See #10

@cypress-bot cypress-bot bot added the stage: awaiting response Potential fix was proposed; awaiting response label Jul 13, 2020
@Hamidrezana
Copy link
Author

@jennifer-shehane Tnx for reply.
So there isn't any solution for my problem, yet?

I mean now we can't test pseudo class in css?

@jennifer-shehane
Copy link
Member

@Hamidrezana No, there isn't a way to do this in Cypress currently.

@jennifer-shehane jennifer-shehane removed the stage: awaiting response Potential fix was proposed; awaiting response label Jul 15, 2020
@mmonteiroc
Copy link

@Hamidrezana you can have a look on "cypress-real-events"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants