自动单击JavaFX Webview中的按钮 [英] Automatic clicking an button in JavaFX Webview
本文介绍了自动单击JavaFX Webview中的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用一个可以自动登录某些网站的JavaFX Web浏览器,我知道如何将数据设置为用户名和密码字段但是如何让它执行登录按钮点击?
这是我到目前为止所得到的:
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);
这是它应该点击的按钮的javascript代码:
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>
推荐答案
这是一个集中的,非专业的例子.. 。使用dom.w3c.Node。* package
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.
这篇关于自动单击JavaFX Webview中的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文