qileilove

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

          UIAutomation: 登錄界面測試實例

           功能介紹:包括2個文本輸入框,分別叫 User name 、 Password ,和一個按鈕,叫 Login。
            以下為測試腳本:
          //Get the handle of application main window
          var window = UIATarget.localTarget().frontMostApp().mainWindow();
          //Get the handle of view
          var view = window.elements()[0];
          var textfields = window.textFields();
          var passworldfields = window.secureTextFields();
          var buttons = window.buttons();
          var textviews = window.textviews();
          var statictexts = window.staticTexts();
          var target = UIATarget.localTarget();
          //Check number of Text fields
          if(textfields.length != 1)
          {
          UIALogger.logFail("FAIL: Invalid number of Text fields");
          }
          else
          {
          UIALogger.logpass("PASS: Correct number of Text fields");
          }
          //TESTCASE_001: Test Log on Screen
          //Check existence of desired TextField on UIScreen
          if(textfields["username"]==null || textfields["username"].toString() == "[object UIAELementNil]")
          {
          UIALogger.logFail("FAIL:Desired textfield not found.");
          }
          else
          {
          UIALogger.logPass("PASS: Desired UITextfield is available");
          }
          //TESTCASE_1.2:Check existence desired of PasswordField On UIScreen
          if(passwordfields[0] == null || passworldfields[0].toString() == "[object UIAElementNil]")
          {
          UIALogger.logFail("FAIL: Desired UISecureField not found.");
          }
          else
          {
          UIALogger.logPass("PASS: Desired UISecureField is available");
          }
          //TESTCASE_1.3 :Check for Existence of Buttons On UIScreen
          if(button["logon"] == null || buttons["logon"].toString() == "[object UIElementNil]")
          {
          UIALogger.logFail("FAIL:Desired UIButton not found.");
          }
          else
          {
          UIALogger.logPass("PASS:Desired UIButton is available");
          }
          //TESTCASE_001: Missing User Name
          textfields["username"].setValue("");
          passwordfields[0].setValue("password");
          buttons["logon"].tap();
          //target.delay(2);
          var errorVal = textviews["error"].value();
          if(errorVal != "Invalid User Name or PassWord")
          {
          UIALoger.logFail("Did Not Get Missing UserName Error:" + errorVal);
          }
          else
          {
          UIALogger.logPass("Missing User Name");
          }
          //TESTCASE_003: Successful Log On
          textfields["username"].setValue("username");
          passwordfields[0].setValue("password");
          buttons["logon"].tap();
          target.delay(2);

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

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

          導航

          統計

          常用鏈接

          留言簿(55)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 商洛市| 泰顺县| 绥德县| 涞水县| 黑河市| 岫岩| 淮阳县| 和静县| 太和县| 赣州市| 扶沟县| 河池市| 冷水江市| 黄大仙区| 久治县| 二手房| 广平县| 奈曼旗| 拜泉县| 通榆县| 乳源| 安顺市| 岳阳县| 恩施市| 泰宁县| 浪卡子县| 博客| 肥城市| 扎鲁特旗| 荣昌县| 时尚| 靖宇县| 祁阳县| 巩留县| 余江县| 鄄城县| 西林县| 曲松县| 临泽县| 甘孜县| 正镶白旗|