posts - 165, comments - 198, trackbacks - 0, articles - 1
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          httpUnit 之使用其他web資源

          Posted on 2008-01-29 17:25 G_G 閱讀(451) 評論(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()?);
          ????}
          }

          主站蜘蛛池模板: 金沙县| 饶阳县| 抚州市| 大田县| 昭通市| 淮滨县| 罗甸县| 陆良县| 黄浦区| 锦屏县| 兴化市| 仙游县| 彝良县| 精河县| 浮山县| 遂川县| 丰县| 招远市| 汝南县| 兴文县| 东平县| 沅江市| 庆安县| 新建县| 花莲市| 会泽县| 松江区| 思茅市| 宁津县| 虹口区| 云阳县| 莒南县| 宣威市| 泗阳县| 潮州市| 海林市| 云浮市| 宾阳县| 澳门| 宁海县| 泸水县|