log
在 Cypress 命令日志中打印消息。
语法
cy.log(message)
cy.log(message, args...)
用法
正确用法
cy.log('created new user')
参数
message (String)
要打印到 Cypress 命令日志中的消息。支持 Markdown 格式的消息。
args...
要打印到 Cypress 命令日志中的额外参数。参数数量没有限制。
生成结果
cy.log()
返回null
。
示例
消息
在命令日志中打印消息。
cy.click('Login')
cy.log('Login successful')
参数
在命令日志中打印带参数的消息。
cy.log('events triggered', events)
规则
要求
cy.log()
必须通过cy
链式调用。
断言
cy.log()
不能链式调用任何断言。
超时设置
cy.log()
不会超时。
命令日志
在命令日志中打印带参数的消息。
cy.log('log out any message we want here')
cy.log('another message', ['one', 'two', 'three'])
以上命令将在命令日志中显示为:

当点击命令日志中的 log
时,控制台会输出以下内容:
