我使用Htmlunit库连接到此网站http://www.tellmemorecampus.com/login.aspx
但是当我在HTML锚点上使用onclick方法时,什么也没发生...
这是我的代码:
HtmlTextInput emailField = login.getHtmlElementById("userNameText");
emailField.type(email); // works
HtmlPasswordInput passwordField = login.getHtmlElementById("passwordText");
passwordField.type(password); // works
HtmlAnchor submit = login.getHtmlElementById("btnSignIn");
HtmlPage result = submit.click(); // doesn't work
System.out.println(result.asText()); ```
I have this
``` Rosetta Stone
Choose an Interface Language
Rosetta Stone® Language Learning Suite
Rosetta Stone® Advantage
Welcome!
[email protected]
sqsqs
Sign In
Forgot your user name or password?
Terms and Conditions
Privacy Policy
Agreements
Help
Copyright © 2014 Rosetta Stone Ltd. All rights reserved. ```
Thank you.
最佳答案
尝试代替
HtmlPage result = submit.click();
此代码
HtmlPage result = submit.click();
webClient.waitForBackgroundJavaScript(10_000);
result = ((HtmlPage) result.getEnclosingWindow().getEnclosedPage());
如果仍然无法解决问题,请在https://github.com/HtmlUnit/htmlunit/issues上打开问题,然后通过我的私人邮件提供帐户数据。
关于java - HtmlUnit单击 anchor 时没有任何 react ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59447456/