Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to switch to the prompt alert.
Selenium Python
alert = driver.switch_to.[1]() Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using driver.switch_to.prompt() which does not exist.
Trying to switch to frame or window instead of alert.
✗ Incorrect
Use driver.switch_to.alert() to access the alert box in Selenium.
2fill in blank
mediumComplete the code to send text 'hello' to the prompt alert.
Selenium Python
alert.[1]('hello')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using alert.type() or alert.write() which are not valid methods.
Trying to assign text directly to alert.
✗ Incorrect
Use alert.send_keys() to enter text into a prompt alert.
3fill in blank
hardFix the error in the code to accept the prompt alert.
Selenium Python
alert.[1]() Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using alert.confirm() or alert.ok() which do not exist.
Trying to use alert.submit() which is for forms.
✗ Incorrect
Use alert.accept() to accept or confirm the alert prompt.
4fill in blank
hardFill both blanks to get the alert text and then dismiss the alert.
Selenium Python
text = alert.[1] alert.[2]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using alert.get_text() which is not a valid method.
Using alert.close() which does not dismiss alerts.
✗ Incorrect
Use alert.text to get alert message and alert.dismiss() to cancel the alert.
5fill in blank
hardFill all three blanks to handle a prompt alert: switch, send text, and accept.
Selenium Python
alert = driver.switch_to.[1]() alert.[2]('test input') alert.[3]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using driver.switch_to.prompt() which is invalid.
Using alert.write() instead of send_keys.
Using alert.confirm() instead of accept().
✗ Incorrect
Switch to alert, send keys, then accept it using alert.accept().