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

“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.

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 *