selenium-webdriver Actions (Emulating complex user gestures)

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Introduction

The Actions class gives us a way of emulating precisely how a user would interact with a web page/elements. Using an instance of this class you can describe a series of actions, such as clicking, double-clicking, dragging, pressing keys, etc. Once these actions are described, in order to carry the actions out, you must call must build the actions (.Build()) and then instruct them to be performed (.Perform()). So we must describe, build, perform. The examples below will expand upon this.

Syntax

  • dragAndDrop(WebElement source, WebElement target)
  • dragAndDropBy(WebElement source, int xOffset, int yOffset)
  • perform()

Parameters

ParametersDetails
sourceElement to emulate button down at.
targetElement to move to and release the mouse at.
xOffsetx co-ordinate to move to.
yOffsety co-ordinate to move to.

Remarks

This section contains information of Actions class of Selenium WebDriver. The Actions class provides you convenient methods to perform complex user gestures like drag and drop, hold and click etc.



Got any selenium-webdriver Question?