qileilove

          blog已經轉移至github,大家請訪問 http://qaseven.github.io/

          Selenium WebDriver施用經驗雜記

           利用Javascript注入,來讀取不同Ajax調用框架的Ajax request status,一直等到Ajax調用全部返回才開始分析操作Dom元素
            演示代碼如下:
          protected void syncAjaxByJQuery(String timeout) {
          boolean isSucceed = false;
          try {
          selenium.waitForCondition(
          "selenium.browserbot.getCurrentWindow().jQuery.active == 0", timeout);
          isSucceed = true;
          } catch (SeleniumException se) {
          LOG.error(se);
          } catch (Exception re) {
          throw new RuntimeException(re.getMessage());
          }
          operationCheck(isSucceed);
          }
          protected void syncAjaxByPrototype(String timeout) {
          boolean isSucceed = false;
          try {
          selenium.waitForCondition(
          "selenium.browserbot.getCurrentWindow().Ajax.activeRequestCount == 0",
          timeout);
          isSucceed = true;
          } catch (SeleniumException se) {
          LOG.error(se);
          } catch (Exception re) {
          throw new RuntimeException(re.getMessage());
          }
          operationCheck(isSucceed);
          }
          protected void syncAjaxByDojo(String timeout) {
          boolean isSucceed = false;
          try {
          selenium.waitForCondition(
          "selenium.browserbot.getCurrentWindow().dojo.io.XMLHTTPTransport.inFlight.length == 0",
          timeout);
          isSucceed = true;
          } catch (SeleniumException se) {
          LOG.error(se);
          } catch (Exception re) {
          throw new RuntimeException(re.getMessage());
          }
          operationCheck(isSucceed);
          }
          Other Tips
            加載IEDriver的時候,通常會因為兼容模式的設置問題,而無法啟動,嘗試在創建IEDriver對象的時候,加入合適的參數設置:
          DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
          ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
          return new InternetExplorerDriver(ieCapabilities);

          posted on 2014-03-14 11:01 順其自然EVO 閱讀(357) 評論(0)  編輯  收藏 所屬分類: selenium and watir webdrivers 自動化測試學習

          <2014年3月>
          2324252627281
          2345678
          9101112131415
          16171819202122
          23242526272829
          303112345

          導航

          統計

          常用鏈接

          留言簿(55)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 新津县| 西畴县| 肥西县| 文山县| 贵定县| 芒康县| 金坛市| 长寿区| 武乡县| 奉节县| 固镇县| 黔南| 武强县| 海盐县| 南靖县| 吴江市| 安达市| 玉门市| 大新县| 漳浦县| 吴堡县| 枣强县| 九台市| 日喀则市| 衡阳市| 河间市| 自治县| 奉贤区| 惠水县| 凤城市| 渭源县| 庆安县| 吴川市| 岳普湖县| 南郑县| 区。| 磴口县| 广昌县| 郓城县| 巫溪县| 太康县|