0
0
Selenium Pythontesting~10 mins

Simple alert acceptance 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 accept a simple alert popup.

Selenium Python
alert = driver.switch_to.alert
alert.[1]()
Drag options to blanks, or click blank then click option'
Adismiss
Bsend_keys
Ctext
Daccept
Attempts:
3 left
💡 Hint
Common Mistakes
Using dismiss() instead of accept() will cancel the alert.
Trying to send keys to a simple alert causes an error.
2fill in blank
medium

Complete the code to switch to the alert before accepting it.

Selenium Python
driver.[1].alert.accept()
Drag options to blanks, or click blank then click option'
Afind_element
Bswitch_to
Cexecute_script
Dget
Attempts:
3 left
💡 Hint
Common Mistakes
Using find_element tries to find a page element, not an alert.
execute_script runs JavaScript but does not switch focus.
3fill in blank
hard

Fix the error in the code to accept the alert correctly.

Selenium Python
alert = driver.switch_to.[1]
alert.accept()
Drag options to blanks, or click blank then click option'
Aalert
Balert()
Calerts
Dswitch
Attempts:
3 left
💡 Hint
Common Mistakes
Adding parentheses after alert causes a TypeError.
Using 'alerts' or 'switch' are invalid attributes.
4fill in blank
hard

Fill both blanks to switch to the alert and get its text.

Selenium Python
alert = driver.[1].[2]
text = alert.text
Drag options to blanks, or click blank then click option'
Aswitch_to
Bfind_element
Calert
Dalerts
Attempts:
3 left
💡 Hint
Common Mistakes
Using find_element instead of switch_to.
Using 'alerts' instead of 'alert'.
5fill in blank
hard

Fill all three blanks to switch to the alert, get its text, and accept it.

Selenium Python
alert = driver.[1].[2]
message = alert.[3]
alert.accept()
Drag options to blanks, or click blank then click option'
Aswitch_to
Btext
Calert
Ddismiss
Attempts:
3 left
💡 Hint
Common Mistakes
Using dismiss() instead of accept() to close the alert.
Trying to call text() as a method instead of accessing it as a property.