Java-拖放操作不可拖动,无法在Chrome浏览器中运行

时间:2019-03-06 20:25:05

标签: java selenium google-chrome selenium-chromedriver

排练对象:

    `Point coordinates1 = from.getLocation();
    Point coordinates2 = to.getLocation();  
    TouchActions builder = new TouchActions(driver);
    builder.longPress(coordinates1)
           .move(coordinates2).release(coordinates2).perform();`

    `Actions builder = new Actions(driver);
    int x2 =to.getLocation().getX();
    int y2 = to.getLocation().getY();
    builder.clickAndHold(from);
    builder.moveByOffset(x2,y2);
    builder.moveToElement(from);
    builder.release();

builder.perform();`

    `browser.actions().
    mouseDown(element1).
    mouseMove(x:-1,y:-1).
    mouseMove(element2).
    mouseUp().

perform();`

    `Actions act = new Actions(driver);
    act.clickAndHold(from).build().perform();
    act.moveToElement(to).build().perform();

act.release(to).build()。perform();`

    `Actions builder = new Actions(driver);

builder.clickAndHold(from).moveToElement(to).release()。build()。perform();`

    `Actions builder = new Actions(driver);
    from.click();
    builder.clickAndHold(from).build().perform();
    builder.moveByOffset(276, 64).build().perform();
    builder.moveToElement(to).build().perform();

builder.release()。build()。perform();`

`Actions builder = new Actions(driver);

     Action dragAndDrop = builder.clickAndHold(from)
                         .moveToElement(to)
                 .release(from)
                 .build();

dragAndDrop.perform();`

new Actions(driver).dragAndDrop(from, to).build().perform();

1 个答案:

答案 0 :(得分:0)

Point coordinates1 = from.getLocation();
Point coordinates2 = to.getLocation();  
TouchActions builder = new TouchActions(driver);
builder.longPress(coordinates1)
       .move(coordinates2).release(coordinates2).perform();

Actions builder = new Actions(driver);
int x2 =to.getLocation().getX();
int y2 = to.getLocation().getY();
builder.clickAndHold(from);
builder.moveByOffset(x2,y2);
builder.moveToElement(from);
builder.release();
builder.perform();

browser.actions().
mouseDown(element1).
mouseMove(x:-1,y:-1).
mouseMove(element2).
mouseUp().
perform();

Actions act = new Actions(driver);
act.clickAndHold(from).build().perform();
act.moveToElement(to).build().perform();
act.release(to).build().perform();

Actions builder = new Actions(driver);
builder.clickAndHold(from).moveToElement(to).release().build().perform();

Actions builder = new Actions(driver);
from.click();
builder.clickAndHold(from).build().perform();
builder.moveByOffset(276, 64).build().perform();
builder.moveToElement(to).build().perform();
builder.release().build().perform();

Actions builder = new Actions(driver);

 Action dragAndDrop = builder.clickAndHold(from)
                     .moveToElement(to)
                     .release(from)
                     .build();
 dragAndDrop.perform();