Skip to main content
Cypress应用

clearAllSessionStorage

清除测试交互过的所有源的 sessionStorage 数据。

caution

Cypress 会在每次测试_前_自动清除所有sessionStorage,以防止当 测试隔离 启用时状态在测试之间共享。除非你需要在单个测试内清除sessionStorage或测试隔离被禁用,否则不应使用此命令。

语法

cy.clearAllSessionStorage()
cy.clearAllSessionStorage(options)

用法

正确用法

cy.clearAllSessionStorage()

参数

options (Object)

传入一个选项对象来改变cy.clearAllSessionStorage()的默认行为。

选项默认值描述
logtrue命令日志中显示该命令

生成结果 了解主题管理

  • cy.clearAllSessionStorage() 返回 null

规则

要求 了解命令链

  • cy.clearAllSessionStorage() 需要链式调用 cy

断言 了解断言

cy.clearAllSessionStorage() 不能链式调用任何断言。

超时设置 了解超时机制

  • cy.clearAllSessionStorage() 不会超时。

另请参阅