由于Web驱动程序无法找到元素,因此无法移动滑块

时间:2019-06-09 11:28:19

标签: java selenium-webdriver slider

我正在尝试定位滑块并将其移动到与默认值不同的值。但是,Web驱动程序无法找到元素或无法执行操作。请帮忙。 enter image description here

1 个答案:

答案 0 :(得分:0)

WebElement priceSlider = findMyElement(d,locator,locatorvalue);                 // int val = 100 / Integer.parseInt(locatorvalue);

            int abc=100/Integer.parseInt(testdata);

            Dimension sliderSize = priceSlider.getSize();
            double sliderWidth = sliderSize.getWidth();

            System.out.println("Slider width : " + sliderWidth);

            double ab=(sliderWidth)/abc;    
            float f = Math.round(ab);
            System.out.println("Float f : " + f);
            int valu = Math.round(f);
            System.out.println("Value of valu " + valu);
            Actions move = new Actions(d);
            move.moveToElement(priceSlider, valu, 0).click();
            move.build().perform();
            System.out.println("Slider moved");