UIAutomation: 登录界面测试实例

发表于:2014-5-13 11:04

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:qqgirllianxin    来源:51Testing软件测试网采编

  功能介绍:包括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);
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号