0
0
Selenium Pythontesting~10 mins

Confirmation alert handling 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 switch to the confirmation alert.

Selenium Python
alert = driver.switch_to.[1]()
Drag options to blanks, or click blank then click option'
Aconfirm()
Balert_switch
Calert()
Dalert
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting the parentheses after alert
Using incorrect method names like confirm or alert_switch
2fill in blank
medium

Complete the code to accept the confirmation alert.

Selenium Python
alert = driver.switch_to.alert()
alert.[1]()
Drag options to blanks, or click blank then click option'
Aaccept
Bdismiss
Cclose
Dsend_keys
Attempts:
3 left
💡 Hint
Common Mistakes
Using dismiss() which cancels the alert
Trying to use close() which is not valid for alerts
3fill in blank
hard

Fix the error in the code to dismiss the confirmation alert.

Selenium Python
alert = driver.switch_to.alert()
alert.[1]()
Drag options to blanks, or click blank then click option'
Aclose
Baccept
Cdismiss
Dcancel
Attempts:
3 left
💡 Hint
Common Mistakes
Using accept() instead of dismiss()
Using close() or cancel() which are not valid alert methods
4fill in blank
hard

Fill both blanks to get the alert text and then accept the alert.

Selenium Python
alert = driver.switch_to.[1]()
text = alert.[2]
alert.accept()
Drag options to blanks, or click blank then click option'
Aalert
Btext
Ddismiss
Attempts:
3 left
💡 Hint
Common Mistakes
Using dismiss() instead of alert() to switch
Trying to call text() as a method instead of property
5fill in blank
hard

Fill all three blanks to switch to alert, print its text, and dismiss it.

Selenium Python
alert = driver.switch_to.[1]()
print(alert.[2])
alert.[3]()
Drag options to blanks, or click blank then click option'
Aalert
Btext
Cdismiss
Daccept
Attempts:
3 left
💡 Hint
Common Mistakes
Calling text as a method with parentheses
Using accept() instead of dismiss() to cancel