0
votes

I need to scroll the table to get table contents that are dynamically populated using selenium with java bindings and chrome driver. This is another scroll and not the window scroll itself. All the available solutions I could find are for the window scroll. What I need here is to scroll the table. I need to scroll the one highlighted

Please see the second screenshot for the page source Page Source Screenshot

Any help much appreciated.

I tried with the below code but it is not able to locate the element

WebElement scroll = driver.findElement(By.xpath("//*[@class='antiscroll-scrollbar antiscroll-scrollbar-vertical antiscroll-scrollbar-shown']"));

scroll.sendKeys(Keys.PAGE_DOWN);

I am getting the below error message

Error Message: No such element: Unable to locate element: {"method":"xpath","selector":"//*[@class='antiscroll-scrollbar antiscroll-scrollbar-vertical antiscroll-scrollbar-shown']"}

1
What have you tried so far? Are you having trouble selecting the element in selenium? - John Mercier
@JohnMercier I tried the below solution but it is not working. codeWebElement scroll = driver.findElement(By.xpath("//*[@class='antiscroll-scrollbar antiscroll-scrollbar-vertical antiscroll-scrollbar-shown']")); scroll.sendKeys(Keys.PAGE_DOWN); Error Message: No such element: Unable to locate element: {"method":"xpath","selector":"//*[@class='antiscroll-scrollbar antiscroll-scrollbar-vertical antiscroll-scrollbar-shown']"} Yes, it is not able to locate the element - john connor
You should edit the question and add this information in a code block. That is the best way to get an answer that helps you. - John Mercier
@John Mercier Thank you for the feedback. I have updated the query. Please let me know if you have any suggestions. - john connor
Check out the guide on how to format code in the question. stackoverflow.com/editing-help#code - John Mercier

1 Answers

0
votes

From experience, I suspect the HTML class of the vertical scrollbar changes when it is in use. This means an extra class identifier (something like 'antiscroll-scrollbar-active') is added, so your xpath no longer applies and the element isn't found. Try using Contains instead, which will avoid that issue by using a partial, instead of complete, class match.

e.g.

//*[contains(@class, 'antiscroll-scrollbar antiscroll-scrollbar-vertical')]