Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to press the Control key down.
Selenium Python
from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.common.keys import Keys actions = ActionChains(driver) actions.[1](Keys.CONTROL).perform()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
key_up instead of key_down.Using
send_keys which sends keys but does not hold them down.✗ Incorrect
The key_down method presses a key down without releasing it.
2fill in blank
mediumComplete the code to release the Control key after pressing it.
Selenium Python
actions = ActionChains(driver)
actions.key_down(Keys.CONTROL).[1](Keys.CONTROL).perform() Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
click which clicks the mouse, not keys.Using
send_keys which sends keys but does not release keys.✗ Incorrect
The key_up method releases a key that was pressed down.
3fill in blank
hardFix the error in the code to hold Shift, type 'a', then release Shift.
Selenium Python
actions = ActionChains(driver)
actions.key_down(Keys.SHIFT).send_keys([1]).key_up(Keys.SHIFT).perform() Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Sending uppercase 'A' which results in 'AA' because Shift is held.
Sending key constants instead of characters.
✗ Incorrect
When holding Shift, sending lowercase 'a' will produce uppercase 'A'. So the key sent should be lowercase 'a'.
4fill in blank
hardFill both blanks to press Control+C to copy text.
Selenium Python
actions = ActionChains(driver) actions.[1](Keys.CONTROL).send_keys([2]).key_up(Keys.CONTROL).perform()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using uppercase 'C' which may not work as expected.
Using
key_up instead of key_down to press Control.✗ Incorrect
Use key_down to press Control, send lowercase 'c' to copy, then release Control with key_up.
5fill in blank
hardFill all three blanks to press Control+Shift+S to save as.
Selenium Python
actions = ActionChains(driver) actions.[1](Keys.CONTROL).[2](Keys.SHIFT).send_keys([3]).key_up(Keys.SHIFT).key_up(Keys.CONTROL).perform()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
key_up to press keys down.Sending uppercase 'S' which duplicates Shift effect.
✗ Incorrect
Press Control and Shift down with key_down, send lowercase 's', then release Shift and Control.