Drag and Drop not working in selenium code

后端 未结 4 1083
半阙折子戏
半阙折子戏 2021-01-29 13:56

Drag and Drop is not working in my selenium code below, can anyone help me?

package selenium;

import java.util.concurrent.TimeUnit;

import org.apache.log4j.Bas         


        
4条回答
  •  無奈伤痛
    2021-01-29 14:46

    You can surely do it using below code. Just ensure that your xpath is correct or else you can't do it using any of the options.

    WebElement from = driver.findElement(By.xpath("html/body/div[1]"));
    WebElement  to = driver.findElement(By.xpath("html/body/div[2]"));
    Actions action1 = new Actions(driver);
    action1.clickAndHold(from).moveToElement(to).release(from).build().perform();
    

    Let me know in case of any issues but try this one it will work :)

提交回复
热议问题