Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
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.
✗ Incorrect
The keyDown method presses a key down without releasing it, which is needed to hold SHIFT.
2fill in blank
mediumComplete 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'
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.
✗ Incorrect
The keyUp method releases a key that was pressed down earlier.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using SHIFT or ALT instead of CONTROL for select all.
Mismatching keys in keyDown and keyUp.
✗ Incorrect
The keyDown and keyUp methods must use the same key. Here, CTRL is used to select all text with 'a'.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using keyUp instead of keyDown to press the key.
Using CONTROL instead of ALT for window switching.
✗ Incorrect
To switch windows, hold ALT key down, press TAB, then release ALT key.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using CONTROL instead of SHIFT for uppercase typing.
Using keyUp before sendKeys which causes errors.
✗ Incorrect
Hold SHIFT down to type uppercase 'HELLO', then release SHIFT key.