I'm looking for a different way to close an alert message other than
dismiss() methods. How can I close an alert message by entering action through the keyboard?
Alert alert = new Alert(); alert.sendkeys(Keys.RETURN);
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.