qileilove

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

          改寫Selenium Web Driver Sample Code

            用Selenium WebDriver做網(wǎng)頁自動化測試已經不少時間,一直用的語言的Python,最近突然很想學習Java,于是自己搭了一個Eclipse+Selenium 2.32的開發(fā)環(huán)境。
            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函數(shù)override的小例子

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

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

          導航

          統(tǒng)計

          常用鏈接

          留言簿(55)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 苏尼特右旗| 福安市| 曲松县| 蕲春县| 全南县| 麻阳| 济阳县| 安阳县| 体育| 兴仁县| 塔城市| 新巴尔虎左旗| 工布江达县| 南城县| 天门市| 象州县| 永州市| 龙山县| 芜湖市| 呼伦贝尔市| 图们市| 扬中市| 张北县| 凤山市| 中山市| 福州市| 巴马| 莒南县| 郎溪县| 喀喇| 四川省| 大港区| 永丰县| 巴南区| 清水河县| 盐亭县| 鄯善县| 六安市| 高安市| 岳阳市| 烟台市|