Is there any way to get the text from an alert in JavaScript?
Below I have attached the screenshot of an alert.
Actually I am trying to automate a website using selenium and java and selenium isn't able to handle such alert.
I wonder whether the JavaScript has solution to such alerts.
I am not aware of JavaScript syntax and code styling so posting only a question. Please excuse me for this.
driver.switchTo.alert().getText()
only works for if it is a JS alert,if it is browser alert then it doesn't work
ALERT EXAMPLE:

You should try this, with Selenium:
Alert alert = driver.switchTo().alert();
alert.getText();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With