为什么 HtmlButton object.click() 在 HtmlUnit 中不起作用?
我从一个 html+javascipt 页面获得 htmlbutton,但我的代码不起作用(Eclipse 中的 JUnit+HtmlUnit) 代码是:
final HtmlPage page = (HtmlPage)webClient.getPage(url);
final HtmlForm form = page.getFormByName("registrationForm");
final HtmlButton button=(HtmlButton)page.getElementById("submit1");
final HtmlTextInput phone = form.getInputByName("phoneno");
phone.setValueAttribute("1234567890");
// Now submit the form by clicking the button and get back the second page.
final HtmlPage page2 = button.click(); //this doesn't work
final String pageAsXml = page2.asText();
System.out.println(pageAsXml);
注释“这不起作用”的行有一些问题。没有错误,但它不起作用。 webclient构造函数有问题吗?我们需要指定浏览器版本作为参数吗?这会在日食中工作吗?
i got htmlbutton from one html+javascipt page but my code does not work(JUnit+HtmlUnit in Eclipse)
The code is :
final HtmlPage page = (HtmlPage)webClient.getPage(url);
final HtmlForm form = page.getFormByName("registrationForm");
final HtmlButton button=(HtmlButton)page.getElementById("submit1");
final HtmlTextInput phone = form.getInputByName("phoneno");
phone.setValueAttribute("1234567890");
// Now submit the form by clicking the button and get back the second page.
final HtmlPage page2 = button.click(); //this doesn't work
final String pageAsXml = page2.asText();
System.out.println(pageAsXml);
the line commented "this doesn't work" has some problem.there is no error but it isn't working.
is there any problem with webclient constructor? do we need to specify browser version as argument? will this work in eclipse?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)