ActionChains Class

Selenium contains an ActionChains class which helps to do actions such as Drag and Drop a WebElement , Scroll to required WebElement , Double click ,click and Hold a WebElement, Right click operations etc.



Procedure to use ActionChain class :

1. First we need to create a object for webdriver class.

2. Now we need to create an object for the Action Chains class and while creating the object we need to pass a webdriver object as an argument for it.

3. Finally now by using the Action Chains class object we can access all the methods.



Below Are the methods in ActionChains class.

perform() Method:

This method helps to perform all stored actions on ActionChains class methods.This method calls after actionchains class method to do the required operation.

    Syntax: perform()


move_to_element() Method:

This method is used to move the mouse to the middle of an element.

	Syntax: actionchain_object.move_to_element(webelement).perform()




move_to_element_with_offset() Method:

This method is used to move the mouse to offset an specified element.Offsets are relative to the top-left corner of the element.

Syntax: 
actionchain_object.move_to_element_with_offset(to_element, xoffset, yoffset).perform()


pause() method:

This method will pause all the inputs for a specified duration of time in seconds.



release() Method:

This method is used to release a mouse button on an element.



click_and_hold() Method:

This method is used to click and hold the mouse button on the webpage at last known mouse coordinates or offset.It doesn’t take any arguments and doesn’t return anything.