0
我使用htmlunit
從net.sourceforge.htmlunit
模擬網絡瀏覽器。我嘗試登錄蒸汽網絡應用程序,但我遇到了問題。設置憑據後我想用click
方法:Html單位沒有重定向點擊後
final WebClient webClient = new WebClient();
webClient.getOptions().setJavaScriptEnabled(true);
webClient.getOptions().setRedirectEnabled(true);
webClient.setCookieManager(new CookieManager());
final HtmlPage loginPage = webClient.getPage(loginPageConfiguration.getLoginPageUrl());
final HtmlTextInput user = loginPage.getHtmlElementById(loginPageConfiguration.getLoginInputId());
user.setText(loginCredentials.getUsername());
final HtmlPasswordInput password = loginPage.getHtmlElementById(loginPageConfiguration.getPasswordInputId());
password.setText(loginCredentials.getPassword());
final HtmlPage afterLoginPage = loginPage.getHtmlElementById(loginPageConfiguration.getLoginButtonId()).click();
在正常的瀏覽器succesfull登錄後重定向到http://store.steampowered.com/
但afterLoginPage
仍是以前的登錄頁面。
'的https:// store.steampowered.com/login'後sucesfull登錄它應該重定向到'HTTP:// store.steampowered.com /' – ByeBye
我試着在循環等待,或加上'waitForBackgroundJavaScript'但沒有工作。還有'webClient.setAjaxController(新的NicelyResynchronizingAjaxController());' – ByeBye
@ByeBye:Steam有一個安全功能並不是不可能的,它會禁用他們UI的自動化。 – Henrik