about 11 years ago
Selenium is a very powerful, flexible open source automation testing tool for web applications. With the help of selenium we can automate Sliders. Sliders helps the user to select a value by dragging and dropping a handle.
The following code should be used to automate the slider:
- WebDriver driver = new FirefoxDriver();
- driver.get("http://jqueryui.com/resources/demos/slider/default.html");
- driver.manage().timeouts().implicitlyWait(20L, TimeUnit.SECONDS);
- WebElement slider = driver.findElement(By.xpath("//*[@id='slider']/a"));
- Actions action = new Actions(driver);
- action.dragAndDropBy(source, xOffset, yOffset).perform();
WebDriver driver = new FirefoxDriver(); driver.get("http://jqueryui.com/resources/demos/slider/default.html"); driver.manage().timeouts().implicitlyWait(20L, TimeUnit.SECONDS); WebElement slider = driver.findElement(By.xpath("//*[@id='slider']/a")); Actions action = new Actions(driver); action.dragAndDropBy(source, xOffset, yOffset).perform();
eg: action.dragAndDropBy(slider, 200, 0).perform();
source element to emulate button down at.
xOffset horizontal move offset.
yOffset vertical move offset.
Hope this helps you. In case you have any questions feel free to ask in comments below.
Can you help out the community by solving one of the following Automation problems?
Do activity (Answer, Blog) > Earn Rep Points > Improve Rank > Get more opportunities to work and get paid!
For more topics, questions and answers, please visit the Tech Q&A page.
0 Comment(s)