11、数据驱动测试中的测试设置与数据封装

数据驱动测试中的测试设置与数据封装

1. 测试方法中的异常处理与清理

在测试过程中,当测试方法调用页面对象方法失败,且此时有窗口或对话框处于打开状态时,需要进行异常处理和清理操作,以确保不影响后续测试运行。

以下是一个示例代码,展示了如何使用 try...catch...finally 块来捕获异常并关闭相关元素:

public class CreateUserTest {
    public class UserPO <M extends WebElement> {
        public UserPO() throws Exception {
        }
        @FindBy(id = "cancel")
        protected M cancel;
        public void createUser(JSONObject user) throws Exception {
        }
        public void verifyUser(String user) throws AssertionError {
        }
        public WebElement getCancel() {
            return cancel;
        }
    }
    // this test method cleans up in the method
    @Test
    public void tc001_createUser(String RowID,
         
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值