I'm looking for a different way to close an alert message other than accept()
or dismiss()
methods. How can I close an alert message by entering action through the keyboard?
1 Answer
I don't know your exact requirements in your software testing services but from question it seems you want to perform Enter key action through keyboard on a javascript popup. TO accomplish this use following code:
Alert alert = new Alert();
alert.sendkeys(Keys.RETURN);
or
alert.sendkeys(Keys.ENTER);
If that doesn't work you can use Enter key code and pass it to sendkeys, like this
alert.sendkeys(<<ENter key code>>);
Hope it helps.