如果想从头学起Cypress,可以看下面的系列文章哦

https://www.cnblogs.com/poloyy/category/1768839.html

 

作用  

  • 获取页面当前的 url 的哈希值
  • 等价于 cy.location('hash') 

 

语法格式

cy.hash()
cy.hash(options)

options:只有 timeout 和 log,不再展开讲了

 

正确写法

cy.hash()

 

实际栗子

html 代码

    <ul id="users">
        <li>
            <a href="#/users/8fc45b67-d2e5-465a-b822-b281d9c8e4d1">Fred</a>
        </li>
    </ul>

 

测试文件代码

Cypress系列(33)- hash() 命令详解

 

测试结果

Cypress系列(33)- hash() 命令详解

 

总结

感觉这方法应该用的不多,如果是普通的链接,是不会返回哈希值的

 

结尾

我的博客即将同步至腾讯云+社区,邀请大家一同入驻:https://cloud.tencent.com/developer/support-plan?invite_code=12vd92hxgwgj1

相关文章:

  • 2021-09-13
  • 2021-11-27
  • 2021-07-08
  • 2021-11-03
  • 2022-02-14
  • 2021-11-12
  • 2021-10-14
  • 2021-07-20
猜你喜欢
  • 2021-10-17
  • 2021-04-28
  • 2021-04-14
  • 2021-08-28
  • 2021-06-07
  • 2021-08-04
相关资源
相似解决方案