我是靠谱客的博主 斯文豆芽,这篇文章主要介绍Groovy面向对象:定义方法的入参,现在分享给大家,希望可以做个参考。

某个页面需要填写的字段比较多,需要定义一个类来封装入参,本页面有一个嵌入的iframe,方法如下:
1、定义页面元素(iframe页面)

复制代码
1
2
3
4
5
6
7
8
9
//输入驾驶证姓名 driverNameInput { $('input', id: 'editor_name') } //输入驾驶人身份证号 driverIDCardInput { $('input', id: 'editor_driverId') } //点击保存按钮 driverSaveButton{$('a#btSaveDrivers').parent().$('span.l-btn-left') }

2、定义方法,填写参数或者某些点击的元素(iframe页面)

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/** * 客户信息页面操作TenantInformation为入参 */ def addTenantInformation(TenantInformation tenantInformation) { log.info("填写所有承租人信息") //填写承租人姓名、身份证号码 czrnamelInput << tenantInformation.LesseeName czrsfzInput << tenantInformation.IdentityNumber houseNatureSelectButton.click() houseNatureSelectClick.click() //承租人手机号码 mobilePhoneInput << tenantInformation.MobilePhone nationalitySelectButton.click() nationalitySelectClick.click()

3、定义一个class,类名为TenantInformation(单独的类)

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package com.cainiao.uitest.scf.Car.Page.dos /** * 封装类,客户信息页面需要输入的字段 */ class TenantInformation { String LesseeName //承租人姓名 String IdentityNumber //身份证号码 String MobilePhone //承租人手机号码 String LivingAddress //居住地详细地址 String HouseholdRegistrationAddress //输入户籍地址 String CompanyName //单位信息:单位名称 String EmploymentDate //输入入职日期 String UnitAddress //单位地址 String FixedTelephone //固定电话

}

4、page页面引用iframe页面的方法(page页面),这里保存嵌入iframe页面如何方法引用

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class CustomerInformationPage extends Page { static at = {$('span.tabs-title',2).text() == '客户信息'} static content = { loginFrame(page: CustomerInformationPageIFrame) { $(By.xpath('//*[@url="/ifincars/sales/apply/jsp/ApplyCustomInfo.jsp"]')) } } //调用CustomerInformationPageIFrame页面封装的方法,填写客户全部信息 def AddTenantInformation(TenantInformation tenantInformation){ withFrame(loginFrame) { //填写基本信息 addTenantInformation(tenantInformation) //增加驾驶人 newDrivers("测试驾驶人","110101199003070628") //增加联系人1 newContacts("测试一号","15704789740") //增加联系人2号 newContacts("测试二号","15703124561") //点击保存 save() } } }

5、在实际用例中,再给类TenantInformation塞值
创建对象并赋值、引用

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//新建对象并赋值 static PersonalGuarantorInfo info = new PersonalGuarantorInfo( guarantorName:"自动化测试", IDCard:"110101198001011574", PhoneNumber:"15708234567", LiveAddress:"南京路128号", AccountAddress:"南京东路节能小区", CompanyName:"车辆金融大项目", CompanyAddress:"公司地址", MonthlyLiability:"10000", MonthlyIncome:"50000" ) //在方法中引用对象 def PersonalGuarantor(){ withFrame(loginFrame){ personalGuarantor(info) } }

最后

以上就是斯文豆芽最近收集整理的关于Groovy面向对象:定义方法的入参的全部内容,更多相关Groovy面向对象:定义方法内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(83)

评论列表共有 0 条评论

立即
投稿
返回
顶部