Monday, 21 December 2015

Scrolling to right using Java in Selenium tests

Many times testers face issues related to scrolling to right of the application so that object is visible.
Below is the code which i have used and working perfectly fine.

You can use action or scrolling horizontally using the right or left key on the keyboard. The library which needs to be included is "org.openqa.selenium.interactions.Actions".


Actions action = new Actions(driver);
action.sendKeys(Keys.ARROW_RIGHT).perform();


For doing the scrolling vertically, you can use the below code:

JavascriptExecutor js = (JavascriptExecutor) driver; 
js.executeScript("arguments[0].scrollIntoView();", <webelement>);

This has not worked for me when scrolling horizontally that is the reason i have above solution different for horizontal and vertical scrolling.

Wednesday, 9 September 2015

Creation of New Project in Eclipse and Addition of Selenium Jar files and TestNG Library

1    Note: Please download Selenium jar files and TestNG library before starting below steps.

             1.  Create a new Java Project in eclipse

2.      Click on Next and add Selenium Jar files (selenium-server-standalone-2.47.1, selenium-java-2.47.1 and selenium-java-2.47.1-srcs) and TestNG files. For TestNG files click on “Add Library” and to add Selenium Jar files click on “Add External Jars”







 3.      Expand the project in Java Eclipse and check the added files: