获取 table 中的最后一行,尽管它没有滚动到当前视线
Get the very last row in a table, although it isn't scrolled into current sight
我有一个 table,其中包含很多行。只有第 n 个最旧的行是可见的。较新的行被隐藏,必须使用滚动条才能将它们移动到视线中。
我写了以下赛普拉斯声明:
cy.get("span.class1.class2").last().click();
它 returns 最后一行,在显示视图时可见。截图中标红。
但我喜欢的是table中的最后一行。标记为蓝色。
用简单的 Cypress 语句可以吗?
还是必须先向下移动滚动条?
如果是这样:如何使用 Cypress 向下滚动?
获取 table 的 parent
class,您可以尝试使用 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() 可能会有所帮助。
我有一个 table,其中包含很多行。只有第 n 个最旧的行是可见的。较新的行被隐藏,必须使用滚动条才能将它们移动到视线中。
我写了以下赛普拉斯声明:
cy.get("span.class1.class2").last().click();
它 returns 最后一行,在显示视图时可见。截图中标红。
但我喜欢的是table中的最后一行。标记为蓝色。
用简单的 Cypress 语句可以吗?
还是必须先向下移动滚动条? 如果是这样:如何使用 Cypress 向下滚动?
获取 table 的 parent
class,您可以尝试使用 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() 可能会有所帮助。