我有一个应该有 10 个元素的列表,如果列表包含 11 个元素,我需要显示滚动,则容器的大小是固定的。一切都很好,但我如何检查滚动是否存在?
cy.get('[data-testid=list-box]')
Run Code Online (Sandbox Code Playgroud)
您可以获得元素的计数,如果列表的长度是less than or equal to 10执行某些操作,否则检查visibilityof scrollbar。请尝试下面的测试并让我知道
it('Check the length of the list', () => {
cy.get('[data-testid=list-box]')
.then(list => {
const listCount = Cypress.$(list).length;
if(listCount <= 10){
// do some action if the list count is less than 10..
}else{
cy.get('#scrollbar_Id').should('be.visible');
}
});
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6229 次 |
| 最近记录: |