前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Cypress学习10-Navigation 导航功能(go,reload,visit)

Cypress学习10-Navigation 导航功能(go,reload,visit)

作者头像
上海-悠悠
发布2020-05-25 15:48:29
5190
发布2020-05-25 15:48:29
举报
文章被收录于专栏:从零开始学自动化测试

前言

web页面上的导航功能,上一页,下一页,重新加载页面,直接访问页面。

cy.go()

使用浏览器的缓存功能,访问上一页,下一页

代码语言:javascript
复制
cy.location('pathname').should('include', 'navigation')

cy.go('back')
cy.location('pathname').should('not.include', 'navigation')

cy.go('forward')
cy.location('pathname').should('include', 'navigation')

// clicking back
cy.go(-1)
cy.location('pathname').should('not.include', 'navigation')

// clicking forward
cy.go(1)
cy.location('pathname').should('include', 'navigation')

cy.reload()

不使用检测,重新加载页面

代码语言:javascript
复制
cy.reload()

// reload the page without using the cache
cy.reload(true)

cy.visit()

直接通过 url 地址访问页面

代码语言:javascript
复制
cy.visit('https://example.cypress.io/commands/navigation', {
  timeout: 50000, // increase total time for the visit to resolve
  onBeforeLoad: function(contentWindow){
    // contentWindow is the remote page's window object
  },
  onLoad: function(contentWindow){
    // contentWindow is the remote page's window object
  }
})
本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2020-05-16,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 从零开始学自动化测试 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 前言
  • cy.go()
  • cy.reload()
  • cy.visit()
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档