您的位置:首页 > 编程语言 > Python开发

python2.7基于selenium的web自动化测试项目--contract

2017-06-15 09:48 561 查看
#HouseContracPage.py

#新增委托合同

# -*- coding:utf8 -*-

from base.Base import Base
from base import Page
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException
import time
from base.Base import log
from base.Base import consoleLog

class HouseContractPage(Base):
houseSearchMould = {
'residential_name_loc' : (By.ID,'residential_name_house_code_search'),
'search_button_loc' : (By.ID,'search_btn'),
'tr_house' : (By.CSS_SELECTOR,'tr[datagrid-row-index="0"]'),
'add_house_contract_button' : (By.CSS_SELECTOR,'#edit_btn + button')
}
contractSearchMould = {
'contract_num_loc': (By.CSS_SELECTOR, '#contract_num_search + span > input:nth-child(1)'),
'search_button_loc': (By.ID, 'search_btn'),
'tr_contract': (By.CSS_SELECTOR, 'tr[datagrid-row-index="0"]'),
'edit_loc': (By.ID, 'edit_btn')
}
addHouseContractMould = {
'edit_loc' : (By.CSS_SELECTOR,'#edit_btn + button'), #列表页加载的等待元素
'delete_button': (By.ID, 'del_btn'),  # 删除
'delete_button_confirm': (By.CSS_SELECTOR, '.dialog-button.messager-button > a:nth-child(1) > span'),  # 删除确认
#合同信息
'tab_info_loc' : (By.CSS_SELECTOR ,'.tabs-inner'), #0-合同信息、1-租金明细、2-业主信息、3-资料上传
'inside_space_loc' : (By.CSS_SELECTOR ,'#first_contract_base > table > tbody > tr:nth-child(3) > td:nth-child(4) > span > input:nth-child(1)'), #使用面积
'rent_loc' : (By.CSS_SELECTOR, 'input#rent + span > input:nth-child(1)'),   #房租
'parking_loc' : (By.CSS_SELECTOR, 'input#parking+ span > input:nth-child(1)'),  #车位费
'service_fee_loc' : (By.CSS_SELECTOR, 'input#year_service_fee + span > input:nth-child(1)'),    #服务费
'pledge_loc' : (By.ID,'pledge'),     #抵押情况-有
'contract_num_loc' : (By.CSS_SELECTOR,'input#contract_num + span >input:nth-child(1)'),  #合同编号
'payment_cycle_loc_1' : (By.CSS_SELECTOR,'input#payment_cycle + span > span > a'), #付款周期
'payment_cycle_loc_2': (By.CSS_SELECTOR, 'body > div:nth-child(44) > div >div:nth-child(1)'),  # 月付
'next_loc_1' : (By.ID,'form_btn'), #合同信息下一步
#租金明细
'rent_detail_selectAll' : (By.CLASS_NAME,'check-all'),  #租金明细全选
'rent_audit_loc' : (By.ID,'payableAudit'),  #租金审核
'audit_pass_loc' : (By.CSS_SELECTOR,'[value="AUDITED"]'),   #审核通过
'rent_audit_confirm' : (By.CSS_SELECTOR,'[onclick="customer_pay.AuditButtonConfirm()"]'),    #租金审核确认
'next_loc_2': (By.ID, 'form_next_btn'),  # 租金明细下一步
#业主信息
'landlord_name_loc' : (By.CSS_SELECTOR,'td[field="landlord_name"]>div>table>tbody>tr>td>span>input:nth-child(1)'),  #业主姓名
'landlord_card_loc': (By.CSS_SELECTOR, 'td[field="id_card"]>div>table>tbody>tr>td>span>input:nth-child(1)'),  #业主证件号码
'landlord_phone_loc': (By.CSS_SELECTOR, 'td[field="phone"]>div>table>tbody>tr>td>span>input:nth-child(1)'),  # 业主联系电话
'landlord_address_loc': (By.CSS_SELECTOR, 'td[field="mailing_address"]>div>table>tbody>tr>td>span>input:nth-child(1)'), #业主通讯地址
'signFlag_loc': (By.CSS_SELECTOR, 'td[field="signFlag"]>div>input'),    #是否签约人
#签约人信息
'address_loc':(By.CSS_SELECTOR,'input#address + span > input:nth-child(1)'),    #签约人通讯地址
'email_loc': (By.CSS_SELECTOR, 'input#email + span > input:nth-child(1)'),  # 签约人电子邮件
'other_contact_loc': (By.CSS_SELECTOR, 'input#other_contact + span > input:nth-child(1)'),  # 签约人其他联系方式
#紧急联系人
'emergency_name_loc': (By.CSS_SELECTOR, 'input#emergency_name + span > input:nth-child(1)'),  # 联系人姓名
'emergency_phone_loc': (By.CSS_SELECTOR, 'input#emergency_phone + span > input:nth-child(1)'),  # 联系人电话
'emergency_id_card_loc': (By.CSS_SELECTOR, 'input#emergency_id_card + span > input:nth-child(1)'),  # 证件号
'emergency_address_loc': (By.CSS_SELECTOR, 'input#emergency_address + span > input:nth-child(1)'),  # 通讯地址
#收款人信息
'account_bank_loc': (By.CSS_SELECTOR, 'input#account_bank + span > input:nth-c
1fff8
hild(1)'),  # 通讯地址
'account_num_loc': (By.CSS_SELECTOR, 'input#account_num + span > input:nth-child(1)'),  # 通讯地址
'next_loc_3':(By.CSS_SELECTOR,'#owner_button > div > p > button#form_btn'),    #业主信息下一步
# 资料上传
'submit_loc' : (By.CSS_SELECTOR, '#imageupload_button > div > p > button'),
#审核相关
'chushen_loc' : (By.CSS_SELECTOR,'button[status="PASS"]'),  #初审,index=1
'fushen_loc': (By.CSS_SELECTOR, 'button[status="APPROVED"]'),  # 复审,index=1
'bohui_loc': (By.CSS_SELECTOR, 'button[status="REJECTED"]'),  # 驳回,index=1
'contract_audit_content' : (By.ID,'iszCommonWorkflowContext'),  #合同审核意见
'contract_audit_confirm' : (By.ID,'iszCommonWorkflowPageSure') #合同审核确认
}

typeMould = {
#合同信息
'property_type' : '#property_type', #产权类型
'apartment_type' : '#apartment_type',   #公寓类型
'reform_way': '#reform_way',    #改造方式
'entrust_type': '#entrust_type',    #合同类型
'sign_body': '#sign_body',  #签约公司
'sign_date':'#sign_date',   #签约日期
'owner_sign_date': '#owner_sign_date',  #业主交房日
'fitment_start_date': '#fitment_start_date',    #装修起算日
'fitment_end_date': '#fitment_end_date',    #装修截止日
'entrust_start_date': '#entrust_start_date',    #委托起算日
'entrust_end_date': '#entrust_end_date',    #委托到期日
'delay_date': '#delay_date',    #延长到期日
'freeType': '#freeType',    #免租期类别
'free_start_date': '#free_start_date',  #免租开始日
'free_end_date':'#free_end_date',    #免租到期日
'first_pay_date': '#first_pay_date',    #首次付款日
'second_pay_date': '#second_pay_date',  #第二次付款日
'payment_cycle': '#payment_cycle',   #付款周期
#业主信息
'ownerCardType':'td[field="ownerCardType"] > div > table > tbody > tr > td > input',    #业主证件类型
#签约人信息
'gender':'#gender',  #性别
'card_type':'#card_type',   #签约人证件类型
#紧急联系人
'emergency_card_type': '#emergency_card_type',  # 证件类型
#收款人信息
'account_name': '#account_name'  # 证件类型
}
@log
def addHouseContract(self):
"""新增委托合同"""
self.open(Page.devHousePage,self.addHouseContractMould['edit_loc'])
self.input_text(self.houseSearchMould['residential_name_loc'],'AutoTest')
#审核房源之后,solr的增量需要时间,所以在此需要多次等待,首次查询后没有发现房源,则等待一分钟后再次查询,重复五次,一旦某次查询后,发现了房源,则结束循环
for i in range(1,11):
self.click(self.houseSearchMould['search_button_loc'])
time.sleep(1)
try:
test = self.driver.find_element(*self.houseSearchMould['tr_house'])
if i > 1:
consoleLog('已查找到数据')
break
            except:
info = '未找到house-core的solr增量房源数据,尝试第%s次查找' % i
consoleLog(info ,level='WARNING')
time.sleep(5)
#self.script("$('#edit_btn + button')[0].click()")   #点击列表页第一行的新增委托
#合同信息
self.click(self.houseSearchMould['add_house_contract_button'],index=0)
self.input_text(self.addHouseContractMould['inside_space_loc'],100)
self.type_select(self.typeMould['property_type'],'HAVECARD')   #有产证商品房
self.click(self.addHouseContractMould['pledge_loc'])
self.type_select(self.typeMould['apartment_type'],'BRAND')  #品牌公寓
self.type_select(self.typeMould['reform_way'],'OLDRESTYLE')    #老房全装
self.type_select(self.typeMould['entrust_type'],'SHARE')    #合租
self.input_text(self.addHouseContractMould['contract_num_loc'],'AutoTest')
self.type_select(self.typeMould['sign_body'],'ISZTECH')    #杭州有限公司
self.type_date(self.typeMould['sign_date'], '2017-02-01')
self.type_date(self.typeMould['owner_sign_date'], '2017-02-01')
self.type_date(self.typeMould['fitment_start_date'], '2017-02-01')
self.type_date(self.typeMould['fitment_end_date'], '2017-02-28')
self.type_date(self.typeMould['entrust_start_date'], '2017-02-01')
self.type_date(self.typeMould['entrust_end_date'], '2020-02-29')
self.type_date(self.typeMould['delay_date'], '2020-05-31')
self.type_select(self.typeMould['freeType'],'STARTMONTH')  #首月
self.type_date(self.typeMould['free_start_date'], '2017-02-01')
self.type_date(self.typeMould['free_end_date'], '2017-02-01')
self.type_date(self.typeMould['first_pay_date'], '2017-02-28')
self.type_date(self.typeMould['second_pay_date'], '2017-03-01')
self.input_text(self.addHouseContractMould['rent_loc'],4321,first=False)
self.input_text(self.addHouseContractMould['parking_loc'],123)
self.input_text(self.addHouseContractMould['service_fee_loc'],234,first=False)
#self.type_select(self.typeMould['payment_cycle'], '半年付')   因为租金策略的机制是点击付款周期后触发,直接赋值不会触发,所以此select不直接赋值,采用点击方式
self.click(self.addHouseContractMould['payment_cycle_loc_1'])
self.click(self.addHouseContractMould['payment_cycle_loc_2'])
self.click(self.addHouseContractMould['next_loc_1'])
self.click(self.addHouseContractMould['next_loc_2'])
#业主信息
self.input_text(self.addHouseContractMould['landlord_name_loc'],'AutoTest')
self.type_select(self.typeMould['ownerCardType'],'IDNO')    #身份证
self.input_text(self.addHouseContractMould['landlord_card_loc'], '42062119910828541X')
self.click(self.addHouseContractMould['landlord_name_loc'])
self.input_text(self.addHouseContractMould['landlord_phone_loc'],'13666666666')
self.click(self.addHouseContractMould['landlord_name_loc'])
self.input_text(self.addHouseContractMould['landlord_address_loc'], u'浙江省杭州市')
self.click(self.addHouseContractMould['signFlag_loc'])
time.sleep(0.5)
#签约人信息
self.type_select(self.typeMould['card_type'],'IDNO')    #身份证
self.type_select(self.typeMould['gender'],'MALE')   #男
self.input_text(self.addHouseContractMould['email_loc'],'test@mail.com')
self.input_text(self.addHouseContractMould['other_contact_loc'],u'浙江省杭州市')
#紧急联系人
self.input_text(self.addHouseContractMould['emergency_name_loc'],u'紧急联系人')
self.input_text(self.addHouseContractMould['emergency_phone_loc'],'13777777777')
self.type_select(self.typeMould['emergency_card_type'],'IDNO')  #身份证
self.input_text(self.addHouseContractMould['emergency_id_card_loc'],'411722197508214014')
self.input_text(self.addHouseContractMould['emergency_address_loc'],u'浙江省杭州市')
#收款人信息
self.type_select(self.typeMould['account_name'],'AutoTest')
self.input_text(self.addHouseContractMould['account_bank_loc'],u'农业银行')
self.input_text(self.addHouseContractMould['account_num_loc'],'1234567890')
self.click(self.addHouseContractMould['next_loc_3'])
self.click(self.addHouseContractMould['submit_loc'])
self.check_submit()
Base.succeed += 1
consoleLog('新增委托合同成功')
@log
def auditHouseContract(self):
"""审核委托合同"""
#审核的相关按钮的disable属性不知道为什么是false,导致无法通过Base类中的对元素属性的校验,所以关于审核按钮的操作都改为js来控制
self.open(Page.entrustContractPage,self.contractSearchMould['tr_contract'],havaFrame=False)
self.input_text(self.contractSearchMould['contract_num_loc'],'AutoTest')
self.click(self.contractSearchMould['search_button_loc'])
self.staleness_of(self.contractSearchMould['tr_contract'])
self.dblclick(self.contractSearchMould['tr_contract'],checkLoc=self.addHouseContractMould['contract_num_loc'])
#驳回
self.click(self.addHouseContractMould['tab_info_loc'], index=3)
self.script('$("button[status=\'REJECTED\']")[1].click()')
self.input_text(self.addHouseContractMould['contract_audit_content'],u'自动化测试审核数据')
self.click(self.addHouseContractMould['contract_audit_confirm'])
self.staleness_of(self.contractSearchMould['tr_contract'])
self.dblclick(self.contractSearchMould['tr_contract'],checkLoc=self.addHouseContractMould['contract_num_loc'])
#审核租金
self.click(self.addHouseContractMould['tab_info_loc'], index=1)
self.click(self.addHouseContractMould['rent_detail_selectAll'])
self.click(self.addHouseContractMould['rent_audit_loc'])
self.click(self.addHouseContractMould['audit_pass_loc'])
self.click(self.addHouseContractMould['rent_audit_confirm'])
#初审
self.click(self.addHouseContractMould['tab_info_loc'],index=3)
self.script('$("button[status=\'PASS\']")[2].click()')
self.click(self.addHouseContractMould['contract_audit_confirm'])
self.staleness_of(self.contractSearchMould['tr_contract'])
self.dblclick(self.contractSearchMould['tr_contract'],checkLoc=self.addHouseContractMould['contract_num_loc'])
#复审
self.click(self.addHouseContractMould['tab_info_loc'], index=3)
self.script('$("button[status=\'APPROVED\']")[1].click()')
self.click(self.addHouseContractMould['contract_audit_confirm'])
self.check_submit()
consoleLog('委托合同审核成功')
@log
def delContract(self):
"""删除委托合同"""
self.open(Page.entrustContractPage, self.contractSearchMould['tr_contract'], havaFrame=False)
self.input_text(self.contractSearchMould['contract_num_loc'], 'AutoTest')
self.click(self.contractSearchMould['search_button_loc'])
self.staleness_of(self.contractSearchMould['tr_contract'])
self.click(self.addHouseContractMould['delete_button'])
self.click(self.addHouseContractMould['delete_button_confirm'])
self.check_submit()
consoleLog('委托合同删除成功')


#HouseContractEndPage.py

###新增委托合同终止结算

# -*- coding:utf8 -*-

from base.Base import Base
from base import Page
from selenium.webdriver.common.by import By
import time
from base.Base import log
from base.Base import consoleLog

class HouseContractEndPage(Base):
searchMould = {
'export_button' : (By.ID,'export_excel_btn'),
'contract_num_loc' : (By.CSS_SELECTOR,'#contract_num_search + span > input:nth-child(1)'),   #委托合同号
'contract_search_button_loc' : (By.ID,'search_btn'),    #委托合同列表页的搜索
'end_contract_num_loc' : (By.CSS_SELECTOR,'#contract_num_wt + span > input:nth-child(1)'),  #委托合同终止列表页的合同号
'end_search_button_loc': (By.ID, 'end_search_btn'), #委托合同终止列表页的搜索
'tr_contract_end' : (By.CSS_SELECTOR, '#ContractReceivable_table_wt > div:nth-child(1) > div:nth-child(2) > div.datagrid-view > div.datagrid-view2 > div.datagrid-body > table > tbody > tr:nth-child(1)'),  # 列表页第一行
}
addContractEndMould = {
'detail_button' : (By.CSS_SELECTOR,'[onclick="HouseEnd.detailDialog(0)"]'), #详情 index:0-操作列中、1-右键中
'delete_button' : (By.CSS_SELECTOR,'[onclick="HouseEnd.detailDialog(0)"] + button'),    #删除
'delete_button_confirm' : (By.CSS_SELECTOR,'.dialog-button.messager-button > a:nth-child(1) > span'),   #删除确认
'tab_info' : (By.CLASS_NAME,'tabs-inner'),  #index 0-出租合同终止结算、1-委托合同终止结算
'tr_contract': (By.CSS_SELECTOR, 'tr[datagrid-row-index="0"]'),  # 列表页第一行
'end_button_loc' : (By.CSS_SELECTOR,'[onclick=\'contractIndex.end("0")\']'),    #0为操作列中,1为右键中
'check_loc' : (By.ID,'end_type'),   #用来确认双击是否成功的元素-结算类型
#结算-收款明细
'penalty_loc': (By.CSS_SELECTOR, '#penalty + span > input:nth-child(1)'),  # 违约金陪入
'return_rent_loc': (By.CSS_SELECTOR, '#return_rent + span > input:nth-child(1)'),  # 返还房租
'no_charge_loc': (By.CSS_SELECTOR, '#no_charge + span > input:nth-child(1)'),  # 未扣款项
'fitment_charge_loc': (By.CSS_SELECTOR, '#fitment_charge + span > input:nth-child(1)'),  # 装修扣款
'other_loc': (By.CSS_SELECTOR, '#other + span > input:nth-child(1)'),  # 其他
'penalty_remark_loc': (By.CSS_SELECTOR, '#penalty_remark + span > input:nth-child(1)'),
'return_rent_remark_loc': (By.CSS_SELECTOR, '#return_rent_remark + span > input:nth-child(1)'),
'no_charge_remark_loc': (By.CSS_SELECTOR, '#no_charge_remark + span > input:nth-child(1)'),
'fitment_charge_remark_loc': (By.CSS_SELECTOR, '#fitment_charge_remark + span > input:nth-child(1)'),
'other_remark_loc': (By.CSS_SELECTOR, '#other_remark + span > input:nth-child(1)'),
#结算-代垫费用退款明细
'tool_bar' : (By.CSS_SELECTOR,'.datagrid-toolbar > table > tbody > tr > td > a > span'), #0-新增、1-删除
'return_money_loc' : (By.CSS_SELECTOR,'[field="return_money"] > div > table > tbody > tr > td > span > input:nth-child(1)'),    #退款金额
#打款信息
'pay_name_loc' : (By.CSS_SELECTOR,'#pay_name + span > input:nth-child(1)'), #姓名
'pay_bank_loc' : (By.CSS_SELECTOR,'#pay_bank  + span > input:nth-child(1)'),    #开户银行
'pay_bank_no_loc': (By.CSS_SELECTOR, '#pay_bank_no  + span > input:nth-child(1)'),  # 银行卡号
'company_no_loc': (By.CSS_SELECTOR, '#company_no  + span > input:nth-child(1)'),  # 还款公司
'remark_loc' : (By.ID,'remark'), #备注
'submit_loc' : (By.ID,'form_save_btn'),    #提交
# 审核相关
'chushen_loc': (By.CSS_SELECTOR, 'button[status="PASS"]'),  # 初审
'fushen_loc': (By.CSS_SELECTOR, 'button[status="REVIEW"]'),  # 复审
'bohui_loc': (By.CSS_SELECTOR, 'button[status="RE_JECT"]'),  # 驳回
'contract_audit_content': (By.ID, 'iszCommonWorkflowContext'),  # 合同审核意见
'contract_audit_confirm': (By.ID, 'iszCommonWorkflowPageSure')  # 合同审核确认
}
typeMould = {
'end_date' : '#end_date',
'end_type' : '#end_type',   #终止类型
'return_type_loc' : '[field="return_type"] > div > table > tbody > tr > td > input',    #退款项目
'bear_type_loc' : '[field="bear_type"] > div > table > tbody > tr > td > input',    #承担方
'bear_name' : '[field="bear_name"] > div > table > tbody > tr > td > input',    #承担方姓名
'money_start_date' : '[field="start_date"] > div > table > tbody > tr > td > input',  #费用开始时间
'money_end_date' : '[field="end_date"] > div > table > tbody > tr > td > input',  #费用结束时间
'explain' : '[field="explain"] > div > table > tbody > tr > td > input',  # 情况说明
'dispute': '[field="dispute"] > div > table > tbody > tr > td > input',  # 是否纠纷
'receivable_date' : '#receivable_date',  #应收日期
'pay_type' : '#pay_type'    #打款类型
}
@log
def addContractEnd(self):
"""新增委托合同终止结算"""
self.open(Page.entrustContractPage,self.addContractEndMould['tr_contract'],havaFrame=False)
self.input_text(self.searchMould['contract_num_loc'],'AutoTest')
self.click(self.searchMould['contract_search_button_loc'])
self.staleness_of(self.addContractEndMould['tr_contract'])
self.context_click(self.addContractEndMould['tr_contract'])
self.click(self.addContractEndMould['end_button_loc'],index=1)
self.input_text(self.addContractEndMould['penalty_loc'], 111)
self.type_select(self.typeMould['end_type'],'RETREATING')   #结算类型-正退
self.type_date(self.typeMould['end_date'],'2017-08-08')
#结算扣款
self.input_text(self.addContractEndMould['penalty_remark_loc'], u'违约金陪入')
self.input_text(self.addContractEndMould['return_rent_loc'], 222)
self.input_text(self.addContractEndMould['return_rent_remark_loc'], u'返还房租')
self.input_text(self.addContractEndMould['no_charge_loc'], 333)
self.input_text(self.addContractEndMould['no_charge_remark_loc'], u'未扣款项')
self.input_text(self.addContractEndMould['fitment_charge_loc'], 444)
self.input_text(self.addContractEndMould['fitment_charge_remark_loc'], u'装修扣款')
self.input_text(self.addContractEndMould['other_loc'], 555)
self.input_text(self.addContractEndMould['other_remark_loc'], u'其他信息')
#代垫费用
self.click(self.addContractEndMould['tool_bar'],index=0)
self.type_select(self.typeMould['return_type_loc'],'LIQUIDATED')    #违约金赔出
self.input_text(self.addContractEndMould['return_money_loc'],666)
self.type_select(self.typeMould['bear_type_loc'],'COMPANY')  #承担方-公司
self.type_select(self.typeMould['bear_name'],'ISZTECH')
self.type_date(self.typeMould['money_start_date'],'2017-07-07')
self.type_date(self.typeMould['money_end_date'],'2017-08-08')
self.type_select(self.typeMould['explain'],'VACANCY')   #情况说明-空置期
self.type_select(self.typeMould['dispute'],'N')
self.type_date(self.typeMould['receivable_date'],'2017-08-08')
#打款信息
self.type_select(self.typeMould['pay_type'],'OWNER')    #打款类别-业主收款
self.input_text(self.addContractEndMould['pay_name_loc'],'AutoTest')
self.input_text(self.addContractEndMould['pay_bank_loc'],u'中国银行')
self.input_text(self.addContractEndMould['pay_bank_no_loc'],'12345678910')
self.input_text(self.addContractEndMould['company_no_loc'],u'杭州有限公司')
self.click(self.addContractEndMould['submit_loc'])
self.check_submit()
consoleLog('委托合同终止结算新增成功')
@log
def auditContractEnd(self):
"""审核委托合同终止结算"""
self.open(Page.contractEndPage,self.searchMould['contract_search_button_loc'],havaFrame=False)
self.click(self.addContractEndMould['tab_info'],index=1)
self.input_text(self.searchMould['end_contract_num_loc'],'AutoTest')
self.click(self.searchMould['end_search_button_loc'])
self.staleness_of(self.searchMould['tr_contract_end'])
self.dblclick(self.searchMould['tr_contract_end'],checkLoc=self.addContractEndMould['check_loc'])
#驳回
self.click(self.addContractEndMould['bohui_loc'])
self.input_text(self.addContractEndMould['contract_audit_content'],u'自动化测试审核数据')
self.click(self.addContractEndMould['contract_audit_confirm'])
self.check_submit()
self.dblclick(self.searchMould['tr_contract_end'],checkLoc=self.addContractEndMould['check_loc'])
#初审
self.click(self.addContractEndMould['chushen_loc'])
self.click(self.addContractEndMould['contract_audit_confirm'])
self.check_submit()
self.dblclick(self.searchMould['tr_contract_end'],checkLoc=self.addContractEndMould['check_loc'])
# 复审
self.click(self.addContractEndMould['fushen_loc'])
self.click(self.addContractEndMould['contract_audit_confirm'])
consoleLog('委托合同终止结算审核成功')
@log
def delContractEnd(self):
"""删除委托合同终止结算"""
self.open(Page.contractEndPage, self.searchMould['contract_search_button_loc'], havaFrame=False)
self.click(self.addContractEndMould['tab_info'], index=1)
self.input_text(self.searchMould['end_contract_num_loc'], 'AutoTest')
self.click(self.searchMould['end_search_button_loc'])
self.staleness_of(self.searchMould['tr_contract_end'])
self.click(self.addContractEndMould['delete_button'])
self.click(self.addContractEndMould['delete_button_confirm'])
self.check_submit()
consoleLog('委托合同终止结算删除成功')


#ApartmentContractPage.py

###签约出租合同

# -*- coding:utf8 -*-

from base.Base import Base
from base import Page
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import time
from base.Base import log
from base.Base import consoleLog

class ApartmentContractPage(Base):
customerSignMould = {
#签约从租客端发起,选择租客
'search_customer_name_loc' : (By.ID,'customer_code_name_mobile_search'),    #租客姓名查询
'search_button_loc' : (By.ID,'search_btn'), #查询按钮
'tr_customer' : (By.CSS_SELECTOR,'[datagrid-row-index="0"]'),
'sign_button' : (By.CSS_SELECTOR,'[onclick="CustomerIndex.signAvailability(0)"]'),  #index:0-操作列中、1-右键中
#选择房源
'share': (By.CSS_SELECTOR,'#search_panel_customer_book_availability_source > div > div > div > ul > li:nth-child(2) > a > span'),#合租按钮
'search_apartment_loc' : (By.ID,'residential_name_house_code_search'),  #楼盘名称查询
'search_apartment_button_loc' : (By.ID,'search_btn'),   #查询按钮 【2】
'apartment_loc' : (By.CSS_SELECTOR,'#search_panel_customer_book_availability_source > div > div > div:nth-child(2) > div > div > div > div > div > div > table > tbody > tr:nth-child(1)')   #第一条房源
}
searchContractMould = {
'contract_num_loc' : (By.CSS_SELECTOR,'#apartment_contract_num + span > input:nth-child(1)'),   #承租合同号
'search_button_loc' : (By.ID,'apartment_search_btn'),   #搜索
'tr_contract' : (By.CSS_SELECTOR,'tr[datagrid-row-index="0"]')  #列表页第一行
}
addApartmentContractMould = {
'delete_button_confirm': (By.CSS_SELECTOR, '.dialog-button.messager-button > a:nth-child(1) > span'),  # 删除确认
#合同信息
'tab_info_loc': (By.CSS_SELECTOR, '.tabs-inner'),  # 0-合租、1-整租、2-合同信息、3-应收款项、4-租客详情
'contract_num_loc' : (By.CSS_SELECTOR,'#contract_num + span > input:nth-child(1)'),  #合同编号
'deposit_loc' : (By.CSS_SELECTOR,'#deposit + span > input:nth-child(1)'),    #应收押金
#合同租金
'rent_strategy_menu_loc': (By.CSS_SELECTOR, '#contract_strategy_table > div > a > span > span:nth-child(1)'),    #租金策略:[0]为新增,[1]为删除
'rent_strategy_price_loc': (By.CSS_SELECTOR, '#contract_strategy_table > table > tbody > tr > td:nth-child(6) > input'),    #月租金
'rent_strategy_contain_loc': (By.CSS_SELECTOR, '#contract_strategy_table > table > tbody > tr > td:nth-child(9) > div > button'),   #月租金包含按钮
'contain_fee_loc': (By.CSS_SELECTOR, '#money_add + span > input:nth-child(1)'),     #月租金包含费用金额
'contain_fee_save_loc': (By.CSS_SELECTOR, '#apartmentContract_money_panel_add > div > p > button'),     #月租金包含的保存
'agent_fee_loc': (By.CSS_SELECTOR, '#agency_fee + span > input:nth-child(1)'),  # 中介服务费
'remark_loc': (By.ID, 'remark'),    #备注
'next_loc_1': (By.CSS_SELECTOR, '#base_button > div > p > button#form_btn'),   #第一页的下一步
'next_loc_2': (By.CSS_SELECTOR, '#base_button > div > p > button#form_next_btn'),   #第二页的下一步
#租客详情
'sign_name_loc' : (By.CSS_SELECTOR,'#sign_name + span > input:nth-child(1)'),  #签约人姓名
'sign_id_no_loc' : (By.CSS_SELECTOR,'#sign_id_no + span > input:nth-child(1)'),    #签约人证件号
'sign_phone_loc' : (By.CSS_SELECTOR,'#sign_phone + span > input:nth-child(1)'),   #签约人联系电话
'sign_address_loc': (By.CSS_SELECTOR,'#postal_address + span > input:nth-child(1)'),  #签约人通讯地址
#紧急联系人
'urgent_customer_name_loc': (By.CSS_SELECTOR,'#urgent_customer_name + span > input:nth-child(1)'),    #紧急联系人姓名
'urgent_phone_loc': (By.CSS_SELECTOR,'#urgent_phone + span > input:nth-child(1)'),    #紧急联系人电话
'urgent_id_card_loc': (By.CSS_SELECTOR,'#urgent_id_card + span > input:nth-child(1)'),    #紧急联系人证件号
'urgent_postal_address_loc': (By.CSS_SELECTOR,'#urgent_postal_address + span > input:nth-child(1)'),  #紧急联系人地址
#承租人信息
'trade_loc': (By.CSS_SELECTOR,'#trade + span > input:nth-child(1)'),  #行业
'email_loc': (By.CSS_SELECTOR,'#email + span > input:nth-child(1)'),  #电子邮件
'tent_contact_address_loc': (By.CSS_SELECTOR,'#tent_contact_address + span > input:nth-child(1)'),    #联系地址
#入住人信息
'del_person_loc' : (By.CSS_SELECTOR,'#check_person_info > div > div > div:nth-child(1) > table > tbody > tr > td:nth-child(3) > a > span'),    #删除入住人按钮
'add_person_loc': (By.CSS_SELECTOR,'#check_person_info > div > div > div:nth-child(1) > table > tbody > tr > td:nth-child(1) > a > span > span:nth-child(1)'),  # 新增入住人按钮
'person_count_loc' : (By.CSS_SELECTOR,'#check_person_info > div > div > div.datagrid-view > div:nth-child(2) > div:nth-child(2) > table > tbody > tr '),   #入住人个数
'person_name_loc' : (By.CSS_SELECTOR,'td[field="customer_name"] > div > table > tbody > tr > td > span > input:nth-child(1)'),        #入住人姓名
'person_cardType_loc': (By.CSS_SELECTOR,'td[field="id_card"] > div > table > tbody > tr > td > span > input:nth-child(1)'),       # 入住人证件号码
'person_phone_loc' : (By.CSS_SELECTOR,'td[field="phone"] > div > table > tbody > tr > td > span > input:nth-child(1)'),    #入住人联系电话
# 审核相关
'chushen_loc': (By.CSS_SELECTOR, 'button[status="PASS"]'),  # 初审
'fushen_loc': (By.CSS_SELECTOR, 'button[status="APPROVED"]'),  # 复审,index=1
'bohui_loc': (By.CSS_SELECTOR, 'button[status="REJECTED"]'),  # 驳回
'contract_audit_content': (By.ID, 'iszCommonWorkflowContext'),  # 合同审核意见
'contract_audit_confirm': (By.ID, 'iszCommonWorkflowPageSure'),  # 合同审核确认
'submit_loc' : (By.CSS_SELECTOR,'#owner_button > div > p > button#form_submit')   #合同提交
}

typeMould = {
#合同信息
'sign_date' : '#sign_date',  #签约日期
'rent_start_date' : '#rent_start_date',     #承租起算日
'rent_end_date' : '#rent_end_date',     #承租到期日
'payment_date' : '#payment_date',   #首次付款日
'payment_type': '#payment_type',    #付款方式
'payment_cycle' : '#payment_cycle',     #付款周期
#合同租金
'rent_strategy_start_loc': '#contract_strategy_table > table > tbody > tr > td:nth-child(7) > input',   #租金策略开始日
'rent_strategy_end_loc': '#contract_strategy_table > table > tbody > tr > td:nth-child(8) > input',     #租金策略结束日
'contain_fee_type': '#fee_type',    #月租金包含费用类型
#其他费用
'agency_fee': '#agency_fee',        #中介服务费
#签约人
'sign_id_type': '#sign_id_type',        #签约人证件类型
'sign_is_customer': '#sign_is_customer',    #是否承租人
#紧急联系人
'urgent_card_type': '#urgent_card_type',    #紧急联系人证件类型
#承租人信息
'customer_type': '#customer_type',  #租客类型
'gender': '#gender',    #租客性别
'education': '#education',  #学历
'yesNo': '#yesNo',  #是否入住
#入住人信息
'cardType': 'td[field="cardType"] > div > table > tbody > tr > td > input',   #入住人证件类型
'sex': 'td[field="sex"] > div > table > tbody > tr > td > input',   #入住人性别
'staydate': 'td[field="staydate"] > div > table > tbody > tr > td > input'    #入住日期
}
@log
def addApartmentContract(self):
"""新增出租合同"""
self.open(Page.customerListPage,self.customerSignMould['tr_customer'],havaFrame=False)
try:
self.input_text(self.customerSignMould['search_customer_name_loc'], 'AutoTest')
except:
consoleLog(Exception.message,level='ERROR')
consoleLog('发现分配租客界面,需先执行关闭操作')
self.click((By.CSS_SELECTOR, '.panel.window > div:nth-child(1) > div.panel-tool > a'))  #可能会有分配租客的弹窗出现,此为关闭
self.click(self.customerSignMould['search_button_loc'])
self.staleness_of(self.customerSignMould['tr_customer'])
self.script("$('button#edit_btn')[2].click()")  # 点击列表页第一行的签约
#此处为查询房源
self.click(self.customerSignMould['share'])
self.input_text(self.customerSignMould['search_apartment_loc'],'AutoTest')
self.input_text(self.customerSignMould['search_apartment_loc'],Keys.ENTER)
self.staleness_of(self.customerSignMould['apartment_loc'])
self.dblclick(self.customerSignMould['apartment_loc'],checkLoc=self.addApartmentContractMould['contract_num_loc'])  #对查询结果的第一条房源数据双击发起签约
self.input_text(self.addApartmentContractMould['contract_num_loc'],'AutoTest')  #合同号
self.type_date(self.typeMould['sign_date'],'2017-02-02')    #签约日期
self.type_date(self.typeMould['rent_start_date'], '2017-02-02') #承租起算日
self.type_date(self.typeMould['rent_end_date'], '2018-08-08')   #承租到期日
self.input_text(self.addApartmentContractMould['deposit_loc'],1234,first=False)
self.type_select(self.typeMould['payment_type'],'NORMAL')   #正常付款
self.type_select(self.typeMould['payment_cycle'], 'TOW_MONTH')  #二月付
#self.input_text(self.addApartmentContractMould['rent_strategy_price_loc'],4321)     #月租金:需求变更,单条情况下无需手动录入
#self.type_date(self.typeMould['rent_strategy_end_loc'],'2018-08-08')    #租金策略结束日:不知道为什么自动化打开的DOM和正常情况下的DOM不一样,所以直接用jquery赋值
self.script("$('#contract_strategy_table > table > tbody > tr > td:nth-child(8) > input').val('2018-08-08')")
self.click(self.addApartmentContractMould['rent_strategy_contain_loc'])     #月租金包含按钮
self.type_select(self.typeMould['contain_fee_type'],'PARKING')  #包含车位费
self.input_text(self.addApartmentContractMould['contain_fee_loc'],123)  #车位费
self.click(self.addApartmentContractMould['contain_fee_save_loc'])  #保存包含
self.input_text(self.addApartmentContractMould['agent_fee_loc'],234,first=False)    #中介服务费
self.input_text(self.addApartmentContractMould['remark_loc'],'this is autotest date')   #备注
self.click(self.addApartmentContractMould['next_loc_1'])    #
self.click(self.addApartmentContractMould['next_loc_2'])
#租客详情
self.input_text(self.addApartmentContractMould['sign_name_loc'],'AutoTest')
self.type_select(self.typeMould['sign_id_type'],'IDNO')
self.input_text(self.addApartmentContractMould['sign_id_no_loc'],'42062119910828541X')
self.input_text(self.addApartmentContractMould['sign_phone_loc'], '15168368432')
self.input_text(self.addApartmentContractMould['sign_address_loc'], u'浙江省杭州市')
self.type_select(self.typeMould['sign_is_customer'], 'Y')
self.input_text(self.addApartmentContractMould['urgent_customer_name_loc'], 'AutoTest')
self.input_text(self.addApartmentContractMould['urgent_phone_loc'], '13666666666')
self.type_select(self.typeMould['urgent_card_type'], 'IDNO')
self.input_text(self.addApartmentContractMould['urgent_id_card_loc'], '42062119910828541X')
self.input_text(self.addApartmentContractMould['urgent_postal_address_loc'], u'浙江省杭州市')
self.type_select(self.typeMould['customer_type'],'EMPLOYEE')
self.type_select(self.typeMould['gender'],'MALE')
self.type_select(self.typeMould['education'], 'BACHELOR')
self.input_text(self.addApartmentContractMould['trade_loc'],u'计算机软件')
self.input_text(self.addApartmentContractMould['email_loc'], 'test@ishangzu.com')
self.type_select(self.typeMould['yesNo'], 'Y')
self.click(self.addApartmentContractMould['add_person_loc'])
self.input_text(self.addApartmentContractMould['person_name_loc'],'test')
self.type_select(self.typeMould['cardType'],'PASSPORT')
self.input_text(self.addApartmentContractMould['person_cardType_loc'],'abcdefghijk')
self.type_select(self.typeMould['sex'], 'MALE')
self.input_text(self.addApartmentContractMould['person_phone_loc'], '13777777777')
self.type_date(self.typeMould['staydate'],'2017-08-08')
self.click(self.addApartmentContractMould['submit_loc'])
Base.succeed += 1
self.check_submit()
consoleLog('出租合同新增成功')
@log
def auditApartmentContract(self):
"""审核出租合同"""
self.open(Page.apartmentContractPage,self.searchContractMould['tr_contract'],havaFrame=False)
self.input_text(self.searchContractMould['contract_num_loc'],'AutoTest')
self.click(self.searchContractMould['search_button_loc'])
self.staleness_of(self.searchContractMould['tr_contract'])
self.dblclick(self.searchContractMould['tr_contract'])
for i in range(0,5):
try:
self.click(self.addApartmentContractMould['tab_info_loc'],index=4)
break
            except:
time.sleep(1)
#驳回
self.click(self.addApartmentContractMould['bohui_loc'])
self.input_text(self.addApartmentContractMould['contract_audit_content'],u'自动化测试审核数据')
self.click(self.addApartmentContractMould['contract_audit_confirm'])
self.staleness_of(self.searchContractMould['tr_contract'])
self.dblclick(self.searchContractMould['tr_contract'])
for i in range(0,5):
try:
self.click(self.addApartmentContractMould['tab_info_loc'],index=4)
except:
time.sleep(1)
else:
pass
#初审
self.click(self.addApartmentContractMould['chushen_loc'])
self.click(self.addApartmentContractMould['contract_audit_confirm'])
self.staleness_of(self.searchContractMould['tr_contract'])
self.dblclick(self.searchContractMould['tr_contract'])
for i in range(0,5):
try:
self.click(self.addApartmentContractMould['tab_info_loc'],index=4)
except:
time.sleep(1)
else:
pass
#复审
self.click(self.addApartmentContractMould['fushen_loc'])
self.click(self.addApartmentContractMould['contract_audit_confirm'])
self.check_submit()
consoleLog('审核出租合同成功')
@log
def delContract(self):
"""删除出租合同"""
self.open(Page.apartmentContractPage, self.searchContractMould['tr_contract'], havaFrame=False)
self.input_text(self.searchContractMould['contract_num_loc'], 'AutoTest')
self.click(self.searchContractMould['search_button_loc'])
self.staleness_of(self.searchContractMould['tr_contract'])
self.script("$('#data_perm_btn').click()")
self.click(self.addApartmentContractMould['delete_button_confirm'])
self.check_submit()
consoleLog('出租合同删除成功')


#ApartmentContractEndPage.py

###新增委托合同终止结算

# -*- coding:utf8 -*-

from base.Base import Base
from base import Page
from selenium.webdriver.common.by import By
from base.Base import log
from base.Base import consoleLog

class ApartmentContractEndPage(Base):
searchMould = {
'contract_num_loc' : (By.CSS_SELECTOR,'#contract_num_search + span > input:nth-child(1)'),   #承租合同号
'search_button_loc' : (By.ID,'search_btn'),
'tr_contract_end' : (By.CSS_SELECTOR, 'tr[datagrid-row-index="0"]'),  # 列表页第一行
}
addContractEndMould = {
'tr_contract': (By.CSS_SELECTOR, 'tr[datagrid-row-index="0"]'),  # 列表页第一行
'end_button_loc' : (By.CSS_SELECTOR,'[onclick=\'apartmentContractList.end("0")\']'),    #0为操作列中,1为右键中
'delete_button': (By.CSS_SELECTOR, '[onclick="ApartmentEnd.detailDialog(0)"] + button'),  # 删除
'delete_button_confirm': (By.CSS_SELECTOR, '.dialog-button.messager-button > a:nth-child(1) > span'),  # 删除确认
'before_end_loc' : (By.CSS_SELECTOR,'[onclick="apartmentContractList.isEndTpye(\'PREEND\')"]'),    #预约终止
'now_end_loc': (By.CSS_SELECTOR, '[onclick="apartmentContractList.isEndTpye(\'NORMAL\')"]'),  # 立刻终止
'end_reason_loc' : (By.CSS_SELECTOR,'#end_reason + span > input:nth-child(1)'), #终止原因
'receipt_num_loc' : (By.CSS_SELECTOR,'#receipt_bank_no + span > input:nth-child(1)'),   #收款卡号
'bank_loc' : (By.CSS_SELECTOR,'#receipt_bank_location + span > input:nth-child(1)'),    #开户银行
'weiyuejin_loc' : (By.CSS_SELECTOR,'[field="project_type"] + td'),   #违约金 index=12
'receivable_money_loc' : (By.CSS_SELECTOR,'[datagrid-row-index="11"] > [field="receivable_money"] > div > table > tbody > tr > td > span > input:nth-child(1)'),    #违约金应收
'payable_money_loc': (By.CSS_SELECTOR,'[datagrid-row-index="11"] > [field="payable_money"] > div > table > tbody > tr > td > span > input:nth-child(1)'),    #违约金应付
'remark_loc' : (By.ID,'remark'), #备注
'submit_loc' : (By.ID,'form_submit_btn'),    #提交
# 审核相关
'chushen_loc': (By.CSS_SELECTOR, 'button[status="PASS"]'),  # 初审
'fushen_loc': (By.CSS_SELECTOR, 'button[status="REVIEW"]'),  # 复审
'bohui_loc': (By.CSS_SELECTOR, 'button[status="RE_JECT"]'),  # 驳回
'contract_audit_content': (By.ID, 'iszCommonWorkflowContext'),  # 合同审核意见
'contract_audit_confirm': (By.ID, 'iszCommonWorkflowPageSure'),  # 合同审核确认
'submit_loc': (By.CSS_SELECTOR, '#owner_button > div > p > button#form_submit')  # 合同提交
}
typeMould = {
'end_date' : '#end_date',
'end_type' : '#end_type',   #终止类型
'receipt_type_loc' : '#contractEndPayerAgintType',   #收款人类型
'receipt_name_loc' : '#receipt_name'    #收款人姓名
}
@log
def addContractEnd(self):
"""新增出租合同终止结算"""
self.context_click(self.addContractEndMould['tr_contract'])
self.click(self.addContractEndMould['end_button_loc'],index=1)
self.click(self.addContractEndMould['now_end_loc'])
self.input_text(self.addContractEndMould['receipt_num_loc'],'AutoTest')
self.type_date(self.typeMould['end_date'],'2017-07-07')
self.input_text(self.addContractEndMould['end_reason_loc'],u'承租周期已完')
self.type_select(self.typeMould['end_type'],'RETREATING')  #正退
self.type_select(self.typeMould['receipt_type_loc'],'PAYER')    #承租人
self.input_text(self.addContractEndMould['bank_loc'],u'中国银行')
self.dblclick(self.addContractEndMould['weiyuejin_loc'],index=12)
self.input_text(self.addContractEndMould['receivable_money_loc'],'888.88')
self.input_text(self.addContractEndMould['payable_money_loc'],'666.66')
self.input_text(self.addContractEndMould['remark_loc'],'AutoTest')
#self.click(self.addContractEndMould['submit_loc'])     #不知道这步为什么会报错,改用js执行
self.script('$("#form_submit_btn").click()')
self.check_submit()
consoleLog('出租合同终止结算新增成功')
@log
def auditContractEnd(self):
"""审核出租合同终止结算"""
self.open(Page.contractEndPage,self.searchMould['tr_contract_end'],havaFrame=False)
self.input_text(self.searchMould['contract_num_loc'],'AutoTest')
self.click(self.searchMould['search_button_loc'])
self.staleness_of(self.searchMould['tr_contract_end'])
self.dblclick(self.searchMould['tr_contract_end'])
#驳回
self.click(self.addContractEndMould['bohui_loc'])
self.input_text(self.addContractEndMould['contract_audit_content'],u'自动化测试审核数据')
self.click(self.addContractEndMould['contract_audit_confirm'])
self.staleness_of(self.searchMould['tr_contract_end'])
self.dblclick(self.searchMould['tr_contract_end'])
#初审
self.click(self.addContractEndMould['chushen_loc'])
self.click(self.addContractEndMould['contract_audit_confirm'])
self.staleness_of(self.searchMould['tr_contract_end'])
self.dblclick(self.searchMould['tr_contract_end'])
# 复审
self.click(self.addContractEndMould['fushen_loc'])
self.click(self.addContractEndMould['contract_audit_confirm'])
consoleLog('出租合同终止结算审核成功')
@log
def delContractEnd(self):
"""删除出租合同终止结算"""
self.open(Page.contractEndPage, self.searchMould['tr_contract_end'], havaFrame=False)
self.input_text(self.searchMould['contract_num_loc'], 'AutoTest')
self.click(self.searchMould['search_button_loc'])
self.staleness_of(self.searchMould['tr_contract_end'])
self.click(self.addContractEndMould['delete_button'])
self.click(self.addContractEndMould['delete_button_confirm'])
self.check_submit()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: