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
Hi, I’m Aravind — a seasoned Automation Test Engineer with over 17 years of hands-on experience in the software testing industry. I specialize in tech troubleshooting and tools like Selenium, Playwright, Appium, JMeter, and Excel automation. Through this blog, I share practical tutorials, expert tips, and real-world insights to help testers and developers improve their automation skills.In addition to software testing, I also explore tech trends and user-focused topics, including Snapchat guides, codeless test automation, and more.
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 *