cypress - Cypress - 停止下一页导航
问题描述
假设我知道下一页导航的 URL,有没有办法阻止下一个操作执行导航,无论导航是由 href 还是 js 引导的?试过cy.intercept
不行。
// doesn't work
cy.intercept({ hostname: 'cross.domain' }, (req) => {})
cy.contains('Next').click()
解决方案
您可以使用JQ .attr():
cy.get(`aTagSelector`) //This part is recommended to check if you click the required button with the link to cross origin
.should('have.attr', 'href')
.and('include', `expectedUrl`)
cy.get(`aTagSelector`)
.then($aTagElement => {
$aTagElement.attr("href", '/');
cy.get($aTagElement)
.click({force: true})
})
推荐阅读
- java - 从 ArrayDeque 中找到一个项目并在 Java 中将其推送到最后
- .net - 无法象征 Xamarin Android 堆栈跟踪
- java - spring data mongorepository.save E11000 有时重复键错误索引
- data-structures - 具有删除 o(1) 和随机访问 o(1) 的数据结构
- java - 单击后更改鼠标位置
- java - 在 Java 8 中使用函数式接口作为 filter() 函数的参数
- javascript - Mapbox 地图不显示
- python - 无法在 AWS EC2 中创建新文件夹
- haskell - Lens:这个filteredHas 组合器是否已经存在?
- excel - Excel 相关下拉列表 - 多行