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

#ResidentiaPage.py

###楼盘模块

# -*- coding:utf8 -*-

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


class ResidentialPage(Base):
   addResidentialMould = {
      'search_btn': (By.ID, 'search_btn'),  # 列表页加载的等待元素--搜索
      # 楼盘地址
      'add_btn' : (By.ID, 'add_btn'),  # 新增楼盘
      'residential_name': (By.CSS_SELECTOR,'#residential_name + span > input'),  #楼盘名称
      'residential_jianpin': (By.CSS_SELECTOR,'#residential_jianpin + span > input '), #楼盘简拼
      'byname_btn': (By.ID, 'other_contact_btn'), #楼盘别名添加按钮
      'byname': (By.CSS_SELECTOR, '#byname + span > input'), #楼盘别名
      'save_button_btn': (By.ID, 'contact_form_btn'), # 保存
      'address': (By.CSS_SELECTOR, '#address + span > input:nth-child(1)'),#街道地址
      'get_location_btn': (By.ID, 'get_btn'), #获取经纬度
      'search_address': (By.ID, 'tipinput'), #输入关键字
      'map_point' : (By.CLASS_NAME,'amap_lib_placeSearch_poi'),
      'search_map_btn': (By.ID, 'searchMap'), # 点击查询
      'save_location_btn': (By.ID, 'add_geo_btn'),#保存经纬度
      # 基础信息
      'department'  : 'body > div:nth-child(23) > div > ul > li > ul > li:nth-child(2) > ul > li:nth-child(1) > ul > li:nth-child(1) > ul > li:nth-child(1) > div > span:nth-child(7)',#责任部门
      'build_date': (By.CSS_SELECTOR, '#build_date + span > input'),  # 建筑年代
      'totle_buildings' : (By.CSS_SELECTOR,'#totle_buildings + span > input'),#总栋数
      'total_unit_count': (By.CSS_SELECTOR, '#total_unit_count + span > input'),  #总单元数
      'total_house_count': (By.CSS_SELECTOR, '#total_house_count + span > input'),  #总户数
      'build_area': (By.CSS_SELECTOR, '#build_area + span > input'),  #占地面积
      'property_company': (By.ID, 'property_company'),  #物业公司
      'property_fee': (By.ID, 'property_fee'),  #物业费
      'plot_ratio': (By.CSS_SELECTOR, '#plot_ratio + span > input'),  # 容积率
      'green_rate': (By.CSS_SELECTOR, '#green_rate + span > input'),  # 绿化率
      'parking_amount': (By.CSS_SELECTOR, '#parking_amount + span > input'),  # 车位数
      'other_info': (By.ID, 'other_info'),  # 楼盘亮点
      # 周边配套,图片,保存
      'bus_stations': (By.ID, 'bus_stations'),#公交站
      'metro_stations': (By.ID, 'metro_stations'), #地铁站
      'roomsFileUpload_btn': (By.CSS_SELECTOR,'#base_img > table > tbody > tr > td > a'),#图片上传
      'submit_btn': (By.ID, 'form_btn'),#保存
      #栋座信息
      'building_info_btn' : (By.CSS_SELECTOR,'#residential + div > div:nth-child(2) > div > div:nth-child(2) > div:nth-child(2) > table > tbody > tr:nth-child(1) > td:nth-child(17) > div > button:nth-child(2)'), #栋座信息按钮
      'add_building_btn': (By.CSS_SELECTOR, '#ResidentialBuilding_table > div > a'),  # 新增楼座
      'building_name': (By.CSS_SELECTOR, '#residential_building_info > table > tbody > tr:nth-child(2) > td:nth-child(2) > input'),# 栋座名称
      'lng_lat_btn': (By.ID, 'get_btn'),  # 经纬度
      'input_searchMap': (By.CSS_SELECTOR, '#myPageTop > table > tbody > tr:nth-child(2) > td:nth-child(1) > input'),# 关键字输入框
      'searchMap_btn': (By.ID, 'searchMap'),  # 查询
      'save_lng_lat_btn': (By.ID, 'add_geo_btn'),  # 保存
      'ground_floors': '#ground_floors',  # 地面层数
      'underground_floors': '#underground_floors',  # 地下层数
      'ladder_count': '#ladder_count',  # 梯数
      'house_count': '#house_count',  # 户数
      #单元信息
      'unit_info_btn': (By.CSS_SELECTOR, '#buliding + div > div:nth-child(2) > div:nth-child(1) > div:nth-child(2) > div:nth-child(2) > table > tbody > tr:nth-child(1) > td:nth-child(11) > div > button:nth-child(1)'),  # 单元信息
      'add_unit_btn ': (By.CSS_SELECTOR, '#ResidentialBuildingUnit_table > div > a'),  # 新增
      'unit_name': (By.ID, 'unit_name'),  # 单元名称
      'save_unitname_btn': (By.ID, 'form_btn'),  # 保存
      #楼层信息
      'floor_info_btn': (By.CSS_SELECTOR, '#buliding_unit + div > div:nth-child(2) > div > div:nth-child(2) > div:nth-child(2) > table > tbody > tr > td:nth-child(4) > div > button:nth-child(1)'),# 楼层信息
      'add_floor_btn': (By.CSS_SELECTOR, '#ResidentialBuildingFloor_table > div > a'),  # 新增
      'floor_name': (By.ID, 'floor_name'),  # 楼层名称
      #房号信息
      'house_info_btn': (By.CSS_SELECTOR, '#buliding_floor + div > div > div > div> div > table > tbody > tr > td:nth-child(4) > div > button:nth-child(1)'),# 房号信息
      'add_house_btn': (By.CSS_SELECTOR, '#ResidentialBuildingHouseNo_table > div >a '),  # 新增
      'house_no': (By.ID, 'house_no')  # 房号名称
   }

   typeMould = {
      'area_code': '#area_code ',  # 城区-
      'business_circle_name': '#taBusinessCircleString '  ,# 商圈
      'property_type': '#property_type ',  # 物业类型
      'property_use': '#housing_type',  # 物业用途
      'department_loc' : '#taDepartString'   #责任部门
      }
   @log
   def addResidential(self):
      """新增楼盘字典、 新增栋座,单元,楼层,房号"""
      self.open(Page.residentiaPage,self.addResidentialMould['search_btn'],havaFrame = False)
      # 楼盘地址
      self.click(self.addResidentialMould['add_btn'])
      self.input_text(self.addResidentialMould['residential_name'], 'AutoTest')
      self.click(self.addResidentialMould['residential_jianpin'])
      self.click(self.addResidentialMould['byname_btn'])
      self.input_text(self.addResidentialMould['byname'], 'auto')
      self.click(self.addResidentialMould['save_button_btn'])
      self.type_select(self.typeMould['area_code'],"330102") #上城区
      self.type_select(self.typeMould['business_circle_name'],"35") #四季青
      self.input_text(self.addResidentialMould['address'], u'自动化测试街道地址')
      self.click(self.addResidentialMould['get_location_btn'])
      self.input_text(self.addResidentialMould['search_address'], u'海创基地', first=False)
      self.click(self.addResidentialMould['search_map_btn'])
      self.click(self.addResidentialMould['search_address'])
      self.click(self.addResidentialMould['map_point'])
      self.click(self.addResidentialMould['save_location_btn'])
      #基础信息
      self.type_select(self.typeMould['property_type'],'ordinary' )
      sql = "SELECT sd.parent_id from sys_department sd INNER JOIN sys_user sur on sur.dep_id = sd.dep_id INNER JOIN sys_position spt on spt.position_id = sur.position_id where sd.dep_district = '330100' and sd.dep_id <> '00000000000000000000000000000000' and (spt.position_name like '资产管家%' or spt.position_name like '综合管家%') LIMIT 1"
      self.type_combotree(self.typeMould['department_loc'],SQL.serach(sql))
      self.input_text(self.addResidentialMould['build_date'], 1988, first=False)
      self.input_text(self.addResidentialMould['totle_buildings'], 10, first=False)
      self.input_text(self.addResidentialMould['total_unit_count'], 30, first=False)
      self.input_text(self.addResidentialMould['total_house_count'], 20, first=False)
      self.input_text(self.addResidentialMould['build_area'], 400, first=False)
      self.input_text(self.addResidentialMould['property_company'], u'杭州物业有限公司', first=False)
      self.input_text(self.addResidentialMould['property_fee'], 2, first=False)
      self.input_text(self.addResidentialMould['plot_ratio'], 80, first=False)
      self.input_text(self.addResidentialMould['green_rate'],20,first=False)
      self.input_text(self.addResidentialMould['parking_amount'], 200, first=False)
      self.input_text(self.addResidentialMould['other_info'], u'临近公交地铁,附近有超市,环境优美', first=False)
      # 周边配套,图片
      self.input_text(self.addResidentialMould['bus_stations'], u'六合桥', first=False)
      self.input_text(self.addResidentialMould['metro_stations'], u'滨江站', first=False)
      # 提交新增楼盘字典
      self.click(self.addResidentialMould['submit_btn'])
      Base.succeed += 1
      consoleLog('楼盘新增成功')
      # 栋座
      self.open(Page.residentiaPage, self.addResidentialMould['search_btn'],havaFrame = False)
      self.click(self.addResidentialMould['building_info_btn'])
      self.click(self.addResidentialMould['add_building_btn'])
      self.input_text(self.addResidentialMould['building_name'], u'AutoTest')
      self.click(self.addResidentialMould['lng_lat_btn'])
      self.input_text(self.addResidentialMould['input_searchMap'], u'逸天广场', first=False)
      self.click(self.addResidentialMould['input_searchMap'])
      self.click(self.addResidentialMould['searchMap_btn'])
      self.click(self.addResidentialMould['save_lng_lat_btn'])
      self.type_select(self.typeMould['property_use'], 'ordinary')
      self.type_select(self.addResidentialMould['ground_floors'], 10)
      self.type_select(self.addResidentialMould['underground_floors'], 2)
      self.type_select(self.addResidentialMould['ladder_count'], 30)
      self.type_select(self.addResidentialMould['house_count'], 100)
      self.click(self.addResidentialMould['save_unitname_btn'])
      # 单元
      self.click(self.addResidentialMould['unit_info_btn'])
      self.click(self.addResidentialMould['add_unit_btn '])
      self.input_text(self.addResidentialMould['unit_name'], u'AutoTest')
      self.click(self.addResidentialMould['save_unitname_btn'])
      # 楼层
      self.click(self.addResidentialMould['floor_info_btn'])
      self.click(self.addResidentialMould['add_floor_btn'])
      self.input_text(self.addResidentialMould['floor_name'], u'AutoTest')
      self.click(self.addResidentialMould['save_unitname_btn'])
      # 房号
      self.click(self.addResidentialMould['house_info_btn'])
      self.click(self.addResidentialMould['add_house_btn'])
      self.input_text(self.addResidentialMould['house_no'], u'AutoTest')
      self.click(self.addResidentialMould['save_unitname_btn'])
      consoleLog('栋座相关新增成功')

   def delResidential(self):
      self.open(Page.residentiaPage,self.addResidentialMould['search_btn'],havaFrame = False)
      # 楼盘地址
      self.click(self.addResidentialMould['add_btn'])



#HouseAddPage.py

###新增房源

# -*- coding:utf8 -*-


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

class HouseAddPage(Base):
    houseAddMould = {
        'test' : (By.ID,'form_btn'), #测试页面加载
        #基本信息
        'property_name': (By.CSS_SELECTOR, '#td_not_found > span > input'),  # 物业地址 ַ
        'property_name_click': (By.CSS_SELECTOR,'#house_develop_panel_form + div > div > div'),
        'contact_people': (By.CSS_SELECTOR, '#contact + span > input'),  # 联系人
        'contact_tel': (By.CSS_SELECTOR, '#contact_tel + span > input'),  # 联系方式
        #出租信息
        'rental_price': (By.CSS_SELECTOR, '#rental_price + span > input '),# 意向租金
        #详细信息
        'build_area': (By.CSS_SELECTOR, '#build_area + span > input'),  # 面积
        'form_btn': (By.ID, 'form_btn')  # 保存
    }

    typeMould = {
        'residential' : '#residential_name_search', #楼盘
        'building': '#house_develop_panel_form + div + div > div > div',  # 栋座
        'unit': '#house_develop_panel_form + div + div + div > div > div',  # 单元
        'room_number': '#house_develop_panel_form + div + div + div + div > div >div',  # 房号
        'did' : '#did', #拓房部门
        'uid' : '#uid', #拓房人
        'house_status': 'body > div:nth-child(17) > div > div:nth-child(3)',  # 房源状态
        'remark': '#remark',  # 备注
        'source': '#source ', #房屋来源
        'rooms' : '#rooms ', #室
        'livings' : '#livings ',#厅
        'kitchens' : '#kitchens ',#厨
        'bathrooms' : '#bathrooms ',#卫
        'balconys' : '#balconys', #阳
        'orientation': '#orientation',  # 朝向
        'property_type': '#property_type',  # 物业类型
        'property_use': '#property_use',  # 物业用途
        'fitment_type': '#fitment_type',  # 装修情况
        'look_type': '#look_type',  # 看房方式
        'look_date': '#look_date',  # 可看房日期
    }


    @log
    def addhousepage(self):
        """新增房源"""
        self.open(Page.houseAddPage,self.houseAddMould['test'],havaFrame=False)
        #基本信息
        self.input_text(self.houseAddMould['property_name'], 'AutoTest')
        self.click(self.houseAddMould['property_name_click'])
        self.input_text(self.houseAddMould['contact_people'], 'AutoTest')
        self.type_click(self.typeMould['building'])
        self.input_text(self.houseAddMould['contact_tel'], '18279881085', first=False)
        self.type_click(self.typeMould['unit'])
        self.input_text(self.houseAddMould['contact_tel'], '18279881085', first=False)
        self.type_click(self.typeMould['room_number'])
        self.type_combotree(self.typeMould['did'],'00000000000000000000000000000000')
        uid = SQL.serach("select user_id from sys_user WHERE user_name = 'AutoTest' limit 1")
        self.type_select(self.typeMould['uid'],uid)
        #出租信息
        self.type_click(self.typeMould['house_status'])
        self.type_select(self.typeMould['source'],'INTRODUCE')
        self.input_text(self.houseAddMould['rental_price'], 3000, first=False)
        self.type_select(self.typeMould['rooms'],'1')
        self.type_select(self.typeMould['livings'], '1')
        self.type_select(self.typeMould['kitchens'], '1')
        self.type_select(self.typeMould['bathrooms'], '1')
        self.type_select(self.typeMould['balconys'], '1')
        #详细信息
        self.input_text(self.houseAddMould['build_area'], '60.00')  # 面积
        self.type_select(self.typeMould['orientation'], 'NORTH')
        self.type_select(self.typeMould['property_type'], 'MULTI_LIFE')
        self.type_select(self.typeMould['property_use'], 'HOUSE')
        self.type_select(self.typeMould['fitment_type'], 'FITMENT_ROUGH')
        self.type_select(self.typeMould['remark'], u'Atuo备注信息')
        self.type_select(self.typeMould['look_type'], 'DIRECTION')
        self.type_select(self.typeMould['look_date'], u'2017-08-08')
        self.click(self.houseAddMould['form_btn'])  # 保存
        Base.succeed += 1
        consoleLog('房源新增成功')



#HouseAuditPage.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 HouseAuditPage(Base):
    searchMould = {
        'residentia_name_loc' : (By.ID,'residential_name_search'),
        'search_button_loc' : (By.ID,'search_btn')
    }
    houseAuditPageloc = {
        'audit_btn': (By.ID, 'audit_btn'),  # 审核
        'department_did_loc' : '#residential_department_did',   #责任部门
        'cancel_btn': (By.ID, 'cancel_btn'),  # 审核通过
        'form_btn': (By.ID, 'form_btn'),  # 审核不通过
        'iszCommonWorkflowPageSure': (By.ID, 'iszCommonWorkflowPageSure'),  # 确定
    }

    @log
    def audit(self):
        """审核房源"""
        self.open(Page.houseAuditPage,self.houseAuditPageloc['audit_btn'])
        self.input_text(self.searchMould['residentia_name_loc'],'AutoTest')
        self.click(self.searchMould['search_button_loc'])
        self.script('$("#audit_btn").click()')
        self.click(self.houseAuditPageloc['cancel_btn'])  # 审核通过
        for i in range(1,6):
            try:
                self.click(self.houseAuditPageloc['iszCommonWorkflowPageSure'])  # 确定
                break
            except:
                self.click(self.houseAuditPageloc['cancel_btn'])  # 审核通过
        self.check_submit()
        try:
            self.solr('house',self.test)
            consoleLog('solr的house-core增量成功')
        except:
            consoleLog(Exception.message,level='ERROR')
            consoleLog('执行house-core的增量失败,请检查solr是否正常')
            pass
        consoleLog('房源审核成功')



#ApartmentPage.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 ApartmentPage(Base):
    apartmentMould = {
        #搜索出需要的房源
        'tr_house': (By.CSS_SELECTOR, 'tr[datagrid-row-index="0"]'),
        'residential_name': (By.ID,'residential_name_house_code_search'),#搜索栏物业地址
        'search_btn' : (By.ID,'search_btn'),#搜索按钮
        'details_btn' : (By.CSS_SELECTOR,'[οnclick="Apartment.dialog(\'edit\',0)"]'),#详情
        'tr_apartment' : (By.CSS_SELECTOR,'tr[datagrid-row-index="0"]'),
        #详情界面
        'make_price_btn' : (By.ID,'btn_make_price'),#定价按钮
        #定价界面
        'entire_rent_price': (By.CSS_SELECTOR,'#rent_price + span >input:nth-child(1)'),#整租-月租金
        'share_rent_price' : (By.CSS_SELECTOR,'td[field=rent_price] > div > span >input:nth-child(1)'), #合租-月租金
        'save_btn' : (By.CSS_SELECTOR,'#base_button > div > p > button:nth-child(2)'),#保存
        'form_btn' : (By.ID,'form_btn'), #保存
        'expense_btn' : (By.CSS_SELECTOR,'#base_button > div > button:nth-child(6)'),#报销
        'amount' : (By.CSS_SELECTOR,'#projectAllExpense > div > table > tbody > tr:nth-child(3) > td:nth-child(5) > span > input'),#报销金额
        'brepay_company': (By.CSS_SELECTOR,'#repay_company + span > input:nth-child(1)'), # 还款公司
        'memo': (By.ID,'memo'),  # 备注
        'submit_btn': (By.ID,'submit_btn')  # 提交
    }
    typeMould = {
        'item_type' : '#projectAllExpense > div > table > tbody > tr:nth-child(1) > td:nth-child(2) > input ',#报销项目
        'bear_type' : '#projectAllExpense > div > table > tbody > tr:nth-child(3) > td:nth-child(2) > input ',#承担方
        'start_date' : '#projectAllExpense > div > table > tbody > tr:nth-child(3) > td:nth-child(6) > input:nth-child(1)',#费用周期开始
        'end_date' : '#projectAllExpense > div > table > tbody > tr:nth-child(3) > td:nth-child(6) > input:nth-child(3)',#费用周期结算
        'vacant' : '#projectAllExpense > div > table > tbody > tr:nth-child(3) > td:nth-child(8) > input',#空置期
        'first' : '#projectAllExpense > div > table > tbody > tr:nth-child(3) > td:nth-child(9) > input',#首次
        'source_bear_id' : '#projectAllExpense > div > table > tbody > tr:nth-child(3) > td:nth-child(10) > span > input:nth-child(1)',#房源方
        'moneytype' : '#moneytype ',#收借款类别
        'customer_name' : '#bank_name ',#姓名
        'customer_bank_location' : '#bank_location ',#开户银行
        'bank_card' : '#bank_card  '#银行卡号
    }

    @log
    def addhouserent(self):
        """房源定价"""
        self.open(Page.apartmentPage, self.apartmentMould['tr_apartment'])
        self.input_text(self.apartmentMould['residential_name'],'AutoTest', first=False)
        for i in range(0, 11):
            self.click(self.apartmentMould['search_btn'])
            time.sleep(1)
            try:
                test = self.driver.find_element(*self.apartmentMould['tr_house'])
                break
            except NoSuchElementException:
                consoleLog('尝试第%s次查找,但未找到apartment-core的solr增量数据' % i,level='WARNING')
                time.sleep(5)

        # 搜索房源
        self.dblclick(self.apartmentMould['tr_apartment'], checkLoc=self.apartmentMould['make_price_btn'])
        # 详情界面
        self.click(self.apartmentMould['make_price_btn'])
        # 定价界面
        self.click(self.apartmentMould['share_rent_price'])
        self.input_text(self.apartmentMould['share_rent_price'], 2222, first=False)
        self.click(self.apartmentMould['save_btn'])
        self.click(self.apartmentMould['form_btn'])
        consoleLog('新增自营房源月租金成功')

    @log
    def addReimbursement(self):
        """新增报销单"""
        self.open(Page.apartmentPage, self.apartmentMould['tr_apartment'])
        # 搜索房源
        self.input_text(self.apartmentMould['residential_name'], 'AutoTest', first=False)
        self.click(self.apartmentMould['search_btn'])
        self.staleness_of(self.apartmentMould['tr_apartment'])
        self.click(self.apartmentMould['details_btn'])
        self.click(self.apartmentMould['expense_btn'])
        #报销费用
        self.input_text(self.apartmentMould['memo'],u'报销单自动化测试备注')
        self.type_select(self.typeMould['item_type'],'WATER')
        self.type_select(self.typeMould['bear_type'],'COMPANY')
        self.input_text(self.apartmentMould['amount'], '666', first=False)
        self.type_date(self.typeMould['start_date'],u'2017-08-08')
        self.type_date(self.typeMould['end_date'],u'2017-08-28')
        self.type_select(self.typeMould['vacant'],'Y')
        self.type_select(self.typeMould['first'],'Y')
        self.type_select(self.typeMould['source_bear_id'],'AutoTest-13666666665')
        #报销人
        self.type_select(self.typeMould['moneytype'],'CUSTOMER_AGENT_PYMENT')
        self.type_select(self.typeMould['customer_name'],'AutoTest')
        self.type_select(self.typeMould['customer_bank_location'],'ABC')
        self.type_select(self.typeMould['bank_card'],'6228481561239334717')
        self.input_text(self.apartmentMould['brepay_company'],u'杭州科技有限公司')
        self.click(self.apartmentMould['submit_btn'])
        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、付费专栏及课程。

余额充值