qileilove

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

          改寫Selenium Web Driver Sample Code

            用Selenium WebDriver做網頁自動化測試已經不少時間,一直用的語言的Python,最近突然很想學習Java,于是自己搭了一個Eclipse+Selenium 2.32的開發環境。
            Sample代碼有一段如下,不是很好理解,
          (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
          public Boolean apply(WebDriver d) {
          return d.getTitle().toLowerCase().startsWith("cheese!");
          }
          });
            我把它重寫成了
          WebDriverWait WDW = new WebDriverWait(driver, 10);
          WDW.until(new theWait());
          //(new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
          //    public Boolean apply(WebDriver d) {
          //        return d.getTitle().toLowerCase().startsWith("cheese!");
          //    }
          //});
          // Should see: "cheese! - Google Search"
          public static class theWait implements ExpectedCondition<Boolean>{
          public Boolean apply(WebDriver d) {
          Boolean bool =  d.getTitle().toLowerCase().startsWith("cheese!");
          if(bool == true)
          {
          String title = d.getTitle();
          System.out.println("Page title is: " + title);
          }
          return bool;
          }
          }
            測試通過,可以做為一個Java函數override的小例子

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

          <2014年5月>
          27282930123
          45678910
          11121314151617
          18192021222324
          25262728293031
          1234567

          導航

          統計

          常用鏈接

          留言簿(55)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 鄂伦春自治旗| 吴忠市| 莱州市| 嘉黎县| 揭阳市| 大庆市| 凤山县| 靖江市| 平和县| 渝北区| 类乌齐县| 东台市| 宜丰县| 鹰潭市| 新密市| 老河口市| 崇州市| 民乐县| 祁连县| 屏边| 云阳县| 隆回县| 诸城市| 大宁县| 黎平县| 卢氏县| 崇明县| 娱乐| 宝丰县| 高清| 武穴市| 肥乡县| 凭祥市| 沙湾县| 张家港市| 化州市| 靖西县| 泾川县| 阳泉市| 凤台县| 老河口市|