How to slide{move} slider in Selenium WebDriver

后端 未结 11 2043
花落未央
花落未央 2021-02-11 09:30

How to slide slider on horizontal progress bar URL: http://jqueryui.com/slider/ I tried to scroll the slider but it did not work for me. My code using Java is below:

         


        
11条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-11 10:24

    This code works absolutely fine for me It handles Slider of website: homeshop18.com try out this code:

    WebDriver driver = new FirefoxDriver();
    driver.get("http://www.homeshop18.com/fashion-jewellery/category:15143/filter_Theme:%28%22Traditional+Wear%22+%22Cuff+%26+Kada%22+%22Daily+Wear%22+%22Maang+Tikka%22+%22Openable+Round%22+%22Round%22+%22Openable+Oval%22%29/sort:Popularity/inStock:true/?it_category=HP&it_action=JW-HPSP01&it_label=HP-HPSP01-131021235900-PD-JW-ZC-VK-SC_DiwaliFestWeddingJewellery&it_value=0");
    
    WebElement Slider = driver.findElement(By.xpath("//*[@id='slider-range']/a[1]"));
    Thread.sleep(3000);
    
    Actions moveSlider = new Actions(driver);
    Action action = moveSlider.dragAndDropBy(Slider, 30, 0).build();
    
    action.perform();
    

提交回复
热议问题