javascript - 赛普拉斯:cy.get("a").find("b") 和 cy.get("a b") 之间的任何区别
问题描述
似乎它们是相同的。cy.get("a").find("b")
和之间的输出有什么区别cy.get("a b")
吗?
(其中a
andb
是一些选择器,例如div
and span
,或.someClass
and .someOtherClass
。)
解决方案
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.
推荐阅读
- python - 在python的同一行内分配多个变量
- java - sql 错误或缺少数据库(未找到此类表)(来自 Java 的 SQlite 数据库连接)
- c++ - ActiveX 替换选项
- javascript - 如何在没有输入的情况下测试 JS 函数(使用 Jest)
- jenkins - 詹金斯:如何自动删除詹金斯从节点中的工作区
- helix - 在 Helix 实例上注册 MessageListener 和 MessaheHandlerFactory 时如何解决 Helix 不一致的行为?
- rabbitmq - 你如何处理 Rabbitmq 死信队列?
- python - 使用 Numpy Array Python 将新列添加到现有数据框
- regex - 正则表达式查找不包含字符串的行组合
- python - 如何解决 django 中的 getattr() 错误?