[英]Java / Android: simulate click on submit button (HTML)
I want to simulate a click on a website on a submit-type button 我想模拟一个提交式 按键网站上的点击
this is the code for now, but apparently it does not work: 这是现在的代码,但显然它不起作用:
String id = "x";
String pw = "y";
web.getSettings().setDomStorageEnabled(true);
web.loadUrl("javascript: {" +
"document.getElementsByName('authid')[0].value = '"+id +"';" +
"document.getElementsByName('authpw')[0].value = '"+pw +"';" +
"var submit = document.getElementsByClassName('inputbutton');" +
"submit[0].submit(); };");
and this is how it looks like: Screenshot of Emulator 这就是它的样子: 模拟器的截图
the code for the button on the website: 网站上按钮的代码:
<input type="submit" value="OK" class="inputbutton">
thanks in advance :) 提前致谢 :)
thanks for the vote up, I've got the answer: 谢谢你的投票,我得到了答案:
instead of submit[0].submit();
而不是
submit[0].submit();
in the last line of the first code part it has to be submit[0].click();
在第一个代码部分的最后一行,它必须
submit[0].click();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.