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

          httpUnit 之使用其他web資源

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

          主站蜘蛛池模板: 关岭| 美姑县| 富锦市| 乐至县| 黄山市| 镇宁| 巴林左旗| 新津县| 常宁市| 永靖县| 工布江达县| 鄄城县| 德惠市| 河北区| 吐鲁番市| 麻阳| 中山市| 当涂县| 呼和浩特市| 龙门县| 四平市| 尼木县| 鹤壁市| 尚义县| 安宁市| 宁海县| 宝坻区| 江门市| 宣化县| 略阳县| 保康县| 沙田区| 武平县| 城口县| 哈密市| 镶黄旗| 高唐县| 无棣县| 汉川市| 上饶市| 达拉特旗|