Advertisement
SeleniumETrainR

How to Work with jQuery UI Slider using selenium webdriver a

Dec 16th, 2012
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.83 KB | None | 0 0
  1. import java.util.List;
  2. import java.util.concurrent.TimeUnit;
  3.  
  4. import org.openqa.selenium.By;
  5. import org.openqa.selenium.Point;
  6. import org.openqa.selenium.WebDriver;
  7. import org.openqa.selenium.WebElement;
  8. import org.openqa.selenium.firefox.FirefoxDriver;
  9. import org.openqa.selenium.firefox.FirefoxProfile;
  10. import org.openqa.selenium.firefox.internal.ProfilesIni;
  11. import org.openqa.selenium.interactions.Action;
  12. import org.openqa.selenium.interactions.Actions;
  13.  
  14.  
  15. public class TestjQuerySlider {
  16.     public static void main(String[] args) throws InterruptedException {
  17.         ProfilesIni allProfiles = new ProfilesIni();
  18.         FirefoxProfile myProfile = allProfiles.getProfile("MyTestProfile");
  19.         myProfile.setPreference("capability.policy.default.Window.frameElement.get","allAccess");
  20.         WebDriver myTestDriver = new FirefoxDriver(myProfile);
  21.         myTestDriver.manage().window().maximize();
  22.         myTestDriver.manage().timeouts().implicitlyWait(1L,TimeUnit.SECONDS);
  23.         myTestDriver.get("http://tinyurl.com/pvpk7o");
  24.  
  25.     Thread.sleep(5000L);
  26.    
  27.     try {
  28.         List<WebElement> AlliFrameID = myTestDriver.findElements(By.tagName("iframe"));
  29.         System.out.println(AlliFrameID.size());
  30.         for(int i=0;i<=AlliFrameID.size();i++){
  31.             System.out.println(AlliFrameID.get(i).getAttribute("class"));
  32.         }
  33.     } catch (Exception e) {
  34.             myTestDriver.switchTo().frame(myTestDriver.findElement(By.className("demo-frame")));
  35.                
  36.                 Point MyPoint= myTestDriver.findElement(By.xpath("//*[@id='slider']/a")).getLocation();
  37.                
  38.                 WebElement someElement = myTestDriver.findElement(By.xpath("//*[@id='slider']/a"));
  39.                
  40.                 System.out.println(MyPoint.x+"--------"+MyPoint.y);
  41.                
  42.                
  43.                 Actions builder = new Actions(myTestDriver);
  44.  
  45.                 Action dragAndDrop =  builder.clickAndHold(someElement).moveByOffset(100,5).release().build();
  46.  
  47.                 dragAndDrop.perform();
  48.             }
  49.  
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement