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()?);
          ????}
          }

          主站蜘蛛池模板: 广河县| 克山县| 年辖:市辖区| 新和县| 木兰县| 灵石县| 尚义县| 瓮安县| 南汇区| 大关县| 东港市| 郸城县| 罗江县| 文昌市| 隆昌县| 溆浦县| 剑川县| 崇阳县| 息烽县| 宾川县| 汉川市| 河曲县| 兴隆县| 永善县| 漳浦县| 鸡西市| 积石山| 库尔勒市| 定兴县| 沙雅县| 犍为县| 门头沟区| 庆城县| 灌阳县| 彩票| 沙坪坝区| 临泉县| 雷州市| 儋州市| 黑水县| 宜宾县|