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

Studio uses selectors after an action has occurred, causing failing tests #14658

Closed
panzarino opened this issue Jan 20, 2021 · 2 comments · Fixed by #14788
Closed

Studio uses selectors after an action has occurred, causing failing tests #14658

panzarino opened this issue Jan 20, 2021 · 2 comments · Fixed by #14788
Assignees
Labels
experiment: studio Issues when using experimentalStudio type: bug

Comments

@panzarino
Copy link
Contributor

panzarino commented Jan 20, 2021

Current behavior

Studio will use selectors for elements after an action has occurred. For example, if clicking a button adds an .active class, studio might use that class to select the button. However, this will cause a broken test since the button does not have the .active class until after it's been clicked.

Desired behavior

Studio should only use properties of the element before an action has taken place to select that element.

Test code to reproduce

<button class="btn">button</button>
<button class="btn">button</button>
<script>
  const btn = document.getElementsByClassName('btn')[0]

  btn.addEventListener('mousedown', function() {
    btn.classList.add('active')
  })
</script>

Enter studio and visit the page with the above html content. Click on the first button to generate a command like the following:
Screen Shot 2021-01-27 at 3 04 24 PM

You can see that Studio picked a selector that only existed after the mousedown (but before the click completed). Therefore, when the test runs, it will fail as the selector isn't there yet.

Screen Shot 2021-01-27 at 3 06 37 PM

Originally reported by @dverbiest #14339 (comment)

@panzarino panzarino added type: bug experiment: studio Issues when using experimentalStudio labels Jan 20, 2021
@panzarino panzarino self-assigned this Jan 20, 2021
@cypress-bot cypress-bot bot added the stage: ready for work The issue is reproducible and in scope label Jan 21, 2021
@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: ready for work The issue is reproducible and in scope stage: work in progress labels Jan 27, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jan 30, 2021

The code for this is done in cypress-io/cypress#14788, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Jan 30, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Feb 1, 2021

Released in 6.4.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v6.4.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Feb 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
experiment: studio Issues when using experimentalStudio type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant