selenium自动化测试中的页对象

coding=utf-8

import sys
import random
import time

from config import globaVar
from pages import custCommon6

selenium = custCommon6.Driver()
selenium.clearCache(‘1’)
orgVal = ‘3013’

listFxcp = [
‘11414111215’, ‘11111111111’, ‘11111115111’, ‘22222222222’, ‘33333323333’
]
fxcp1 = listFxcp[0]

00-身份证号 01-护照号码 0b-香港居民通行证 0c-澳门居民通行证 0d-台湾居民通行证 0e-外国人永久居留证

idKey = [‘0b’,’0c’,’0d’,’0e’,’01’,’00’]

idKey = [‘0b’,’0c’,’0d’,’0e’,’01’]
idKeyback = [‘00’,’0b’,’0c’,’0d’,’0e’,’01’,’00’,’0b’,’0c’,’0d’,’0e’,’01’]
backlist = [‘6000’,’6100’,’6200’,
‘6300’,’7100’,’7200’,’7300’,’7400’,’7500’,’7600’,’7700’,’5000’,’5200’,’5300’]
size = len(backlist)

name = selenium.getShanGuo()

orgList = [ ‘3099’]
orgList2 = [ “3077”, “3078”, “3079”, “3110”,”3111”,’3210’ ]

修改um号所在的营业部

selenium.updateOrg(‘3111’, ‘LIUHAN572’, ‘1’)

for i in range(6):

k = idKey[i]

if k == '00' or k == '01' or k == '0e':

    v = selenium.getIDCard()

elif k == '0b':

    v = 'H' + selenium.autoTimeString(8) + '01'
elif k == '0c':
    v = 'M' + selenium.autoTimeString(8) + '01'
else:
    v = selenium.getNumberSart(orgVal)+str(i)

backNew = ['5000','5100']  #5700是可以支持周末开户而不报错 5100农行

globaVar.back = '5700'

globaVar.stockCount = '4'

#5700支持周末开户

# 打开浏览器并登录

userCode = 'GR'+ selenium.getIdInfo(k)+globaVar.eventTime+ name + str(random.randrange(100))

#此标识用于判断是否需要开通股本,1表示开通,其余pass

selenium.my_print_info( u'开户的客户名称为:%s' % (userCode))
selenium.my_print_info('serial- %d '%(i+1))
selenium.my_print_info('idcard is - %s ' % (v))
selenium.login(globaVar.event)


#用于登录后弹出的“打开读卡器失败,请检查读卡器状态!”点击确定
selenium.popboxinfo()

#判断证件类型来赋Key值

selenium.my_print_info(u'开户过程中使用的银行为:%s'% (globaVar.back))


# 识别个人开户并切换ifrome
selenium.clikcOpenccount()

#判断是否为双人见证开户
selenium.inputDoubCert(globaVar.douWitness)

#切换营业部
# selenium.inputOrgNumber('3018')

# 输入客户信息,拼接了证件类型上去

selenium.inputCusName(userCode)

# 输入证件类型及号码的及证件结束日期

selenium.inputID_Type(k,v)

# 根据ID_TYPE判断输入证件基本信息,包括性别,sex
selenium.inputBaseInfo(k,v)


# index随机生成下拉输入输入学历、职位、职业 # selenium.inputPost()
selenium.inputEdu()
selenium.inputOccu()
#行业大业的子类
selenium.inputTrade()

#未成年, 收入入标识  1 表示有收入,0表示未收入;

selenium.inputYoung2('0')


# 发送短信22222222222222

selenium.inputMobile(globaVar.event)

# 使用地址,使用ID_TYPE来判断输入联系地址
selenium.imputContInfor(k)


# 点击下一步
selenium.clickNext()


# 第二个页面关联信息节点
#控制人信息

selenium.inputKZRInfo2()

#填写其他人信息与不良诚信
selenium.inputCX(globaVar.CX)

#其它必填信息
selenium.inputOtherInfo(k)

#监护人信息
selenium.inputJHRInfo2()

# 点击下一步
selenium.clickNext()

selenium.inputTax('2')


# 第四个页面账户节点
selenium.is_not_visible("body > div.panel.window.messager-window.message-loading > div")

#选择点击开通股票类型,此处有逻辑判断


selenium.clickShare2(k,v)

# 选择相应的银行,只传入K不传入val,val用日期拼接
selenium.selectBack2(k)


# 点击下一步
selenium.clickNext()

# 第五个页面风险测评

selenium.inputRiskAss2(fxcp1)

# 第一个节点,影像节点提交

selenium.submit()
time.sleep(1)
selenium.close()

# 退出

selenium.accountReview2(k,v)
###########################
###################page

coding=utf-8

--coding:utf-8--

import os
import random
from time import *
import time
import string
from this import d

import selenium.webdriver.support.expected_conditions as EC
import selenium.webdriver.support.ui as ui
from Tools.scripts.treesync import raw_input
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from config import globaVar,globaDB
from public.common.beans import Beans
import sys
OVER_TIME = 5
currtime = time.strftime(‘%Y%m%d%H%M’, time.localtime(time.time()))

class Driver(Beans):
def new(cls, *args, **kw):
“””
使用单例模式将类设置为运行时只有一个实例,在其他Python类中使用基类时,
可以创建多个对象,保证所有的对象都是基于一个浏览器
“””
if not hasattr(cls, ‘_instance’):
orig = super(Driver, cls)
cls._instance = orig.new(cls, *args, **kw)
return cls._instance

def clikcOpenccount(self):
    """
    识别个人开户并切换ifrome
    """
    time.sleep(1)
    self.ifrmaeSwitch('iframe[src*=cust]')
    time.sleep(1)
    self.browerClick("#custOpenAcctBtn")
    time.sleep(3)
    self.ifrmaeSwitch("#openAccountTab0 > iframe")

def getAge(self, birthday):
    print ("Enter Your Date of Birth explace yyyymmdd")
    y = birthday[:4]
    m = birthday[4:6]
    d = birthday[6:]
    # get the current time in tuple format
    a = gmtime()
    # difference in day
    dd = a[2] - int(d)
    # difference in month
    dm = a[1] - int(m)
    # difference in year
    dy = a[0] - int(y)
    # checks if difference in day is negative
    if dd < 0:
        dd = dd + 30
        dm = dm - 1
        # checks if difference in month is negative when difference in day is also negative
        if dm < 0:
            dm = dm + 12
            dy = dy - 1
    # checks if difference in month is negative when difference in day is positive
    if dm < 0:
        dm = dm + 12
        dy = dy - 1
    print(("Your current age is %s Years %s Months & %s Days") % (dy, dm, dd))
    return dy


def getName(self, k):
    """此方法用于用于自动生成用户名,不需要输入开户名称"""

    rad = random.randrange(0, 101, 2)
    userCode = self.getShanGuo() + self.getIdInfo(k) + str(rad)
    return userCode

def getShanGuo(self):
    '''三国名将录'''
    strVal = ['曹操', '张辽', '徐晃', '乐进', '于禁', '张合', '夏侯渊', '夏侯惇', '许褚', '曹仁', '曹洪', '曹真', '司马懿', '邓艾',
              ' 刘备', '关羽', '张飞', '赵云', '马超', '黄忠', '魏延', '姜维', '王平', '邓芝', ' 孙吴', '周瑜', '陆逊', '鲁肃',
              '吕蒙', '陆抗', '甘宁', '程普', '周泰', '铁木真', '窝阔台', '忽必烈', '耶律楚材', '铁木真', '关汉卿', '施耐庵', '韩愈',
              '柳宗元', '苏轼', '苏洵', '苏辙', '欧阳修', '王安石', '曾巩', '张九龄', '李白', '杜甫', '王维', '孟浩然', '王昌龄',
              '綦毋潜', '常健', '岑参', '元结', '韦应物', '柳宗元', '孟郊', '陈子昂', '李颀', '白居易', '高适', '王勃', '骆宾王',
              '刘禹锡', '杜牧', '许浑', '李商隐', '温庭筠', '王之涣' '贺知章']
    index = random.randrange(len(strVal))
    return 'GR' +  strVal[index]

# 00        01       0b     0c      0d      0e
# 身份证   护照  香港  澳门  台湾  外国
# def getIdInfo(self, key):
#     '''返回证件类型对应的汉字'''
#     d = {
#         '00': '大陆',
#         '01': '护照',
#         '0b': '香港',
#         '0c': '澳门',
#         '0d': '台湾',
#         '0e': '外国'
#     }
#     val = d[key]
#     return val

def getIdInfo(self, key):
    '''返回证件类型对应的汉字'''
    d = {
        '00': 'DL',
        '01': 'HZ',
        '0b': 'XG',
        '0c': 'OM',
        '0d': 'TW',
        '0e': 'WG'
    }
    val = d[key]
    return val


def updateOrg(self, orgVal, umVal, flag):
    """修改UM号所属的营业部"""

    if flag == '1':
        # 修改um所属的营业部
        self.update(globaVar.event, orgVal, umVal)

        # 修改um营业部后进行提交,成功后可在新的营业部进行开户操作
        self.loginadmin(globaVar.event)
        self.updateYYB(umVal)
    elif flag == '0':
        print ('不修改营业部直接开户……')

def virBusDep(self, orgVal):
    """修改虚拟营业部"""


    self.loginadmin(globaVar.event)
    self.updateVirBusDep(orgVal)




def continueOperate(sefl):
    """此方法用于中断操作"""
    raw_input_A = input("raw_input: \n")






def inputCusName(self, name):

    '''此方法用于输入用户名及确认输入'''

    self.inputDouble('#CUST_FNAME', name)
    print (name)

def inputBaseInfoSFZ(self):
    '''此方法输入用户名及确认输入'''

    # 证件地址 身份证时的输入

    self.browerInput("#ID_ADDR", globaVar.addr + currtime)
    # 发证机关
    self.browerInput("#ID_ISS_AGCY", globaVar.fzjg + currtime)

def inputID_Type(self, key, val):

    '''引方法用于根据输入的Key来判断输入证件类型和号码包括开始和结束日期'''

    self.driver.find_element_by_css_selector("#ID_TYPE + span > input").send_keys(key)

    time.sleep(1)
    self.driver.find_element_by_css_selector("#ID_TYPE + span > input").send_keys(Keys.ENTER)

    # 输入号码和双重输入信息
    self.inputDouble('#ID_CODE', val)

    if key == '00' or key == '0e':
        try:

            # cssGALW = '#policeValid > span.ui-tool-icons.icon-blue-police'
            cssGALW = '#policeValid > span.btn-text'
            self.executeJSClick(cssGALW)
            time.sleep(1)
            self.driver.switch_to.default_content()
            self.is_not_visible('body > div.panel.window.messager-window.message-loading > div > div')
        finally:
            cssQD = 'body > div.panel.window.messager-window > div.messager-body.panel-body.panel-body-noborder.window-body > div.messager-button > div > a'
            cssGB = 'body > div.panel.window > div.panel-body.panel-body-noborder.window-body > div.dialog-button > div > a > span.btn-text'
            if self.is_element_exist(cssQD):
                self.executeJSClick(cssQD)
            elif self.is_element_exist(cssGB):
                self.executeJSClick(cssGB)
            else:
                pass
            # 切换iframe
            self.ifrmaeSwitch('iframe[src*=BUSI_SCOPE]')

    # 开始结束日期
    self.driver.find_element_by_css_selector(
        "#basicInfoForm > div:nth-child(2) > span:nth-child(4) > span > input").send_keys(globaVar.startDate)
    self.driver.find_element_by_css_selector(
        "#basicInfoForm > div:nth-child(2) > span:nth-child(6) > span > input").send_keys(globaVar.endDate)

def updateYYB(self, um):
    '''进入管理员菜单,修改营业部并提交'''
    self.driver.find_element_by_css_selector('#search-input').clear()
    self.driver.find_element_by_css_selector('#search-input').send_keys('99010631')
    self.driver.find_element_by_css_selector('#search-input').send_keys(Keys.ENTER)
    time.sleep(2)

    self.driver.switch_to.frame(self.driver.find_element_by_css_selector("iframe[src*=manager]"))

    self.driver.find_element_by_css_selector('#USER_CODE').send_keys(um)
    time.sleep(1)
    self.driver.find_element_by_css_selector('#searchEmpInfo > span.btn-text').click()
    time.sleep(1)
    self.driver.find_element_by_css_selector('#EMP_POST_SET > div.form-buttons > div:nth-child(1) > a').click()
    cssQR = 'body > div.panel.window.messager-window > div.messager-body.panel-body.panel-body-noborder.window-body > div.messager-button > div > a'
    time.sleep(1)
    self.driver.find_element_by_css_selector(cssQR).click()
    time.sleep(1)
    self.driver.close()

def updateVirBusDep(self, orgVal):
    '''进入管理员菜单,修改虚拟营业部'''
    self.driver.find_element_by_css_selector('#search-input').clear()
    self.driver.find_element_by_css_selector('#search-input').send_keys('99000251')
    self.driver.find_element_by_css_selector('#search-input').send_keys(Keys.ENTER)
    time.sleep(2)
    #用于机构前面加个6
    val = '6' + orgVal
    self.driver.switch_to.frame(self.driver.find_element_by_css_selector("iframe[src*=pages]"))

    self.browerClick('#button_commonAdd_YGT_VIRTUAL_TELLER > span.btn-text')

    cssJGDM = 'body > div.panel.window > div.panel-body.panel-body-noborder.window-body > div.panel > div > form > div > div.form-group-inline.group-69405-2-1 > span.combo.combo-validatebox-must > input.combo-text'

    self.browerInput(cssJGDM,orgVal)

    cssYGDM = 'body > div.panel.window > div.panel-body.panel-body-noborder.window-body > div.panel > div > form > div > div:nth-child(3) > input'

    self.browerInput(cssYGDM,val)

    cssBC = 'body > div.panel.window > div.panel-body.panel-body-noborder.window-body > div.dialog-button > div:nth-child(1) > a'

    self.browerClick(cssBC)

    self.driver.close()

def intoXLGYCD(self):
    # 维护虚拟柜员,进入菜单
    self.driver.find_element_by_css_selector('#search-input').clear()
    self.driver.find_element_by_css_selector('#search-input').send_keys('99000251')
    self.driver.find_element_by_css_selector('#search-input').send_keys(Keys.ENTER)
 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值