I have a situation (during a selenium test), in which the user will receive a security code. The user must then input the security code before being allowed to continue.
It seems you have to accept and close the prompt first, before being able to store and use the value
alert.accept(); code = (String) js.executeScript("return window.promptResponse");