javascript - Get the very last row in a table, although it isn't scrolled into current sight
问题描述
I have a table which contains many rows. Only the nth-oldest rows are visible. The newer rows are hidden and one has got to use a scrollbar to move them into sight.
I have written the following Cypress-statement:
cy.get("span.class1.class2").last().click();
It returns the last row, which is visible, when the view becomes shown. Marked red in the screenshot.
But what I like to have is the very last row in the table. Marked blue.
Is that possible with a simple Cypress-statement?
Or do I have to move the scrollbar down first? If so: How can I scroll downwards using Cypress?
解决方案
获取该parent
表的类,您可以尝试使用scrollTo()
选项。
赛普拉斯文档: https ://docs.cypress.io/api/commands/scrollto.html#Syntax
例子:
cy.scrollTo(0, 500) // Scroll the window 500px down
cy.get('.sidebar').scrollTo('bottom') // Scroll 'sidebar' to its bottom
还有另一个选项称为.scrollIntoView()
,但我认为在您的情况下 scrollTo() 可能会有所帮助。
推荐阅读
- mysql - SQL If field is '*' then select from another table
- javascript - 通过引用反应调用方法不起作用
- amazon-web-services - 为 S3 存储桶中的每个对象调用 lambda
- dynamics-crm - 有没有办法在网格顶部隐藏快速查找?
- c - ARDUINO:组合串行输入的所有字符
- c# - Tesseract 不读取单个值和某些值
- sql - Oracle sql 开发人员登录被拒绝
- php - DomPDF: iconv(): 错误的字符集,不允许从 `utf-8' 转换为 `us-ascii//TRANSLIT'
- python - 如何在python中正确复制列表
- http - IIS 从 Header 中删除“Content-Length”