Posts

Showing posts with the label Scrolling

Scroll the WebGrid using selenium webdriver

Hi, Sometimes in webpage there is web table grid present on page and we need to scroll the grid to access the element information. Because of asynchronous call data will not load completely until unless you scroll the grid. From wiki.. Synchronous means that you call a web service (or function or whatever) and wait until it returns - all other code execution and user interaction is stopped until the call returns. Asynchronous means that you do not halt all other operations while waiting for the web service call to return Here I have written the method that will scroll your grid until it reach to end of data row. Note:  ElementXpath will be your data table rows xpath like   ElementXpath = "//table//tr"; public static void ScrollView(WebDriver driver,String ElementXpath) throws Exception { int elemntCountBeforeScroll= driver.findElements(By.xpath(ElementXpath)).size(); if (elemntCountBeforeScroll>0){ WebElement element = driver.findElements(By.xpath(...

Scrolling web page with Webdriver using java

We can scroll the web page using javaScript Executor or You can use the "org.openqa.selenium.interactions.Actions" class to move to an element: Following classes you required in you java code import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.Alert; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; 1. We may require to scroll to bottom of the page and then perform operations. For this scenario we can use following code ((JavascriptExecutor) driver).executeScript( "window.scrollTo(0, document.body.scrollHeight)" ); 2. Some times, we may require to scroll to particular element and peform operations on that particular element. For this we need to pass the element on which we need to perform operation. For this scenario we ca use following code WebElement element = driver.findElement(By.linkText( "googleMap" )); ((JavascriptExecutor) driver).executeScrip...