QA Interview Handbook
  • 🏠Home Page
  • About Testing
    • 💖Qualities of A Great Tester
  • Manual Testing
    • 💡Overview
      • ✋Demand for Software Testing
      • 😄Tester's Role in Manual Testing
      • 7️Testing Principles
      • 🚨V & V
      • ❔Interview Questions
    • ♻️SDLC
      • 📒Phase 1: Planning
      • 🔍Phase 2: Requirement Analysis
      • 👔Phase 3: Design
      • ⛑️Phase 4: Development
      • 🧪Phase 5: Testing
      • 🚚Phase 6: Deployment
      • 🖱️Phase 7: Maintenance
      • ⚔️Common Challenges
      • ❔Interview Questions
    • 🌀STLC
    • 🌊Waterfall
    • ✳️Agile
      • 😁Tester's Role in Scrum
    • 🔢Types
      • ⬜White Box Testing
      • ⬛Black Box Testing
        • 🔰Techniques Used in Black Box Testing
        • 🚘Functional Testing
          • 1️⃣Unit Testing
          • 2️⃣Integration Testing
            • 🔰Techniques Used in Integration Testing
          • 3️⃣System Testing
            • 📼Types of System Testing
            • 🌊Phases of System Testing
            • 🌀Regression Testing
            • 🌫️Smoke Testing
          • 4️⃣Acceptance Testing
            • ⚙️User Acceptance Testing
            • 🅰️Alpha Testing
            • 🅱️Beta Testing
        • 🕳️Non Functional Testing
      • 📑Grey Box Testing
    • 🪄User Story
      • ⏺️Sample User Stories
    • 📓Test Cases
      • ⏺️Sample Test Cases
      • ❔Interview Questions
    • ✖️Defect Life Cycle
      • ☣️Priority + Severity
      • ⏺️Sample Defect Reports
      • ❔Interview Questions
      • 🐛Buggy Questions
    • 🌐Atlassian JIRA
      • 🐞JIRA Issues
      • ❔Interview Questions
    • ❔Interview Questions
  • Accessibility Testing
    • 💡Overview
    • 🤓Tester's Role in Accessibility Testing
    • 📚WCAG Principles
      • 👁️Perceivable
      • 🏹Operable
      • 🧠Understandable
      • 🤖Robust
    • 🔧Axe DevTools
      • ❔Interview Questions
    • 📓Test Cases
    • ❔Interview Questions
  • API Testing
    • 💡Overview
    • 😀Tester's Role in API Testing
    • 🍊HTTP Methods & CRUD
      • 🍂HTTP Status Codes
    • 🍍API Tools
      • 🟠Postman
        • ☄️Sending your first API request
        • 🔬HTTP Requests with Java
        • 🎲GitHub Sample
        • ❔Interview Questions
      • ⛑️REST Assured
        • 🎇Dependency
        • ❔Interview Questions
    • 📓Test Cases
    • 🦧API Cheatsheet
    • ❔Interview Questions
  • Database Testing
    • 💡Overview
    • 😆Tester's Role in Database Testing
    • 🔵SQL
      • ⛓️Constraints
      • 🛢️Referencing a Column
      • 🔼DDL Commands
      • 🔼DML Commands
        • 🖌️Operators
        • 🛠️Functions
          • ⏯️Aggregate Functions
        • 🎅Clauses
          • ⏫Join Clauses
          • 🔵Filter Clauses
          • ⏬Set Operations
      • 🃏Wildcard Character
      • ❔Interview Questions
    • 📓Test Cases
    • 🧤SQL Practice Sites
    • 🫐SQL Cheatsheet
    • ❔Interview Questions
  • Java
    • ⛩️Introduction
    • 😄Tester's Reason to Learn Java
    • Ⓜ️Main Method
      • ❔Interview Questions
    • 📐Variables & Types
      • 🪢Special Types
    • 🥁Modifiers
    • 🅾️Operators
    • 🪡String
      • 🩺String Methods
        • String Method Problems
      • 🚨Delimiter
      • ❔Interview Questions
    • 🖇️Conditionals
      • 💎Common If Statements
      • 💎Common Ternary Operator Statements
    • Ⓜ️Math Class
    • 🌊Loops
      • 💎Common Loop Examples
      • 🔃Nested For Loops
    • 🍼OOPS
      • 🏛️Classes and Objects
        • ❔Interview Questions
      • 🎃Constructor
        • ⚡Static
          • ❔Interview Questions
        • 📍This() & Super()
          • ❔Interview Questions
        • 🍀Finalization
      • 🔓Encapsulation
      • 🐥Inheritance
      • 🦋Polymorphism
      • 🕸️Abstraction
    • 🏮Java Practice Sites
    • ☑️Data Structures + Algorithms
      • 🅾️Big O
      • ☑️Data Structures
        • 🔸Array
        • 🔳Array Problems
        • Page
      • 🪟Sliding Window Technique
        • 🪟Sliding Window Problems
        • 🥐LeetCode #53
        • 🥐LeetCode #209
    • ❔Interview Questions
  • Automation Testing
    • 🚰Flow
      • 💡Overview
      • 🤩Tester's Role in Automation Testing
      • 🍀Selenium
        • 🕸️Selenium WebDriver
          • 🕷️WebDriver Commands
            • 🌐WebElement
              • 🔆HTML Tags
              • 🔬Find Element(s)
              • 🦎Locators
                • ❌Xpath
                • 🏰CSS Selector
                • 📀DOM
                • 🏠Quick Reference for XPath + CSS
            • ✋Waits
            • Browser Management
            • 🏎️Navigation
            • Alerts
          • 🏷️Advanced User Interactions
            • 🗯️Action vs. Actions
            • 💧Drop Down
            • ✅Check Box
            • 🖇️Forms
          • ⚠️Exceptions
        • 🍏OOPS + Selenium
        • 🚢Frameworks
          • ⚓Module Based Framework
          • 🎹Keyword Driven Framework
          • 🎋Data Driven Framework
          • 🌺Hybrid Framework
          • 🌴Log4j
          • 📄Page Object Model
        • 🧪Testing Frameworks
          • 💡TestNG
          • 🉑JUnit
          • 🥒BDD
            • 🥒Cucumber
        • 🌉Selenium Grid
          • ✖️Desired Capabilities
        • ❔Interview Questions
      • 🔄API Testing with Selenium
      • ⏪Database Testing with Selenium
      • Ⓜ️Maven
      • 🐙Git
        • ❔Interview Questions
      • 🕵️‍♂️Jenkins
        • ❔Interview Questions
      • 🐳Docker
        • ❔Interview Questions
      • 📙AWS
        • ❔Interview Questions
  • Behavioral
    • 📣Mixed Interview Questions
    • ⭐STAR Method
      • 🌟Sample Responses
Powered by GitBook
On this page
  • 🌟 Action 🌟
  • 🌟 Actions 🌟

Was this helpful?

  1. Automation Testing
  2. Flow
  3. Selenium
  4. Selenium WebDriver
  5. Advanced User Interactions

Action vs. Actions

🌟 Action 🌟

Action is an interface in Selenium that represents a single user-interaction action. It is defined in org.openqa.selenium.interactions. It contains one of the most widely used method perform(). Action is used when performing a single user interaction on a web page.

Sure, here are all the commands in Action that are not in Actions:

  • Action.click()

  • Action.doubleClick()

  • Action.contextClick()

  • Action.dragAndDrop()

  • Action.keyDown()

  • Action.keyUp()

  • Action.sendKeys()

  • Action.move()

  • Action.release()

These commands are all used to perform simple user-interaction actions. They are all implemented in the Action interface, but they are not all exposed in the Actions class. This is because the Actions class is designed to be more powerful and flexible, and it does not need to expose all of the simple actions that are available in the Action interface.

If you need to perform any of the commands listed above, you can use the Action interface directly. However, if you need to perform more complex actions, you should use the Actions class.

Here is an example of how to use the Action interface to click on an element:

import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Action;

public class Example {

    public static void main(String[] args) {
        WebElement element = driver.findElement(By.id("myElement"));

        Action clickAction = new Action(driver);
        clickAction.click(element);
        clickAction.perform();
    }
}

This code will click on the element with the ID myElement.

🌟 Actions 🌟

Actions is a class in Selenium that is defined in org.openqa.selenium.interactions. It is the user-facing API for emulating complex user gestures. Actions class implements the builder pattern, which can build a CompositeAction containing all actions specified by the method calls. Actions is used when performing a sequence of user interactions on a web page.

Here is an example of using Action and Actions in Selenium:

// Using Action to click on an element
WebElement element = driver.findElement(By.id("example-id"));
Action action = new Actions(driver).click(element).build();
action.perform();

// Using Actions to perform a sequence of actions
WebElement element1 = driver.findElement(By.id("example-id-1"));
WebElement element2 = driver.findElement(By.id("example-id-2"));
Actions actions = new Actions(driver);
actions.click(element1).click(element2).sendKeys("text").build().perform();

In summary, Action is used for a single user interaction, while Actions is used for a sequence of user interactions.

PreviousAdvanced User InteractionsNextDrop Down

Last updated 1 year ago

Was this helpful?

🚰
🍀
🕸️
🏷️
🗯️
How to Handle Actions Class in Selenium?Medium
Logo