因此,每当我尝试访问元素 '#container ._1AtVbE' 但在 DOM 中时,它都会给我 30 个结果,其中包括 Apple 智能手机。但在 cypress runner 中,它给出了 13 并且页面未加载。一旦我物理滚动到结果底部页面,就会生成剩余的项目。
这是我尝试过的代码: ///
describe('全部登录测试', () =>{
beforeEach( () =>{
cy.visit('https://www.flipkart.com/')
})
it.only("simi", () => {
cy.get('._1ch8e_').contains('Mobiles').click()
cy.get('#container [class="_1AtVbE col-12-12').contains('Apple SmartPhones').find('div.Nyt1vx').scrollIntoView().find('._1xCO19')
///cy.get('#container ._1AtVbE',{timeout:50000}).should('be.visible')
})
})
一旦我物理滚动到结果底部页面...
Cypress 有命令
scrollTo('bottom')
正是这样做的。问题是在哪里添加滚动(必须是列表或其他可滚动元素)。
我无法从你的代码中看出,因为那些是最差选择器。
假设是
#container
...
cy.get('#container').scrollTo('bottom') // scroll to bottom of container