我正试图登录这个网站:
https://recordings.integralnet.pl/admin-panel/login?lang=en
我把登录&通过,但我无法点击"提交"按钮。它被禁用,直到两个文本输入都为空。我不知道如何启用它。你能帮助我吗?
WebClient webClient = new WebClient(BrowserVersion.CHROME);
try {
webClient.getOptions().setRedirectEnabled(true);
webClient.getOptions().setJavaScriptEnabled(true);
webClient.setAjaxController(new NicelyResynchronizingAjaxController());
HtmlPage page = webClient.getPage("https://recordings.integralnet.pl/admin-panel/login?lang=en");
webClient.waitForBackgroundJavaScript(1000);
System.out.println(page.asXml());
DomElement loginElement = page.getElementById("textfield-1010-inputEl");
loginElement.setAttribute("j_username", "myLogin");
DomElement passwordElement = page.getElementById("login-form-password-inputEl");
passwordElement.setAttribute("j_password", "myPassword");
webClient.waitForBackgroundJavaScript(1000);
DomElement submitElement = page.getElementById("button-1012");
submitElement.removeAttribute("disabled");
webClient.waitForBackgroundJavaScript(1000);
HtmlPage clickedPage = submitElement.click();
webClient.waitForBackgroundJavaScript(10000);
System.out.println(clickedPage.asXml());
} catch (IOException e) {
e.printStackTrace();
}
}
答案 0 :(得分:0)
试试这段代码:
WebClient webClient = new WebClient(BrowserVersion.CHROME);
try {
webClient.getOptions().setRedirectEnabled(true);
webClient.getOptions().setJavaScriptEnabled(true);
webClient.setAjaxController(new NicelyResynchronizingAjaxController());
HtmlPage page = webClient.getPage("https://recordings.integralnet.pl/admin-panel/login?lang=en");
webClient.waitForBackgroundJavaScript(1000);
System.out.println(page.asXml());
HtmlTextInput loginElement = (HtmlTextInput) page.getElementById("textfield-1010-inputEl");
loginElement.type("myLogin");
HtmlPasswordInput passwordElement = (HtmlPasswordInput) page.getElementById("login-form-password-inputEl");
passwordElement.type("myPass");
DomElement submitElement = page.getElementById("button-1012");
HtmlPage clickedPage = submitElement.click();
webClient.waitForBackgroundJavaScript(10000);
System.out.println(clickedPage.asText());
} catch (IOException e) {
e.printStackTrace();
}