当前位置: 首页>>代码示例>>Java>>正文


Java Form.get方法代码示例

本文整理汇总了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();
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:21,代码来源:UPassLoader.java

示例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"));
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:30,代码来源:NVIT.java

示例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"));
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:30,代码来源:KwantlenUniversity.java

示例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"));
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:30,代码来源:BCIT.java

示例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"));
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:29,代码来源:CapilanoUniversity.java

示例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"));
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:30,代码来源:EmilyCarrUniversity.java

示例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"));
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:30,代码来源:DouglasCollege.java

示例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"));
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:30,代码来源:VancouverCommunityCollege.java

示例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"));
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:29,代码来源:LangaraCollege.java

示例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"));
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:29,代码来源:UniversityOfBritishColumbia.java

示例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"));
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:29,代码来源:SimonFraserUniversity.java

示例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;
}
 
开发者ID:dezgeg,项目名称:matkakortti-widget,代码行数:9,代码来源:MatkakorttiApi.java


注:本文中的com.gistlabs.mechanize.document.html.form.Form.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。