密码字段将被禁用,直到您在该
username字段中键入内容为止。通过在用户名中设置值不会触发管理密码字段启用的事件。
下面的作品
public static void main(String[] args) { WebClient webClient = new WebClient(); try { HtmlPage page = (HtmlPage) webClient .getPage("https://ma-andover.myfollett.com/aspen/logon.do"); HtmlForm form = page.getFormByName("logonForm"); form.getInputByName("username").setValueAttribute("myUsername"); HtmlInput passWordInput = form.getInputByName("password"); passWordInput.removeAttribute("disabled"); passWordInput.setValueAttribute("myPassword"); page = form.getInputByValue("Log On").click(); // works fine System.out.println(page.asText()); } catch (Exception e) { e.printStackTrace(); } finally { webClient.close(); }}输出是
Aspen: Log onAspen about AspenAndover Public SchoolsLogin ID myUsername Password I forgot my passwordLog onCopyright © 2003-2014 Follett School Solutions. All rights reserved.Follett Corporation Follett Software Company Aspen Terms of UseInvalid login. OK



