0
0
Selenium Javatesting~10 mins

Keyboard actions (keyDown, keyUp) in Selenium Java - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to press the SHIFT key down using Selenium Actions.

Selenium Java
Actions actions = new Actions(driver);
actions.[1](Keys.SHIFT).perform();
Drag options to blanks, or click blank then click option'
AkeyDown
BkeyUp
Cclick
DsendKeys
Attempts:
3 left
💡 Hint
Common Mistakes
Using keyUp instead of keyDown, which releases the key instead of pressing it.
Using sendKeys which types characters instead of pressing keys down.
2fill in blank
medium

Complete the code to release the SHIFT key after holding it down.

Selenium Java
Actions actions = new Actions(driver);
actions.keyDown(Keys.SHIFT).[1](Keys.SHIFT).perform();
Drag options to blanks, or click blank then click option'
AsendKeys
BkeyUp
Cclick
DdoubleClick
Attempts:
3 left
💡 Hint
Common Mistakes
Using sendKeys which types characters instead of releasing keys.
Using click which clicks the mouse instead of keyboard keys.
3fill in blank
hard

Fix the error in the code to hold CTRL key and press 'a' to select all text.

Selenium Java
Actions actions = new Actions(driver);
actions.keyDown(Keys.[1]).sendKeys("a").keyUp(Keys.CONTROL).perform();
Drag options to blanks, or click blank then click option'
AENTER
BSHIFT
CALT
DCONTROL
Attempts:
3 left
💡 Hint
Common Mistakes
Using SHIFT or ALT instead of CONTROL for select all.
Mismatching keys in keyDown and keyUp.
4fill in blank
hard

Fill both blanks to hold ALT, press TAB, then release ALT to switch windows.

Selenium Java
Actions actions = new Actions(driver);
actions.[1](Keys.[2]).sendKeys(Keys.TAB).keyUp(Keys.ALT).perform();
Drag options to blanks, or click blank then click option'
AkeyDown
BCONTROL
CALT
DkeyUp
Attempts:
3 left
💡 Hint
Common Mistakes
Using keyUp instead of keyDown to press the key.
Using CONTROL instead of ALT for window switching.
5fill in blank
hard

Fill all three blanks to hold SHIFT, type 'hello', then release SHIFT.

Selenium Java
Actions actions = new Actions(driver);
actions.[1](Keys.[2]).sendKeys("hello").[3](Keys.SHIFT).perform();
Drag options to blanks, or click blank then click option'
AkeyDown
BSHIFT
CkeyUp
DCONTROL
Attempts:
3 left
💡 Hint
Common Mistakes
Using CONTROL instead of SHIFT for uppercase typing.
Using keyUp before sendKeys which causes errors.