Skip to content

Cypress 7 & 8 changed Element.getAttribute #17512

@endercrest

Description

@endercrest

Current behavior

It seems that both Cypress 7 & 8 changed the return value for Element.getAttribute from null to empty string when the attribute doesn't exist in Chrome. This occurred when executing on a returned element from a document body event listener.

This is different from the return value chrome gives when running without cypress

Desired behavior

Expected cypress to continue to follow the respective browser's implementation. In the case of chrome, currently they return null when the attribute doesn't exist. This is observed in Cypress 6 (tested on both 6.4.0 & 6.9.1)

This is only a problem when Cypress is controlling chrome. Haven't tested other browsers / electron.

Test code to reproduce

https://github.com/endercrest/cypress-getattribute

Steps:

  1. Install dependencies (yarn)
  2. Start the server (yarn start)
  3. Start cypress

Defaults to Cypress 8.0.0, which is broken. If ran on cypress 6.9.1 it works as expected.

react-router.js.-.8.0.0.mp4
react-router.js.mp4

Cypress Version

8.0.0

Other

Chrome: Version 92.0.4515.107 (Official Build) (x86_64)

Metadata

Metadata

Assignees

No one assigned

    Labels

    pkg/driverThis is due to an issue in the packages/driver directorytype: unexpected behaviorUser expected result, but got another

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions