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

#CustomerPage.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
import time

class CustomerPage(Base):
    listMould = {
        'customer_name_search' : (By.ID,'customer_code_name_mobile_search'),
        'search_button' : (By.ID,'search_btn'),
        'add_customer_loc' : (By.ID,'customerAdd'),
        'delete_button' : (By.ID,'del_btn'),
        'alert_confirm': (By.CSS_SELECTOR, '.dialog-button.messager-button > a:nth-child(1) > span'),
        'tr_customer': (By.CSS_SELECTOR, '[datagrid-row-index="0"]'),
        'is_tr_customer' : (By.CSS_SELECTOR,'[οnclick="CustomerIndex.del(5)"]')
    }
    addCustomerMould = {
        #租客信息
        'customer_name_loc' : (By.CSS_SELECTOR,'#customer_name + span > input:nth-child(1)'),  #姓名
        'customer_phone_loc' : (By.CSS_SELECTOR,'#phone + span > input:nth-child(1)'),    #手机号
        'customer_gender_loc' : (By.CSS_SELECTOR,'[name="gender"]'),    #性别 0男 1女 2未知
        'customer_marriage_loc' : (By.CSS_SELECTOR,'[name = "marriage"]'),  #婚姻 0未婚 1已婚 2未知
        'customer_email_loc' : (By.CSS_SELECTOR,'#email + span > input:nth-child(1)'),  #邮箱
        'customer_wechat_loc': (By.CSS_SELECTOR, '#wechat + span > input:nth-child(1)'),  # 邮箱
        'rent_price_min_loc': (By.CSS_SELECTOR, '#rent_from_price + span > input:nth-child(1)'),  #求租最小价
        'rent_price_max_loc': (By.CSS_SELECTOR, '#rent_to_price + span > input:nth-child(1)'),  # 求租最大价
        #求租需求
        'rent_people_loc': (By.CSS_SELECTOR, '#rent_people + span > input:nth-child(1)'),  # 入住人数
        'area_loc': (By.CSS_SELECTOR, '#area + span > input:nth-child(1)'),  # 求租面积
        'rent_other': (By.ID, 'rent_other'),  # 其他需求

        'submit_loc' : (By.ID,'form_btn')   #提交
    }
    typeMould = {
        #租客信息
        'constellation' : '#constellation',     #星座
        'education': '#education',  # 学历
        'customer_from': '#customer_from',  # 来源
        #求租需求
        'rent_class': '#rent_class',  # 求租等级
        'rent_type': '#rent_type',  # 求租类型
        'rent_use': '#rent_use',  # 求租用途
        'rent_fitment': '#rent_fitment',  # 装修情况
        'rent_area_code': '#rent_area_code',  # 求租城区
        'rent_business_circle': '#rent_business_circle_ids',  # 求租商圈
        'rent_date': '#rent_date'  # 希望入住日
    }
    @log
    def addCustomer(self):
        """新增租前客户"""
        #租客信息
        self.open(Page.customerListPage,self.listMould['add_customer_loc'],havaFrame=False)
        self.click(self.listMould['add_customer_loc'])
        self.input_text(self.addCustomerMould['customer_name_loc'],'AutoTest')
        self.input_text(self.addCustomerMould['customer_phone_loc'], '13666666666')
        self.click(self.addCustomerMould['customer_gender_loc'],index=1)
        self.click(self.addCustomerMould['customer_marriage_loc'], index=1)
        self.input_text(self.addCustomerMould['customer_email_loc'], 'mail@mail.com')
        self.input_text(self.addCustomerMould['customer_wechat_loc'], 'AutoTest')
        self.type_select(self.typeMould['constellation'],'VIRGO')
        self.type_select(self.typeMould['education'], 'BACHELOR')
        self.type_select(self.typeMould['customer_from'], 'LOCAL58')
        #求租需求
        self.type_select(self.typeMould['rent_class'], 'CLASSA')    #求租等级-A级
        self.type_select(self.typeMould['rent_type'], 'GATHERHOUSE')    #求租类型-不限
        self.type_select(self.typeMould['rent_use'], 'RESIDENCE')   #求租用途-住宅
        self.type_select(self.typeMould['rent_fitment'], 'FITMENT_ROUGH')   #装修情况-毛坯
        self.type_select(self.typeMould['rent_area_code'], '330108')    #求租城区-滨江
        self.type_select(self.typeMould['rent_business_circle'], '4')     #求租商圈-浦沿
        self.input_text(self.addCustomerMould['rent_price_min_loc'],'1111')
        self.input_text(self.addCustomerMould['rent_price_max_loc'], '2222')
        self.type_date(self.typeMould['rent_date'],'2017-02-02')
        self.input_text(self.addCustomerMould['rent_people_loc'],'3')
        self.input_text(self.addCustomerMould['area_loc'],'88.88')
        self.input_text(self.addCustomerMould['rent_other'],u'浙江省杭州市')
        self.click(self.addCustomerMould['submit_loc'])
        self.check_submit()
        Base.succeed += 1
        consoleLog('新增租客成功')

    def delCustomer(self):
        """删除租前客户"""
        #租客信息
        self.open(Page.customerListPage,self.listMould['tr_customer'],havaFrame=False)
        self.input_text(self.listMould['customer_name_search'],'AutoTest')
        self.click(self.listMould['search_button'])
        self.staleness_of(self.listMould['tr_customer'])
        self.click(self.listMould['delete_button'])
        self.click(self.listMould['alert_confirm'])
        self.check_submit()
        consoleLog('租前客户删除成功')

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Bug来袭~

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值