看起来它们是相同的。 cy.get("a").find("b")
和 cy.get("a b")
之间的输出有什么不同吗?
(其中a
和b
是一些选择器,例如div
和span
,或者。 someClass
和 .someOtherClass
。)
最佳答案
正如您在问题中所述,cy.get("a").find("b")
之间没有区别和 cy.get("a b")
.但是 find
之间最重要的区别和 get
Cypress 中的命令是 cy.get()
is chained off of cy
, it always looks for the selector within the entire document
as stated in Cypress documents .但同样stated in Cypress documents查找作品如下:
Get the descendent DOM elements of a specific selector.
所以命令 cy.get("a").find("b")
返回所有 b
a
的后继元素元素,但是 cy.get("a").get("b")
找到所有 a
和 b
元素,无论它们是父元素还是子元素。
关于javascript - Cypress :cy.get ("a").find ("b") 和 cy.get ("a b") 之间的任何区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52103005/