How to slide{move} slider in Selenium WebDriver

后端 未结 11 2060
花落未央
花落未央 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:21

    I just tried another way to work on slider bar.

    My code:

        public void sliderCode(int iSliderAdjustValue){
        File file = new File("D:\\Driver\\IEDriverServer.exe");
        System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
        WebDriver driver = new InternetExplorerDriver();
        driver.get("http://jqueryui.com/slider/");
    
        WebDriver driver = new InternetExplorerDriver();
        driver.get("http://jqueryui.com/slider/");
        driver.switchTo().frame(0); //need to switch to this frame before clicking the slider
        WebElement slider = driver.findElement(By.xpath("//div[@id='slider']/a"));
        Actions builder= new Actions(driver);
        int iCount = 0;
        if (iRange > 0) {
        for(iCount = 0; iCount < iRange; iCount++) {
        builder.moveToElement(slider).click(slider).sendKeys(Keys.ARROW_UP).perform();
                  }
        } else {
        for (iCount = 0; iCount > iRange; iCount--) {
        builder.click(slider).sendKeys(Keys.ARROW_DOWN) .perform();
        }
        }
            }
    

提交回复
热议问题