.scrollIntoView
语法:
.scrollIntoView()
.scrollIntoView(options)
使用:
cy.get('footer').scrollIntoView() // Scrolls 'footer' into view
参数介绍
duration 0 多长时间滑到指定元素
easing swing 滚动的动画效果
log true 是否显示命令行日志
offset {top: 0, left: 0} 元素滚动后的偏移量
timeout defaultCommandTimeout 超时时间
样例
滚动到指定元素
cy.get('button#checkout').scrollIntoView()
.should('be.visible')
使用线性宽松动画滚动
cy.get('.next-page').scrollIntoView({ easing: 'linear' })
在2s内滚动到指定元素
cy.get('footer').scrollIntoView({ duration: 2000 })
在2s内滚动到指定元素,超时时间为10s
cy.get('tr').eq(50).scrollIntoView({ timeout: 10000,duration: 2000})