Dish
Dish

Reputation: 115

How to perform internal scrolling using selenium with java

I've a page which has list of messages say for example 20 messages and I am able to view only 4 at a time then I need to scroll down. If I use normal scrolling methods, it will scroll the page but I want to scroll the messages.

Upvotes: 0

Views: 106

Answers (1)

VSs
VSs

Reputation: 61

I have a suggestion - if messages are open after double click you can click at the first once and then switch by sending Key.ARROW_DOWN. Something like that:

firstMessage.click();
int i = 0;
while (i < 20) {
firstMessage.sendKeys(Keys.ARROW_DOWN);
i++;
}

Or you can tru to use JS for scrolling by pixels:

new Actions(driver).moveToElement(webelement).clickAndHold().moveByOffset(0, valueOfPixelsToScroll).release(webelement).build().perform();

Upvotes: 1

Related Questions