-1

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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.