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 閱讀(242) 評論(0)  編輯  收藏 所屬分類: selenium and watir webdrivers 自動化測試學習

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

          導航

          統計

          常用鏈接

          留言簿(55)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 封开县| 滦南县| 兖州市| 郧西县| 紫金县| 宜章县| 吐鲁番市| 宁国市| 齐齐哈尔市| 西和县| 无棣县| 千阳县| 屏东市| 肥城市| 阳江市| 清丰县| 临沭县| 灵璧县| 松阳县| 开封县| 石林| 铜鼓县| 清水县| 贵州省| 郴州市| 新巴尔虎右旗| 茌平县| 台南县| 静宁县| 拜泉县| 葵青区| 兴山县| 香河县| 丁青县| 婺源县| 江西省| 安西县| 沙河市| 红桥区| 香港 | 平谷区|