Automatic clicking an button in JavaFX Webview

browser, button, java, javafx, javascript

Solution

this is a concentrated, non-specialized example... uses the dom.w3c.Node.* package

HTMLInputElement element = (HTMLInputElement)myWebView.getEngine().getDocument().getElementsByTagName("input").item(0);
element.click();

Find a way to handle the object you're looking for, and it will work.

Problem

I am working an an JavaFX Webbrowser that can autologin to some sites, i know how to set the data to username and password fields but how to i make it execute the login button click? This is what i got so far: ``` String email = "document.getElementsByName('email')[0].value='MY_EMAIL';"; String pass = "document.getElementsByName('pass')[0].value='MY_PASSWORD';"; String login = ""; webEngine.executeScript(email); webEngine.executeScript(pass); webEngine.executeScript(login); ``` and this is the javascript code of the button it should click: ``` <label class="uiButton uiButtonConfirm" id="loginbutton" for="u_0_c"><input value="Aanmelden" tabindex="4" type="submit" id="u_0_c"></label> ```

Original source

Related problems