SessionLoginHelper { private void startLogin() throws BiliLiveException { try { status = NOT_COMPLETED; miniLoginPage = webClient.getPage(MINILOGIN_URL); miniLoginPage.executeJavaScript(LOGIN_JAVASCRIPT); webClient.setStatusHandler((page, message) -> { if (page == miniLoginPage) { parseStatus(message); } }); } catch (IOException ex) { throw new NetworkException("IO Exception", ex); } } SessionLoginHelper(@NotNull String email, @NotNull String password);  SessionLoginHelper(@NotNull String email, @NotNull String password, @NotNull String userAgent);  SessionLoginHelper(@NotNull String email, @NotNull String password,
                              long loginTimeoutMillis, boolean keepLoggingIn, @NotNull String userAgent); Image getCaptcha(); void loginWithCaptcha(String captcha); void fillSession(Session session); void setLoginTimeoutMillis(long loginTimeoutMillis); void setEmail(@NotNull String email); void setPassword(@NotNull String password); static final int DEFAULT_LOGIN_TIMEOUT_MILLIS; static final boolean DEFAULT_KEEP_LOGGING_IN; static final String LOGIN_JAVASCRIPT; static final String TRUST_STORE_PASSWORD; static final String MINILOGIN_URL; }
@Test public void startLogin() throws Exception { String email = testInput("E-Mail:"); String password = testInput("Password:"); SessionLoginHelper helper = new SessionLoginHelper(email, password); JOptionPane.showMessageDialog(null, "Captcha", "Captcha", JOptionPane.PLAIN_MESSAGE, new ImageIcon(helper.getCaptcha())); String captcha = testInput("Captcha:"); helper.loginWithCaptcha(captcha); assertEquals(SessionLoginHelper.LoginStatus.SUCCESS, helper.getStatus()); }