JavaFX WebEngine How to save form values

I am using JavaFX WebEngine to implement OAuth to login to a website. Everything regarding the login process works fine, however, I noticed that the username and password are not remembered the next time you log in (as other web browsers do).

Is it possible to allow WebEngine to behave like other browsers (e.g. Chrome) in order to remember form information?

+4
source share
1 answer

If you wish, you can write the username / password to disk. After that, restore it and set the login / password to form (or install and send) via javascript, for example.

String javascript = new StringBuilder()
                .append("function submitData() {if(document.getElementsByName('email') == undefined) return; document.getElementsByName('email')[0].value='")
                .append(String.copyValueOf(authData.getEmail()))
                .append("'; document.getElementsByName('pass')[0].value='").append(String.copyValueOf(authData.getPassword()))
                .append("'; document.forms[0].submit();} submitData();").toString();

webEngine.executeScript(javascript);
-1

Source: https://habr.com/ru/post/1541630/


All Articles