- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are the Actions class in Selenium?
Selenium can perform mouse movements, keypress, hovering on an element, drag and drop actions, and so on with the help of the ActionsChains class. We have to create an instance of the ActionChains class which shall hold all actions in a queue.
Then the method - perform is invoked which actually performs the tasks in the order in which they are queued. We have to add the statement from selenium.webdriver import ActionChains to work with the ActionChains class.
#Method 1 - chained pattern e =driver.find_element_by_css_selector(".txt") a = ActionChains(driver) a.move_to_element(e).click().perform() #Method 2 - queued actions one after another e =driver.find_element_by_css_selector(".txt") a = ActionChains(driver) a.move_to_element(e) a.click() a.perform()
In both the above methods, the actions are performed in sequence in which they are called, one by one.
Methods of ActionChains class are listed below −
click - it is used to click a web element.
click_and_hold - it is used to hold down the left mouse button on a web element.
double_click- it is used to double-click a web element.
context_click- it is used to right-click a web element.
drag_and_drop_by_offset - it is used to first perform pressing the left mouse on the source element, navigating to the target offset and finally releasing the mouse.
drag_and_drop - it is used to first perform pressing the left mouse on the source element, navigating to the target element and finally releasing the mouse.
key_up - it is used to release a modifier key.
key_down - it is used for a keypress without releasing it.
move_to_element - it is used to move the mouse to the middle of a webelement.
move_by_offset - it is used to move the mouse to an offset from the present mouse position.
perform - it is used to execute the queued actions.
move_to_element_by_offset - it is used to move the mouse by an offset of a particular webelement. The offsets are measured from the left-upper corner of the webelement.
release - it is used to release a held mouse button on a webelement.
pause - it is used to stop every input for a particular duration in seconds.
send_keys - it is used to send keys to the present active element.
reset_actions - it is used to delete all actions that are held locally and in remote.
- How to capture tooltip in Selenium using Actions Class?
- How to scroll up/down a page using Actions class in Selenium?
- What are ActionChains class in Selenium with python?
- What are JSP actions elements?
- What are the mobile device authentication actions?
- What are the various methods available under Select class in Selenium?
- How to enter a letter in uppercase in the edit box using Actions in Selenium?
- How to perform right click on an element with Actions in Selenium?
- What are the different cookies methods in Selenium?
- What are the various important exceptions in Selenium?
- What are the P class and NP class in TOC?
- What are the prerequisites to learn Selenium?
- What are the drawbacks of Selenium WebDriver?
- What are the various Components of Selenium?
- What are different selenium versions?