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


Java HtmlPasswordInput.setValueAttribute方法代码示例

本文整理汇总了Java中com.gargoylesoftware.htmlunit.html.HtmlPasswordInput.setValueAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java HtmlPasswordInput.setValueAttribute方法的具体用法?Java HtmlPasswordInput.setValueAttribute怎么用?Java HtmlPasswordInput.setValueAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.gargoylesoftware.htmlunit.html.HtmlPasswordInput的用法示例。


在下文中一共展示了HtmlPasswordInput.setValueAttribute方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mockLogin

import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput; //导入方法依赖的package包/类
public String mockLogin(URL url, String username, String password) {
	try {
		HtmlPage page1 = webClient.getPage(url.getURLValue());  
		// find the login form
        HtmlForm form = page1.getForms().get(0);  
        
        // fill in the input
        HtmlInput hi = form.getInputByName("commit");
        HtmlTextInput textField = form.getInputByName("login");  
        HtmlPasswordInput pass = form.getInputByName("password");  
        
        textField.click();
        textField.setValueAttribute(username);  
        pass.click();
        pass.setValueAttribute(password);  
      
        // push the button
        HtmlPage page2 = hi.click();  
        return page2.asXml();

	} catch(IOException ioe)  {
		ioe.printStackTrace();
		return null;
	}
}
 
开发者ID:knshen,项目名称:JSearcher,代码行数:26,代码来源:GithubLoginSimulator.java

示例2: loadPage

import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput; //导入方法依赖的package包/类
public void loadPage() {
	try {
		// Store cookies
		cookieManager = webClient.getCookieManager();
		page = webClient.getPage(URL);

		HtmlForm form = page.getFormByName("processLogonForm");
		HtmlSubmitInput button = form.getInputByName("Login");
		HtmlTextInput user = form.getInputByName("userName");
		HtmlPasswordInput pass = form.getInputByName("password");

		user.setValueAttribute(username);
		pass.setValueAttribute(password);

		page = button.click();
		if (page.asXml().contains("*  Please try again.")) {
			loginSuc = false;
			return;
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:zeshan321,项目名称:Project-D2L,代码行数:24,代码来源:D2LHook.java

示例3: logIn

import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput; //导入方法依赖的package包/类
private void logIn()throws IOException{
    final HtmlPage page = browser.getPage("http://codeforces.com/enter");
        
    final HtmlTextInput handle = (HtmlTextInput)page.getByXPath("//input[@id='handle']").get(0);
    final HtmlPasswordInput pass = (HtmlPasswordInput)page.getByXPath("//input[@id='password']").get(0);

    final HtmlSubmitInput btn = (HtmlSubmitInput)page.getByXPath("//input[@class='submit']").get(0);

    // Change the value of the text fields
    handle.setValueAttribute(user_name);
    pass.setValueAttribute(pass_word);

    // Now submit the form by clicking the button
    btn.click();
}
 
开发者ID:AmrSaber,项目名称:XC2,代码行数:16,代码来源:Server.java

示例4: login

import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput; //导入方法依赖的package包/类
public void login(JSONObject accountProperties){
    this.logger.info("네이버에 로그인합니다: " + accountProperties.getString("username"));

    try{
        final HtmlPage loginPage = this.getPage("https://nid.naver.com/nidlogin.login?url=");
        final HtmlForm loginForm = loginPage.getFormByName("frmNIDLogin");

        final HtmlTextInput     idInput     = loginForm.getInputByName("id");
        final HtmlPasswordInput pwInput     = loginForm.getInputByName("pw");
        final HtmlSubmitInput   loginButton = (HtmlSubmitInput) loginForm.getByXPath("//fieldset/span/input").get(0);

        final String id = accountProperties.getString("username");
        final String pw = accountProperties.getString("password");

        if(id.equals("") || pw.equals("")){
            this.logger.notice("네이버 로그인 불가: 계정 정보가 설정되어 있지 않습니다");
            return;
        }

        idInput.setValueAttribute(id);
        pwInput.setValueAttribute(pw);

        Elements errors = Jsoup.parse(((HtmlPage) loginButton.click()).asXml().replaceFirst("<\\?xml version=\"1.0\" encoding=\"(.+)\"\\?>", "<!DOCTYPE html>")).select("div.error");
        if(!errors.isEmpty()) this.logger.warning("네이버 로그인 실패: " + errors.text());
    }catch(Exception e){
        this.logger.warning("네이버 로그인 실패: " + e.getClass().getName() + ": " + e.getMessage());
    }

    this.close();
}
 
开发者ID:ChalkPE,项目名称:Takoyaki,代码行数:31,代码来源:Staff.java

示例5: removeAd

import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput; //导入方法依赖的package包/类
private static boolean removeAd(String adId)
{
    try
    {
        WebClient client = Client.get();
        String urlDelete = LinkFactory.AD_DELETE_LINK_1 + adId;
        Logger.traceINFO("URL for ad delete is : " + urlDelete);
        final HtmlPage deletePage1 = client.getPage(urlDelete);
        HtmlRadioButtonInput deleteRadioButton = (HtmlRadioButtonInput) deletePage1.getElementById("cmd_delete");
        deleteRadioButton.setChecked(true);

        HtmlSubmitInput continueButton = deletePage1.getElementByName("continue");
        final HtmlPage deletePage2 = continueButton.click();

        if (!deletePage2.asXml().contains("votre mot de passe tient compte des majuscules"))
        {
            Logger.traceERROR("Unknown error. Cannot remove ad with id : " + adId);
        }

        HtmlPasswordInput passwordInput = deletePage2.getElementByName("passwd");
        passwordInput.setValueAttribute(DefaultUserConf.PASSWORD);

        final HtmlSelect causeSelect = deletePage2.getElementByName("delete_reason");
        HtmlOption autreCauseSelect = causeSelect.getOptionByValue("5");
        causeSelect.setSelectedAttribute(autreCauseSelect, true);

        HtmlSubmitInput continueButton2 = deletePage2.getElementByName("continue");
        HtmlPage result = continueButton2.click();

        return result.asXml().contains("Votre annonce sera supprim") && result.asXml().contains("lors de la prochaine mise � jour");
    }
    catch (Exception e)
    {
        Logger.traceERROR(e);
        return false;
    }
}
 
开发者ID:philipperemy,项目名称:Leboncoin,代码行数:38,代码来源:AdRepublisher.java

示例6: getCallbackUrl

import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput; //导入方法依赖的package包/类
@Override
protected String getCallbackUrl(HtmlPage authorizationPage) throws Exception {
    HtmlForm form = authorizationPage.getForms().get(0);
    HtmlTextInput login = form.getInputByName("username");
    login.setValueAttribute("leleuj");
    HtmlPasswordInput passwd = form.getInputByName("password");
    passwd.setValueAttribute("leleuj");
    HtmlSubmitInput submit = form.getInputByName("submit");
    HtmlPage confirmPage = submit.click();
    HtmlAnchor allowLink = confirmPage.getAnchorByName("allow");
    HtmlPage callbackPage = allowLink.click();
    String callbackUrl = callbackPage.getUrl().toString();
    logger.debug("callbackUrl : {}", callbackUrl);
    return callbackUrl;
}
 
开发者ID:ameizi,项目名称:cas-oauth-example-3.5.x,代码行数:16,代码来源:TestCasWrapperProvider20.java

示例7: getConversation

import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput; //导入方法依赖的package包/类
public static WebClient getConversation() throws IOException, SAXException {
  final WebClient conversation = new WebClient();

  // always login first
  final Page loginPage = conversation.getPage(TestUtils.URL_ROOT
      + "login.jsp");
  Assert.assertTrue("Received non-HTML response from web server", loginPage.isHtmlPage());

  final HtmlPage loginHtml = (HtmlPage)loginPage;
  HtmlForm form = loginHtml.getFormByName("login");
  Assert.assertNotNull("Cannot find login form", form);

  final HtmlTextInput userTextField = form.getInputByName("user");
  userTextField.setValueAttribute(IntegrationTestUtils.TEST_USERNAME);

  final HtmlPasswordInput passTextField = form.getInputByName("pass");
  passTextField.setValueAttribute(IntegrationTestUtils.TEST_PASSWORD);

  final HtmlSubmitInput button = form.getInputByName("submit_login");
  final Page response = button.click();

  final URL responseURL = response.getUrl();
  final String address = responseURL.getPath();
  final boolean correctAddress;
  if (address.contains("login.jsp")) {
    correctAddress = false;
  } else {
    correctAddress = true;
  }
  Assert.assertTrue("Unexpected URL after login: "
      + address, correctAddress);

  return conversation;
}
 
开发者ID:jpschewe,项目名称:fll-sw,代码行数:35,代码来源:WebTestUtils.java


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