Need to scroll down for locating an Element with Selenium

0 votes
So is there a way to scroll down or up so as to locate an element using XPath? I'm aware of a focus method in Selenium, but it does not physically scroll to within the view of FireFox browser window. I'm doing this because I'm testing the click on an element on a page. But, the event doesn't seem to work unless the element is visible. Does anyone have any suggestions for this?
Apr 20, 2018 in Selenium by kappa3010
• 2,010 points
69 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

There are a couple of options for doing this. Either use a JavaScript executor method or use Actions() method.

JavaScript Executor method:

JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("javascript:window.scrollBy(250,350)");

Actions method:

WebElement Elmnt = driver.findElement(By.id("my-id"));
Actions actions = new Actions(driver);
actions.moveToElement(Elmnt);
actions.perform()
answered Apr 20, 2018 by king_kenny
• 3,590 points

Related Questions In Selenium

0 votes
1 answer

Need to select an IFrame with selenium (python)

Well for me, something like this worked. ...READ MORE

answered May 3, 2018 in Selenium by sniffy_god
• 760 points
646 views
0 votes
1 answer

Wait for an element to be accessible using Selenium WebDriver

You can try out the below code: ...READ MORE

answered May 18, 2018 in Selenium by Atul
• 10,220 points
78 views
0 votes
1 answer

Need to perform parallel execution (multiple browser sessions) with Selenium & TestNG by using @BeforeSuite

@Beforesuite annotated method runs before the testNG.XML ...READ MORE

answered Mar 30, 2018 in Selenium by nsv999
• 5,050 points
993 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,050 points
164 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
553 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
152 views
0 votes
1 answer

Need some advise on the preferred element locators with Selenium WebDriver

Well let's not call it "Hierarchy". But, ...READ MORE

answered Apr 13, 2018 in Selenium by king_kenny
• 3,590 points
66 views
0 votes
1 answer

Need to integrate my Selenium tests with REST APIs

Selenium is good enough for this purpose...You ...READ MORE

answered Apr 18, 2018 in Selenium by king_kenny
• 3,590 points
203 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.