use of com.hsn.epic4j.exception.CheckException in project epic4j by huisunan.
the class PasswordLogin method login.
@Override
@SneakyThrows
public void login(Page page, String email, String password) {
if (StrUtil.isEmpty(email)) {
throw new CheckException("账号不能为空");
}
if (StrUtil.isEmpty(password)) {
throw new CheckException(email + " 密码不能为空");
}
log.debug("login start");
PageUtil.click(page, "div.menu-icon");
PageUtil.click(page, "div.mobile-buttons a[href='/login']");
PageUtil.click(page, "#login-with-epic");
PageUtil.type(page, "#email", email);
PageUtil.type(page, "#password", password);
PageUtil.click(page, "#sign-in[tabindex='0']");
PageUtil.findSelectors(page, 30000, true, () -> {
throw new TimeException("Check login result timeout.");
}, new SelectItem("#talon_frame_login_prod[style*=visible]", () -> {
throw new PermissionException("CAPTCHA is required for unknown reasons when logging in");
}), new SelectItem("div.MuiPaper-root[role=alert] h6[class*=subtitle1]", () -> {
Object jsonValue = page.waitForSelector("div.MuiPaper-root[role=alert] h6[class*=subtitle1]").getProperty("textContent").jsonValue();
throw new PermissionException("From Epic Games: " + jsonValue);
}), new SelectItem("input[name=code-input-0]", () -> {
throw new PermissionException("From Epic Games need code");
}), new SelectItem(".signed-in", () -> {
log.info("login success");
return SelectItem.SelectCallBack.END;
}));
log.debug("login end");
}
Aggregations