N NextGen Virtual Academy
AD Administrator Learning Manager
SELENIUM WEBDRIVER · PRACTICE LAB

Keyboard Actions

Practice keyboard interactions using Selenium WebDriver's Actions class and Keys class.

LAB KEYS
OBJECTIVE

What You Will Practice

  • Press Enter.
  • Navigate using Tab.
  • Use Escape.
  • Use Arrow Keys.
  • Select text using Ctrl + A.
  • Copy and paste text.
  • Practice keyboard shortcuts.
  • Use Selenium Keys and Actions.
01

Enter Key

Type a value and press Enter to submit the input.

ENTER
Selenium Command element.sendKeys("Selenium", Keys.ENTER);
02

Tab Key

Move focus from one field to the next using the Tab key.

TAB
Selenium Command element.sendKeys(Keys.TAB);
03

Escape Key

Open the popup and use Escape to close it.

ESCAPE

Keyboard Popup

Press Escape to close this popup.

Selenium Command actions.sendKeys(Keys.ESCAPE).perform();
04

Arrow Keys

Use arrow keys to move the selection around the grid.

ARROWS

Click the grid and use the Arrow Keys.

Selenium Command actions.sendKeys(Keys.ARROWDOWN).perform();
actions.sendKeys(Keys.ARROWRIGHT).perform();
05

Ctrl + A

Select all text inside the input field using Ctrl + A.

CTRL + A
Selenium Command element.sendKeys(Keys.CONTROL, "a");
06

Copy & Paste

Copy text from one field and paste it into another field.

COPY / PASTE
Selenium Command source.sendKeys(Keys.CONTROL, "a");
source.sendKeys(Keys.CONTROL, "c");
target.sendKeys(Keys.CONTROL, "v");
07

Keyboard Shortcuts

Practice common keyboard shortcuts used in browser automation.

SHORTCUTS
QUICK REFERENCE

Selenium Keyboard Commands

Enter
element.sendKeys(
    Keys.ENTER
);
Tab
element.sendKeys(
    Keys.TAB
);
Escape
actions.sendKeys(
    Keys.ESCAPE
).perform();
Ctrl + A
element.sendKeys(
    Keys.CONTROL,
    "a"
);
Copy
element.sendKeys(
    Keys.CONTROL,
    "c"
);
Paste
element.sendKeys(
    Keys.CONTROL,
    "v"
);