0

我可以移动滑块,但不能在特定值上设置滑块。

 WebDriver driver = new FirefoxDriver();
 driver.get("");
 WebElement Slider = driver.findElement(By.xpath("//*[@id='slider-range']/a[1]"));
 Actions moveSlider = new Actions(driver);
 Action action = moveSlider.dragAndDropBy(Slider, 30, 0).build();
 action.perform();
4

2 回答 2

1
    Found the solution for the above program, by rearranging URl value we can achieve  this.

    URL url = new URL("http://www.myntra.com/women-sarees?nav_id=606&s=tn#!pricerange=2799:9099");  
    String str =url.toString(); 
    int index =  str.indexOf("pricerange");                                                   
    String before = str.substring(index);
    String SubValue = before.substring(E_index); 
    String value1   = SubValue.substring(1,5);      
    String value2   = SubValue.substring(6);    
    String newValue1 = "3000";                                                              
    String newValue2 = "5000";
    String beforeurl = str.substring(0,63); 
    String newUrl = beforeurl+newValue1+":"+newValue2;  System.out.println("New URL -> "+newUrl); driver.get(newUrl);
于 2013-10-24T08:07:06.897 回答
0

您可以使用该moveByOffset()方法将滑块移动到特定点。

WebElement Slider = driver.findElement(By.xpath("//*[@id='slider-range']/a[1]"));

Actions builder = new Actions(driver);

Action dragAndDrop =

builder.clickAndHold(Slider).moveByOffset(xOffset,yOffset).release().build();

dragAndDrop.perform();
于 2013-10-23T10:06:22.873 回答