package com.example.actions;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.interactions.Actions;
public class ScrollBarActions {
WebDriver driver;
public void setup(){
FirefoxProfile profile=new FirefoxProfile();
profile.setEnableNativeEvents(true);
driver=new FirefoxDriver(profile);
driver.manage().window().maximize();
driver.get("http://jqueryui.com/slider/");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
}
public void menuandSubMenu(){
System.out.println(driver.findElements(By.tagName("iframe")).size());
// Switch to Frames
// WebElement iframe=driver.findElement(By.xpath("//iframe[@id='demo-frame']"));
driver.switchTo().frame(0);
//Slider xpath
WebElement rootElement=driver.findElement(By.xpath(".//div[@id='slider']/span"));
int x=rootElement.getLocation().x;
System.out.println(x);
int y=rootElement.getLocation().y;
System.out.println(y);
WebElement slider = driver.findElement(By.xpath("//div[@id='slider']/span"));
Actions move = new Actions(driver);
Action action = (Action) move.dragAndDropBy(slider, 250, 0).build();
action.perform();
System.out.println("completed");
//or
WebElement slider1 = driver.findElement(By.xpath("//div[@id='slider']/a"));
for (int i = 1; i <=20 ; i++) {
slider1.sendKeys(Keys.ARROW_RIGHT);
}
}
public static void main(String[] args) {
ScrollBarActions dd=new ScrollBarActions();
dd.setup();
dd.menuandSubMenu();
}
}
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.interactions.Actions;
public class ScrollBarActions {
WebDriver driver;
public void setup(){
FirefoxProfile profile=new FirefoxProfile();
profile.setEnableNativeEvents(true);
driver=new FirefoxDriver(profile);
driver.manage().window().maximize();
driver.get("http://jqueryui.com/slider/");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
}
public void menuandSubMenu(){
System.out.println(driver.findElements(By.tagName("iframe")).size());
// Switch to Frames
// WebElement iframe=driver.findElement(By.xpath("//iframe[@id='demo-frame']"));
driver.switchTo().frame(0);
//Slider xpath
WebElement rootElement=driver.findElement(By.xpath(".//div[@id='slider']/span"));
int x=rootElement.getLocation().x;
System.out.println(x);
int y=rootElement.getLocation().y;
System.out.println(y);
WebElement slider = driver.findElement(By.xpath("//div[@id='slider']/span"));
Actions move = new Actions(driver);
Action action = (Action) move.dragAndDropBy(slider, 250, 0).build();
action.perform();
System.out.println("completed");
//or
WebElement slider1 = driver.findElement(By.xpath("//div[@id='slider']/a"));
for (int i = 1; i <=20 ; i++) {
slider1.sendKeys(Keys.ARROW_RIGHT);
}
}
public static void main(String[] args) {
ScrollBarActions dd=new ScrollBarActions();
dd.setup();
dd.menuandSubMenu();
}
}
0 Comments