Use of “altKeyDown” and “altKeyUp” in selenium with example

Last updated on October 8th, 2025 at 11:36 am

“altKeyDown” command
“altKeyDown” command works just like you are pressing alt key of your keyboard. It will keep pressed alt key until “altKeyUp” not executed. You can use this command when you need to perform any action by pressing alt key.
Let me show you use of “altKeyDown” command with example. In bellow given example, altKeyDown command will press and hold alt key down then click command will click on targeted element.

New Test
Command Target Value
open https://www.google.co.in/
altKeyDown
click css=#gb_2 > span.gbts
altKeyUp

“altKeyUp” command

“altKeyUp” will release the pressed alt key. In above example, altKeyUp command will release pressed alt key using altKeyDown command.
author avatar
Aravind QA Automation Engineer & Technical Blogger
Aravind is a QA Automation Engineer and technical blogger specializing in Playwright, Selenium, and AI in software testing. He shares practical tutorials to help QA professionals improve their automation skills.
Stay Updated with New Articles
Get the latest tutorials and insights delivered to your inbox.

2 thoughts on “Use of “altKeyDown” and “altKeyUp” in selenium with example

  1. Hello,
    Pls clarify on the below:
    In the above example when executed altkeydown menu bar is not shown in google page .

    click css=#gb_2 > span.gbts(Are you clicking on menu bar or anywhere for the menu to go off)

Leave a Reply

Your email address will not be published. Required fields are marked *