1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| private Scene createScene() {
Group root = new Group();
Scene scene = new Scene(root, 1000, 1000);
System.out.println("1");
webView = new WebView();
webView.setPrefSize(1000, 1000);
final WebEngine webEngine = webView.getEngine();
webEngine.setJavaScriptEnabled(true);
webEngine.getLoadWorker().stateProperty().addListener((observable, oldValue, newValue) -> {
System.out.printf("%s -> %s%n", oldValue, newValue);
switch (newValue) {
case SUCCEEDED:
System.out.println("Ok");
html_succeed = 1;
Document doc = webEngine.getDocument();
// /!\ String html = (String) webEngine.executeScript("document.documentElement.outerHTML");
Element el = doc.getElementById("Email");
System.out.println(el);
el.setAttribute("value", "******@gmail.com");
Element btn = doc.getElementById("next");
((HTMLInputElement) btn).click();
webEngine.load(webView.getEngine().getLocation());
break;
case FAILED:
final Throwable ex = webEngine.getLoadWorker().getException();
ex.printStackTrace();
break;
}
});
webEngine.load("https://accounts.google.com/ServiceLogin/identifier?flowName=GlifWebSignIn&flowEntry=ServiceLogin");
root.getChildren().add(webView);
GridPane.setHgrow(webView, Priority.ALWAYS);
GridPane.setVgrow(webView, Priority.ALWAYS);
return scene;
} |
Partager