本文整理汇总了Java中com.gistlabs.mechanize.document.html.form.Form.get方法的典型用法代码示例。如果您正苦于以下问题:Java Form.get方法的具体用法?Java Form.get怎么用?Java Form.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.gistlabs.mechanize.document.html.form.Form
的用法示例。
在下文中一共展示了Form.get方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: selectSchool
import com.gistlabs.mechanize.document.html.form.Form; //导入方法依赖的package包/类
private HtmlDocument selectSchool(String siteURL, String schoolId) throws SchoolNotFoundException {
MechanizeAgent agent = new MechanizeAgent();
HtmlDocument page = agent.get(siteURL);
Form schoolSelectionForm = page.forms().get(0);
Select schoolDropdown = (Select) schoolSelectionForm.get("PsiId");
List<Select.Option> schools = schoolDropdown.getOptions();
Select.Option schoolOption = null;
for(Select.Option school : schools) {
if (school.getValue().equals(schoolId)) {
schoolOption = school;
}
}
if (schoolOption != null) {
schoolOption.setSelected(true);
}
else {
throw new SchoolNotFoundException();
}
return schoolSelectionForm.submit();
}
示例2: login
import com.gistlabs.mechanize.document.html.form.Form; //导入方法依赖的package包/类
@Override
public HtmlDocument login(HtmlDocument authPage, String username, String password, Context context) throws SchoolAuthenticationFailedException {
Form authForm = authPage.form("aspnetForm");
Text usernameField = (Text) authForm.get("ctl00$ContentPlaceHolder1$UsernameTextBox");
Password passwordField = (Password) authForm.get("ctl00$ContentPlaceHolder1$PasswordTextBox");
usernameField.setValue(username);
passwordField.setValue(password);
HtmlDocument nvitRedirect = authForm.submit();
HtmlDocument submittedPage;
try {
HtmlDocument translinkRedirect = nvitRedirect.forms().get(0).submit();
LoggerUtil.appendLog(context, "translinkRedirect: " + translinkRedirect.getUri());
submittedPage = translinkRedirect.forms().get(0).submit();
LoggerUtil.appendLog(context, "submittedPage: " + submittedPage.getUri());
}
catch (Exception e) {
throw new SchoolAuthenticationFailedException(e);
}
if (submittedPage.getUri().contains("https://upassbc.translink.ca")) {
return submittedPage;
} else {
throw new SchoolAuthenticationFailedException(new Exception("Invalid submitted page URI"));
}
}
示例3: login
import com.gistlabs.mechanize.document.html.form.Form; //导入方法依赖的package包/类
@Override
public HtmlDocument login(HtmlDocument authPage, String username, String password, Context context) throws SchoolAuthenticationFailedException {
Form authForm = authPage.forms().get(0); // form has no id or name
Text usernameField = (Text) authForm.get("username");
Password passwordField = (Password) authForm.get("password");
usernameField.setValue(username);
passwordField.setValue(password);
HtmlDocument kuRedirect = authForm.submit();
HtmlDocument submittedPage;
try {
HtmlDocument translinkRedirect = kuRedirect.forms().get(0).submit();
LoggerUtil.appendLog(context, "translinkRedirect: " + translinkRedirect.getUri());
submittedPage = translinkRedirect.forms().get(0).submit();
LoggerUtil.appendLog(context, "submittedPage: " + submittedPage.getUri());
}
catch (Exception e) {
throw new SchoolAuthenticationFailedException(e);
}
if (submittedPage.getUri().contains("https://upassbc.translink.ca")) {
return submittedPage;
} else {
throw new SchoolAuthenticationFailedException(new Exception("Invalid submitted page URI"));
}
}
示例4: login
import com.gistlabs.mechanize.document.html.form.Form; //导入方法依赖的package包/类
@Override
public HtmlDocument login(HtmlDocument authPage, String username, String password, Context context) throws SchoolAuthenticationFailedException {
Form authForm = authPage.form("login");
Text usernameField = (Text) authForm.get("username");
Password passwordField = (Password) authForm.get("password");
usernameField.setValue(username);
passwordField.setValue(password);
HtmlDocument bcitRedirect = authForm.submit();
HtmlDocument submittedPage;
try {
HtmlDocument translinkRedirect = bcitRedirect.forms().get(0).submit();
LoggerUtil.appendLog(context, "translinkRedirect: " + translinkRedirect.getUri());
submittedPage = translinkRedirect.forms().get(0).submit();
LoggerUtil.appendLog(context, "submittedPage: " + submittedPage.getUri());
}
catch (Exception e) {
throw new SchoolAuthenticationFailedException(e);
}
if (submittedPage.getUri().contains("https://upassbc.translink.ca")) {
return submittedPage;
} else {
throw new SchoolAuthenticationFailedException(new Exception("Invalid submitted page URI"));
}
}
示例5: login
import com.gistlabs.mechanize.document.html.form.Form; //导入方法依赖的package包/类
@Override
public HtmlDocument login(HtmlDocument authPage, String username, String password, Context context) throws SchoolAuthenticationFailedException {
Form authForm = authPage.form("aspnetForm");
Text usernameField = (Text) authForm.get("ctl00_ContentPlaceHolder1_UsernameTextBox");
Password passwordField = (Password) authForm.get("ctl00_ContentPlaceHolder1_PasswordTextBox");
usernameField.setValue(username);
passwordField.setValue(password);
HtmlDocument cuRedirect = authForm.submit();
HtmlDocument submittedPage;
try {
HtmlDocument translinkRedirect = cuRedirect.forms().get(0).submit();
LoggerUtil.appendLog(context, "translinkRedirect: " + translinkRedirect.getUri());
submittedPage = translinkRedirect.forms().get(0).submit();
LoggerUtil.appendLog(context, "submittedPage: " + submittedPage.getUri());
}
catch (Exception e) {
throw new SchoolAuthenticationFailedException(e);
}
if (submittedPage.getUri().contains("https://upassbc.translink.ca")) {
return submittedPage;
} else {
throw new SchoolAuthenticationFailedException(new Exception("Invalid submitted page URI"));
}
}
示例6: login
import com.gistlabs.mechanize.document.html.form.Form; //导入方法依赖的package包/类
@Override
public HtmlDocument login(HtmlDocument authPage, String username, String password, Context context) throws SchoolAuthenticationFailedException {
Form authForm = authPage.form("fm1");
Text usernameField = (Text) authForm.get("username");
Password passwordField = (Password) authForm.get("password");
usernameField.setValue(username);
passwordField.setValue(password);
HtmlDocument ecuRedirect = authForm.submit();
HtmlDocument submittedPage;
try {
HtmlDocument translinkRedirect = ecuRedirect.forms().get(0).submit();
LoggerUtil.appendLog(context, "translinkRedirect: " + translinkRedirect.getUri());
submittedPage = translinkRedirect.forms().get(0).submit();
LoggerUtil.appendLog(context, "submittedPage: " + submittedPage.getUri());
}
catch (Exception e) {
throw new SchoolAuthenticationFailedException(e);
}
if (submittedPage.getUri().contains("https://upassbc.translink.ca")) {
return submittedPage;
} else {
throw new SchoolAuthenticationFailedException(new Exception("Invalid submitted page URI"));
}
}
示例7: login
import com.gistlabs.mechanize.document.html.form.Form; //导入方法依赖的package包/类
@Override
public HtmlDocument login(HtmlDocument authPage, String username, String password, Context context) throws SchoolAuthenticationFailedException {
Form authForm = authPage.form("aspnetForm");
Text usernameField = (Text) authForm.get("ctl00$ContentPlaceHolder1$UsernameTextBox");
Password passwordField = (Password) authForm.get("ctl00$ContentPlaceHolder1$PasswordTextBox");
usernameField.setValue(username);
passwordField.setValue(password);
HtmlDocument dcRedirect = authForm.submit();
HtmlDocument submittedPage;
try {
HtmlDocument translinkRedirect = dcRedirect.forms().get(0).submit();
LoggerUtil.appendLog(context, "translinkRedirect: " + translinkRedirect.getUri());
submittedPage = translinkRedirect.forms().get(0).submit();
LoggerUtil.appendLog(context, "submittedPage: " + submittedPage.getUri());
}
catch (Exception e) {
throw new SchoolAuthenticationFailedException(e);
}
if (submittedPage.getUri().contains("https://upassbc.translink.ca")) {
return submittedPage;
} else {
throw new SchoolAuthenticationFailedException(new Exception("Invalid submitted page URI"));
}
}
示例8: login
import com.gistlabs.mechanize.document.html.form.Form; //导入方法依赖的package包/类
@Override
public HtmlDocument login(HtmlDocument authPage, String username, String password, Context context) throws SchoolAuthenticationFailedException {
Form authForm = authPage.form("aspnetForm");
Text usernameField = (Text) authForm.get("ctl00$ContentPlaceHolder1$UsernameTextBox");
Password passwordField = (Password) authForm.get("ctl00$ContentPlaceHolder1$PasswordTextBox");
usernameField.setValue(username);
passwordField.setValue(password);
HtmlDocument vccRedirect = authForm.submit();
HtmlDocument submittedPage;
try {
HtmlDocument translinkRedirect = vccRedirect.forms().get(0).submit();
LoggerUtil.appendLog(context, "translinkRedirect: " + translinkRedirect.getUri());
submittedPage = translinkRedirect.forms().get(0).submit();
LoggerUtil.appendLog(context, "submittedPage: " + submittedPage.getUri());
}
catch (Exception e) {
throw new SchoolAuthenticationFailedException(e);
}
if (submittedPage.getUri().contains("https://upassbc.translink.ca")) {
return submittedPage;
} else {
throw new SchoolAuthenticationFailedException(new Exception("Invalid submitted page URI"));
}
}
示例9: login
import com.gistlabs.mechanize.document.html.form.Form; //导入方法依赖的package包/类
@Override
public HtmlDocument login(HtmlDocument authPage, String username, String password, Context context) throws SchoolAuthenticationFailedException {
Form authForm = authPage.form("loginForm");
Text usernameField = (Text) authForm.get("userNameInput");
Password passwordField = (Password) authForm.get("passwordInput");
usernameField.setValue(username);
passwordField.setValue(password);
HtmlDocument lcRedirect = authForm.submit();
HtmlDocument submittedPage;
try {
HtmlDocument translinkRedirect = lcRedirect.forms().get(0).submit();
LoggerUtil.appendLog(context, "translinkRedirect: " + translinkRedirect.getUri());
submittedPage = translinkRedirect.forms().get(0).submit();
LoggerUtil.appendLog(context, "submittedPage: " + submittedPage.getUri());
}
catch (Exception e) {
throw new SchoolAuthenticationFailedException(e);
}
if (submittedPage.getUri().contains("https://upassbc.translink.ca")) {
return submittedPage;
} else {
throw new SchoolAuthenticationFailedException(new Exception("Invalid submitted page URI"));
}
}
示例10: login
import com.gistlabs.mechanize.document.html.form.Form; //导入方法依赖的package包/类
@Override
public HtmlDocument login(HtmlDocument authPage, String username, String password, Context context) throws SchoolAuthenticationFailedException {
Form authForm = authPage.form("loginForm");
Text usernameField = (Text) authForm.get("j_username");
Password passwordField = (Password) authForm.get("password");
usernameField.setValue(username);
passwordField.setValue(password);
HtmlDocument ubcRedirect = authForm.submit();
HtmlDocument submittedPage;
try {
HtmlDocument translinkRedirect = ubcRedirect.forms().get(0).submit();
LoggerUtil.appendLog(context, "translinkRedirect: " + translinkRedirect.getUri());
submittedPage = translinkRedirect.forms().get(0).submit();
LoggerUtil.appendLog(context, "submittedPage: " + submittedPage.getUri());
}
catch (Exception e) {
throw new SchoolAuthenticationFailedException(e);
}
if (submittedPage.getUri().contains("https://upassbc.translink.ca")) {
return submittedPage;
} else {
throw new SchoolAuthenticationFailedException(new Exception("Invalid submitted page URI"));
}
}
示例11: login
import com.gistlabs.mechanize.document.html.form.Form; //导入方法依赖的package包/类
@Override
public HtmlDocument login(HtmlDocument authPage, String username, String password, Context context) throws SchoolAuthenticationFailedException {
Form authForm = authPage.form("fm1");
Text usernameField = (Text) authForm.get("username");
Password passwordField = (Password) authForm.get("password");
usernameField.setValue(username);
passwordField.setValue(password);
HtmlDocument sfuRedirect = authForm.submit();
HtmlDocument submittedPage;
try {
HtmlDocument translinkRedirect = sfuRedirect.forms().get(0).submit();
LoggerUtil.appendLog(context, "translinkRedirect: " + translinkRedirect.getUri());
submittedPage = translinkRedirect.forms().get(0).submit();
LoggerUtil.appendLog(context, "submittedPage: " + submittedPage.getUri());
}
catch (Exception e) {
throw new SchoolAuthenticationFailedException(e);
}
if (submittedPage.getUri().contains("https://upassbc.translink.ca")) {
return submittedPage;
} else {
throw new SchoolAuthenticationFailedException(new Exception("Invalid submitted page URI"));
}
}
示例12: findField
import com.gistlabs.mechanize.document.html.form.Form; //导入方法依赖的package包/类
private FormElement findField(Form loginForm, String name) {
final String PREFIX = "Etuile$MainContent$LoginControl$LoginForm$";
FormElement formElement = loginForm.get(PREFIX + name);
if (formElement == null)
throw new MatkakorttiException("Couldn't find field " + name + " in login form", true);
return formElement;
}