Why drag and drop is not working in Selenium Webdriver?

后端 未结 12 1765
借酒劲吻你
借酒劲吻你 2021-01-11 11:45

I am trying to drag an element into another element using Selenium WebDriver but it\'s not working. I tried all the solutions which I can find on internet but none of the so

12条回答
  •  旧巷少年郎
    2021-01-11 12:13

    I have face similar problem way back, I have used dragAndDropBy to move slider but it didn't worked for me but later I found help and below the snippet for my working code:

    public static void slider(){
    x=10;
    WebElement slider = driver.findElement(By.id("slider"));
    int width=slider.getSize().getWidth();
    Actions move = new Actions(driver);
    move.moveToElement(slider, ((width*x)/100), 0).click();
    move.build().perform();
    System.out.println("Slider moved");
    }
    

    You can refer the link here

提交回复
热议问题