An element not coming into view as the pane remains constant. I believe if I scroll down the pane maybe it will solve that issue?
So basically I want to scroll down a div to an element so as to get into visibility.
What piece of code would I need to add to my webdriver java?
I tried with the following without success:
WebDriver driver = null;
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("$('#fed-panel').data('jsp').scrollToBottom()");
I use the following in my code to deal with some Ajax objects that appear only when one scrolls down. You can replace the 'this.objectExists' function below (which is something I implemented) with ObjectVisible.
public void scrollDown(String identifier, String m){
Boolean readyStateComplete = false;
int i=0;
while (!readyStateComplete) {
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("window.scrollTo(0,Math.max(document.documentElement.scrollHeight," +
"document.body.scrollHeight,document.documentElement.clientHeight));");
covlog.logIssue(CovLogger.DEBUG, "scrollDown","Scrolling for the " + ++i + " times");
String tmp = js.executeScript("return document.readyState").toString();
readyStateComplete = tmp.contentEquals("complete");
//In case the object doesn't exists, break out of the loop
//the object might represent a spinner that shows that more
// records are downloaded.
if ((i%24)==0){ //24 is page size
if (!this.objectExists(identifier, m)){
readyStateComplete = true;
}
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.