Home > OS >  How do I catch infinite scroll last index
How do I catch infinite scroll last index

Time:02-18

I want to get last index in data-table on page. But this table using infinite scroll.Therefore every scroll event mixing last index. How can I control this situration.

str_index=findElement("//*[@id=\"Table\"]/div/div[2]/div/span/span",Path.xPath).getText();
    index=Integer.parseInt(str_index)-1;

str_index= Table info for how many items is showing.And I get this value for using xPath.

WebElement last=findElement("//*[@id=\"Table\"]/div/div[1]/div/cdk-virtual-scroll-viewport/div[1]/table/tbody/tr[" index "]/td[18]",Path.xPath);

CodePudding user response:

I think I fix the problem. I use this:

WebElement last=findElement("//*[@id=\"Table\"]/div/div[1]/div/cdk-virtual-scroll-viewport/div[1]/table/tbody/tr[last()]/td[18]",Path.xPath);

CodePudding user response:

You can scroll to the bottom of the document:

public void scrollToBottom() {
     jsExecutor.executeScript("window.scrollTo(0,document.body.scrollHeight)");
}
  • Related