Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Selenium Essentials

You're reading from   Selenium Essentials Get to grips with automated web testing with the amazing power of Selenium WebDriver

Arrow left icon
Product type Paperback
Published in Mar 2015
Publisher
ISBN-13 9781784394332
Length 194 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
 Sams Sams
Author Profile Icon Sams
Sams
Arrow right icon
View More author details
Toc

Mouse and keyboard actions


In Selenium WebDriver, actions can be either mouse actions or keyboard actions. The selenium-based Actions API provides support to click on a particular location with or without elements and use keyboard shortcuts efficiently.

  • The build() method generates all the composite actions. The following is the syntax for this function:

    action.build();

    The following code snippet explains to you how you can generate actions using the build() method:

    Actions action = new Actions(driver);
    action.click(driver.findElement(By.locatorType("path")));
    action.build();
  • The click() method performs a mouse click on the current mouse pointer location. The following is the syntax for this function:

    action.click();
    action.click(driver.findElement(By.locatorType("path")));

    Unlike clicking on the mouse's current location, this function allows you to click on an element by locating it (using the Actions class). Please check the following snippet for both cases:

    driver.get("http://www.google.com"...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images