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 阅读(1738) 评论(0)  编辑  收藏 所属分类: 测试学习专栏selenium and watir webdrivers 自动化测试学习


只有注册用户登录后才能发表评论。


网站导航:
 
<2014年5月>
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567

导航

统计

常用链接

留言簿(55)

随笔分类

随笔档案

文章分类

文章档案

搜索

最新评论

阅读排行榜

评论排行榜