Wednesday, February 23, 2022

How to Automate Slider in Selenium WebDriver

We can achieve it using xOffse and yOffse of the web element and drag and drop by method.

WebElement slider = driver.findElement(By.xpath("//*[@id='slider']/a"));
Actions action = new Actions(driver);
action.dragAndDropBy(source, xOffset, yOffset).build.perform();
action.click();
action.release();

Note: We can get the X,Y coordinates using Page Ruler Redux chrome plugin.
xOffset horizontal move offset (Top value in the Page Ruler).
yOffset vertical move offset (Right value in the Page Ruler).