Tuesday, 2 July 2013

Drag & Drop | Mouse Hover actions [WebDriver]

Drag & Drop Action:

This script allows you to do drag & drop elements; Drag & Drop operations make use of the Actions classes

Actions builder = new Actions(driver);

Action dragAndDrop = builder.clickAndHold(source Element)
.moveToElement(target Element)
.release(target Element)
.build();

dragAndDrop.perform();

(or)
Actions builder = new Actions(driver);
Action dragAndDrop = builder.dragAndDrop(source Elementtarget Element).build();
dragAndDrop.perform();

Mouse Hover Action:

This script allows you to do Mouse Hover elements; Mouse Hover operations make use of the Actions classes

Actions builder = new Actions(driver);

WebElement HoverLink = driver.findElement(By.linkText("
source Element"));
builder.moveToElement(HoverLink);
builder.perform();

5 comments:

  1. Hi Sams ..

    Really nice blog for Selenium people and one small request can you do a blog on Report Generating using Testng and Maven .. Thanks

    ReplyDelete
    Replies
    1. Thanks for the request. I'll have a blog on it ASAP.
      Cheers!

      Sams

      Delete
  2. Very nice explanations..Could you please do it for ANT with testNG?

    ReplyDelete
  3. good posts.. keep doing. All the best dude

    ReplyDelete
  4. Loved reading this thankks

    ReplyDelete