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

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

          主站蜘蛛池模板: 灵武市| 汕尾市| 阿鲁科尔沁旗| 兰西县| 桐梓县| 海南省| 勐海县| 内丘县| 雷山县| 营口市| 和平县| 遵义县| 达拉特旗| 新兴县| 巫山县| 延长县| 伊金霍洛旗| 新龙县| 阳西县| 绵阳市| 富顺县| 招远市| 天台县| 兴和县| 顺义区| 长武县| 金沙县| 鸡西市| 佳木斯市| 肇东市| 日喀则市| 平顶山市| 寿宁县| 镇宁| 炎陵县| 乌兰浩特市| 乌恰县| 宝应县| 仁布县| 扎鲁特旗| 永丰县|