cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.72k stars 3.16k forks source link

cy.get() does not accept a DOM element #2759

Closed alexkrolick closed 5 years ago

alexkrolick commented 5 years ago

Current behavior:

cy.get() accepts string selectors but not actual DOM node references

Desired behavior:

cy.get seems to be based on jQuery, which accepts a DOM element and returns it wrapped: https://codepen.io/alexkrolick/pen/dQprqX?editors=0011

It may not be idiomatic for some reason but it seems like if a valid reference has been obtained, it should be usable.

Steps to reproduce:

Versions

3.1.1

chrisbreiding commented 5 years ago

cy.get() only accepts a selector string, so that it can re-query for that selector as part of retrying the command chain. While it is related to jQuery, it does not mimic its signature exactly or all of its features. You can use cy.wrap() to wrap a DOM element reference instead.