selenium move slider with correct value

Viewed 69

how can i handle the slider has float width?

Screenshot of the slider I want to move

public void setHValue(IWebElement slider, double value)
{
  string vMin = slider.GetAttribute("aria-valuemin");
  Thread.Sleep(500);
  string vMax = slider.GetAttribute("aria-valuemax");
 
  double minValue = Double.Parse(vMin);
  double maxValue = Double.Parse(vMax);
    
          
  Actions action = new Actions(_driver);

  action.MoveToElement(slider, (int)(value * 379.84 / (maxValue - minValue)), 6 / 2)
        .Click()
        .Build()
        .Perform(); 
}

I'm using this code now, but the result is different from the value I want. I am trying to set the slider to a value of 12600 but I am getting 11852.xx instead.

var Slider = _driver.FindElement(By.XPath("/html/body/div[2]/div/div[3]/div/div[3]/div/div[2]/div[2]/div/div[2]/div/div/div[2]/span/span[3]"));

setHValue(Slider, 12600); -> 11852.xx
<span class="MuiSlider-track-212 jss204" style="left: 0%; width: 100%;"></span>
<input type="hidden" value="0.08,100999.99">
<span class="MuiSlider-thumb-215 jss202 MuiSlider-thumbColorPrimary-216" tabindex="0" role="slider" data-index="0" aria-orientation="horizontal" aria-valuenow="0.08" aria-describedby="tippy-23" aria-valuemax="100999.99" aria-valuemin="0.08" style="left: 0%;"></span>
<span class="MuiSlider-thumb-215 jss202 MuiSlider-thumbColorPrimary-216" tabindex="0" role="slider" data-index="1" aria-orientation="horizontal" aria-valuenow="100999.99" aria-describedby="tippy-24" aria-valuemax="100999.99" aria-valuemin="0.08" style="left: 100%;"></span>

https://app.earth2.io/#resources/bazaar/jewels

0 Answers
Related