0
0
Selenium Pythontesting~10 mins

Key combinations (key_down, key_up) in Selenium Python - 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 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'
Akey_down
Bkey_up
Cclick
Dsend_keys
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.
2fill in blank
medium

Complete 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'
Akey_up
Bdouble_click
Csend_keys
Dclick
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.
3fill in blank
hard

Fix 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'
A'A'
B'a'
CKeys.ALT
DKeys.SHIFT
Attempts:
3 left
💡 Hint
Common Mistakes
Sending uppercase 'A' which results in 'AA' because Shift is held.
Sending key constants instead of characters.
4fill in blank
hard

Fill 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'
Akey_down
Bkey_up
C'c'
D'C'
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.
5fill in blank
hard

Fill 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'
Akey_down
Bkey_up
C's'
D'S'
Attempts:
3 left
💡 Hint
Common Mistakes
Using key_up to press keys down.
Sending uppercase 'S' which duplicates Shift effect.