How to handle application prompts
This example demonstrates how to handle the javascript prompt (also called as javascript dialog boxes) on the UI.
In the solution shown below, the click on the button "Click for JS Prompt" will display a javascript prompt on Worksoft SaaS Training application. You can answer by entering the value "This is Prompt" in the dialog box along with submitting the prompt.
Solution:
# | Command | Target | Value |
---|---|---|---|
To enter "This is Prompt" in the dialog box | |||
1 | answerOnNextPrompt |
This is Prompt | |
Click on the button "Click for JS Prompt" | |||
2 | click |
//button[.='Click for JS Prompt'] | |
Verify the prompt | |||
3 | assertPrompt |
I am a JS prompt. | |
Verify the text entered in the prompt | |||
4 | waitForText |
id=result | You entered: This is Prompt |
Tips, Tricks, Gotchas & Best Practices:
- As an alternative, you can also use the waitForPrompt or verifyPrompt commands to handle the prompts.