I am facing an issue while trying to move the Slider using the DragandDropBy method. The slider seems to be moving to the wrong position consistently. I also attempted to use javascriptexecutor, however, that doesn't seem to work either.
driver.manage().window().maximize();
driver.get("http://www.globalsqa.com/demo-site/sliders/#Color Picker");
driver.manage().timeouts().implicitlyWait(30,TimeUnit.SECONDS );
WebElement iFrame = driver.findElement(By.cssSelector("#post-2673 > div.twelve.columns > div.newtabs.horizontal > div > div.single_tab_div.resp-tab-content.resp-tab-content-active > p > iframe"));
String sFrameContent = iFrame.getText().toString();
System.out.println("The Iframe Content is: "+sFrameContent );
driver.switchTo().frame(iFrame);
Actions action = new Actions(driver);
WebElement redSlider = driver.findElement(By.cssSelector("div#red > div"));
Thread.sleep(1000);
action.clickAndHold(redSlider).moveByOffset(90,0).release(redSlider).release().build().perform();
JavascriptExecutor jse = (JavascriptExecutor) driver;
jse.executeScript("document.getElementsByTagName('span')[0].style.left = '10.000%' ");
System.out.println("-------END--------");
driver.switchTo().defaultContent();
The above code runs without any errors, but unfortunately, the Slider does not move correctly to the desired position.
<body class="ui-widget-content" style="border:0;">
<p class="ui-state-default ui-corner-all ui-helper-clearfix" style="padding:4px;">
<span class="ui-icon ui-icon-pencil" style="float:left; margin:-2px 5px 0 0;"></span> Simple Colorpicker
</p>
<div id="red" class="ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content">
<div class="ui-slider-range ui-corner-all ui-widget-header ui-slider-range-min" style="width: 9.80392%;"></div><span tabindex="0" class="ui-slider-handle ui-corner-all ui-state-default" style="left: 9.80392%;"></span></div>
<div id="green" class="ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content">
<div class="ui-slider-range ui-corner-all ui-widget-header ui-slider-range-min" style="width: 54.902%;"></div><span tabindex="0" class="ui-slider-handle ui-corner-all ui-state-default" style="left: 54.902%;"></span></div>
<div id="blue" class="ui-slider ui-corner-all ui-slider-horizontal ui-widget ui-widget-content">
<div class="ui-slider-range ui-corner-all ui-widget-header ui-slider-range-min" style="width: 23.5294%;"></div><span tabindex="0" class="ui-slider-handle ui-corner-all ui-state-default" style="left: 23.5294%;"></span></div>
<div id="swatch" class="ui-widget-content ui-corner-all" style="background-color: rgb(25, 140, 60);"></div>
</body>