Cypress: any difference between cy.get("a").find("b") and cy.get("a b")

As you stated in your question there is not difference between cy.get("a").find("b") and cy.get("a b"). But the most important difference between find and get commands in Cypress is that cy.get() is chained off of cy, it always looks for the selector within the entire document as stated in Cypress documents. But as again stated in Cypress documents find works as follows:

Get the descendent DOM elements of a specific selector.

So the command cy.get("a").find("b") returns all the b elements which are successor of an a element, but cy.get("a").get("b") finds all the a and b elements regardless of they are parent and child.


There is no difference in result, but there is a difference in implementation.

From the docs for the .find() command:

The querying behavior of this command matches exactly how .find() works in jQuery.

In other words,

cy.get("a").find("b");

is equivalent to the following JQuery:

$("a").find("b");

$("a").find("b"); will produce the same result as $("a b"), but will use a different method to get there.


I've done a bit of testing to confirm this on a fairly complex page:

testing result

Notice how the number results is the same for cy.get("td").find("tr") and cy.get("td tr").


find() wont work on the cy rather it can work on a chained DOM. the below command would throw error cy.find('.progress') // Errors, cannot be chained off 'cy'