JavaScript alert handling issue

Hi Team,

In JavaScript alert handling, we have written a common function for capturing the alert message with accepting the alert.

While handling the alert, alert message has been retrieved but before accepting the alert, it is getting hide and error message is thrown.

Please find the attached video file for your reference.

Alerthandling.zip (2.0 MB)

Please find the script for handling JavaScript alert.

alertmessage= WebUI.getAlertText()
WebUI.acceptAlert()

Kindly help me out to find a solution.

Is there any possible solution to accept the JavaScript alert.

1 Like

hi,

try to use Robot class
https://www.guru99.com/using-robot-api-selenium.html
or native selenium

1 Like