java 登录窗体案例_UIAutomation: 登录界面测试实例

这篇博客演示了如何使用UI自动化测试工具检查Java登录窗体的元素,包括用户名文本框、密码输入框和登录按钮的存在性。还测试了无效用户名和成功登录的情况。
摘要由CSDN通过智能技术生成

//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);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值