0
0
Selenium Javatesting~10 mins

Prompt alert text entry in Selenium Java - 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 prompt alert.

Selenium Java
Alert alert = driver.[1]();
Drag options to blanks, or click blank then click option'
AswitchTo().alert
BswitchTo().alert.get()
CswitchTo().alerts()
DswitchTo().alert()
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting parentheses after alert()
Using alerts() instead of alert()
Trying to access alert as a property without method call
2fill in blank
medium

Complete the code to send text to the prompt alert.

Selenium Java
alert.[1]("Hello World");
Drag options to blanks, or click blank then click option'
AsendKeys
BsetText
Ctype
DinputText
Attempts:
3 left
💡 Hint
Common Mistakes
Using setText or type which are not valid Alert methods
Trying to send keys directly to driver instead of alert
3fill in blank
hard

Fix the error in the code to accept the prompt alert after entering text.

Selenium Java
alert.sendKeys("Test");
alert.[1]();
Drag options to blanks, or click blank then click option'
Aconfirm
Bdismiss
Caccept
Dclose
Attempts:
3 left
💡 Hint
Common Mistakes
Using dismiss() which cancels the alert instead of accepting
Trying to use close() which is not a method of Alert
4fill in blank
hard

Fill both blanks to correctly handle a prompt alert by sending text and accepting it.

Selenium Java
Alert alert = driver.[1]();
alert.[2]("Selenium");
alert.accept();
Drag options to blanks, or click blank then click option'
AswitchTo().alert()
BsendKeys
CsetText
Ddismiss
Attempts:
3 left
💡 Hint
Common Mistakes
Using setText instead of sendKeys
Using dismiss instead of sendKeys for entering text
5fill in blank
hard

Fill all three blanks to switch to a prompt alert, send text, and accept it.

Selenium Java
Alert alert = driver.[1]();
alert.[2]("Test123");
alert.[3]();
Drag options to blanks, or click blank then click option'
AswitchTo().alert()
BsendKeys
Caccept
Ddismiss
Attempts:
3 left
💡 Hint
Common Mistakes
Using dismiss() instead of accept()
Forgetting parentheses on switchTo().alert()