posts - 165, comments - 198, trackbacks - 0, articles - 1
            BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

          httpUnit 之使用其他web資源

          Posted on 2008-01-29 17:25 G_G 閱讀(450) 評(píng)論(0)  編輯  收藏 所屬分類: JUnit

          httpUnit
          package?httpUnit;

          import?com.meterware.httpunit.GetMethodWebRequest;
          import?com.meterware.httpunit.WebConversation;
          import?com.meterware.httpunit.WebForm;
          import?com.meterware.httpunit.WebRequest;
          import?com.meterware.httpunit.WebResponse;

          import?junit.framework.TestCase;

          public?class?HttpTest?extends?TestCase?{
          ????
          public?void?testT()?throws?Exception?{
          ????????WebConversation?wc?
          =?new?WebConversation();
          ????????WebRequest?????req?
          =?new?GetMethodWebRequest(?"http://www.baidu.com"?);
          ????????
          ????????WebResponse???resp?
          =?wc.getResponse(?req?);
          ????????
          //<input?type=submit?value=百度一下?id=sb>
          ????????
          //<input?type=text?name=wd?id=kw?size=36?maxlength=100>
          ????????WebForm?form?=?resp.getForms()[0];??????//?select?the?first?form?in?the?page
          ????????form.setParameter(?"wd",?"Italian"?);???
          ????????resp.getForms()[
          0].getSubmitButtonWithID("sb").click();

          ????????System.out.println(?wc.getCurrentPage().getText()?);
          ????}
          }

          主站蜘蛛池模板: 红安县| 永平县| 蒙阴县| 新和县| 伊通| 东山县| 比如县| 绥芬河市| 晴隆县| 教育| 广德县| 颍上县| 漳浦县| 泗水县| 开江县| 南丰县| 浮山县| 海安县| 泰来县| 青河县| 广汉市| 固镇县| 衡水市| 沙坪坝区| 二连浩特市| 嘉禾县| 密云县| 左贡县| 长春市| 梁平县| 中西区| 福鼎市| 石门县| 黄平县| 泾源县| 扎赉特旗| 萨迦县| 泾川县| 苗栗县| 禄劝| 沽源县|