Я хочу автоматизировать учетную запись google и принять oauth, чтобы получить код аутентификации.HtmlUnit Google Войти
Я получаю NullPointerExeption by nextButton.click(), я не могу найти «следующую» кнопку.
WebClient webClient = new WebClient(); //BrowserVersion.FIREFOX_38
HtmlPage page = webClient.getPage("https://accounts.google.com/o/oauth2/auth?");
HtmlTextInput email = (HtmlTextInput)page.getElementById("Email");
email.setValueAttribute(emailAddress);
HtmlSubmitInput nextButton = (HtmlSubmitInput)page.getElementById("next");
HtmlPage newPage = (HtmlPage)nextButton.click();
webClient.waitForBackgroundJavaScriptStartingBefore(8000);
HtmlTextInput passwd = (HtmlTextInput)page.getElementById("Passwd");
passwd.setValueAttribute(password);
HtmlSubmitInput signIn = (HtmlSubmitInput)page.getElementById("signIn");
HtmlPage pageSucces = (HtmlPage)signIn.click();
webClient.waitForBackgroundJavaScriptStartingBefore(8000);
HtmlSubmitInput submitAccess = (HtmlSubmitInput)page.getElementById("submit_approve_access");
HtmlPage pageAccess = (HtmlPage)submitAccess.click();
webClient.waitForBackgroundJavaScriptStartingBefore(8000);
HtmlTextInput code = (HtmlTextInput)page.getElementById("code");
System.out.println(code.getText());
Я попробовал этот Can't log in to Google using HtmlUnit - Can't advance to web page for entering password без успеха.