selenium自动化测试中的页对象

版权声明:若转载请指明出处 https://blog.csdn.net/qq_24790545/article/details/82495298

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)
    time.sleep(2)

    self.driver.switch_to.frame(self.driver.find_element_by_css_selector("iframe[src*=VIEW_ID]"))
    time.sleep(1)

def clickWinPopBox(self):
    '''此方法用于点击弹出的Win的弹出框'''
    cssQR = 'body > div.panel.window.messager-window > div.messager-body.panel-body.panel-body-noborder.window-body > div.messager-button > div > a > span'
    time.sleep(1)
    # 点击弹出框确认按钮
    self.driver.find_element_by_css_selector(cssQR).click()

def updateXLGY(self, org, val):
    '''维护虚拟柜员,进入菜单,修改数据'''
    self.driver.find_element_by_css_selector('#button_commonAdd_YGT_VIRTUAL_TELLER > span.btn-text').click()
    time.sleep(2)
    cssJGDM = 'body > div.panel.window > div.panel-body.panel-body-noborder.window-body > div.panel > div > form > div > div > span.combo > input[placeholder="必填"]'
    cssYGDM = 'body > div.panel.window > div.panel-body.panel-body-noborder.window-body > div.panel > div > form > div > div:nth-child(3) > input'

    self.driver.find_element_by_css_selector(cssJGDM).send_keys(org)
    time.sleep(1)
    self.driver.find_element_by_css_selector(cssJGDM).send_keys(Keys.ENTER)
    time.sleep(1)

    self.driver.find_element_by_css_selector(cssYGDM).send_keys(val)
    time.sleep(1)

    # 点击保存
    self.driver.find_element_by_css_selector(
        'body > div.panel.window > div.panel-body.panel-body-noborder.window-body > div.dialog-button > div:nth-child(1) > a').click()
    time.sleep(1)
    cssQR = 'body > div.panel.window.messager-window > div.messager-body.panel-body.panel-body-noborder.window-body > div.messager-button > div > a > span'
    time.sleep(2)

    # 点击弹出框确认按钮
    self.driver.find_element_by_css_selector(cssQR).click()
    time.sleep(1)
    self.driver.close()

def updateYXKG(self, pa, val):
    '''进入管理员菜单,修改全局变量的参数,需要输入需要修改的参数和具体值,最后会关闭浏览器'''
    self.driver.find_element_by_css_selector('#search-input').clear()
    self.driver.find_element_by_css_selector('#search-input').send_keys('99010620')
    self.driver.find_element_by_css_selector('#search-input').send_keys(Keys.ENTER)
    time.sleep(1)

    # 切换iframe
    self.driver.switch_to.frame(self.driver.find_element_by_css_selector("iframe[src*=genericParam]"))

    # 参数号码
    cssCSDM = 'body > div.panel.datagrid > div.datagrid-wrap.panel-body.panel-body-noborder > div.datagrid-queryForm > form > div > div:nth-child(2) > input'
    self.driver.find_element_by_css_selector(cssCSDM).send_keys(pa)
    time.sleep(1)
    # 查询按钮
    cssCXAN = 'body > div.panel.datagrid > div.datagrid-wrap.panel-body.panel-body-noborder > div.datagrid-queryForm > form > div > div:nth-child(6) > div > a > span.btn-text'
    self.driver.find_element_by_css_selector(cssCXAN).click()
    time.sleep(1)
    # 选中数据
    cssXZ = '#datagrid-row-r1-2-0 > td:nth-child(2) > div'
    time.sleep(1)
    self.driver.find_element_by_css_selector(cssXZ).click()
    # 点击修改
    cssXGAN = '#button_commonModify_YGT_UPM_SYSPARAM'
    time.sleep(1)
    self.driver.find_element_by_css_selector(cssXGAN).click()
    time.sleep(1)
    # 输入参数
    cssCSZ = 'body > div.panel.window > div.panel-body.panel-body-noborder.window-body > div.panel > div > form > div > div:nth-child(4) > input'
    getVal = self.driver.find_element_by_css_selector(cssCSZ).get_attribute('title')
    time.sleep(1)


    try:
        if getVal != val:
            self.driver.find_element_by_css_selector(cssCSZ).clear()
            self.driver.find_element_by_css_selector(cssCSZ).send_keys(val)
            time.sleep(1)
            # 点击保存
            cssBC = 'body > div.panel.window > div.panel-body.panel-body-noborder.window-body > div.dialog-button > div:nth-child(1) > a > span.btn-text'
            self.driver.find_element_by_css_selector(cssBC).click()
            time.sleep(1)

            # 确认
            # buttenNext = self.driver.find_element_by_css_selector("#next")
            # self.driver.execute_script('$(arguments[0]).click()', buttenNext)
            cssQRAN = 'body > div.panel.window.messager-window > div.messager-body.panel-body.panel-body-noborder.window-body > div.messager-button > div > a'
            self.driver.find_element_by_css_selector(cssQRAN).click()
            # 点击缓存
            cssSXHC = 'body > div.panel.datagrid > div.datagrid-wrap.panel-body.panel-body-noborder > div.datagrid-toolbar > div:nth-child(4) > a'
            time.sleep(1)
            self.driver.find_element_by_css_selector(cssSXHC).click()
            time.sleep(1)
            # 缓存确认
            cssHCQR = 'body > div:nth-child(8) > div.messager-body.panel-body.panel-body-noborder.window-body > div.messager-button > div > a > span'
            self.driver.find_element_by_css_selector(cssHCQR).click()
        elif getVal == val:
            self.my_print_info('参数与预期相符无须修改……')
        time.sleep(10)
    except Exception as e:
        print (e)
    finally:
        self.driver.close()

def inputBaseInfo(self, key, val):
    '''此方法用于输入基本信息,且根据Key来判断输入,包括性别和国籍'''

    if key == '00':
        time.sleep(1)
        self.driver.find_element_by_css_selector("#ID_ADDR").send_keys(globaVar.addr + currtime)
        # 发证机关
        self.driver.find_element_by_css_selector("#ID_ISS_AGCY").send_keys(globaVar.fzjg + currtime)

    elif key == '0b' or key == '0c' or key == '0d':
        # 港澳台
        # 性别

        cssXB = "#basicInfoForm > div:nth-child(3) > span:nth-child(2) > span > input"
        self.inputListComma(cssXB, globaVar.sex)

        sexTitle = self.driver.find_element_by_css_selector(cssXB).get_attribute('title')

        # 出生日期
        if sexTitle == "1-女性":
            globaVar.birth = globaVar.birtGirl
        else:
            globaVar.birth = globaVar.birtBoy

        # 出生日期
        self.driver.find_element_by_css_selector(
            "#basicInfoForm > div:nth-child(3) > span:nth-child(4) > span > input").send_keys(globaVar.birth)

        # 辅证件类型及开始时间和结束时间
        # self.driver.find_element_by_css_selector("#OTHER_ID_CODE").send_keys(val+'518')
        self.inputDouble("#OTHER_ID_CODE", self.autoIDFZZJ())
        time.sleep(1)
        self.driver.find_element_by_css_selector(
            "#basicInfoForm > div.other-id-type-wrap > div:nth-child(3) > span:nth-child(2) > span > input").send_keys(
            globaVar.startDate)
        time.sleep(1)
        self.driver.find_element_by_css_selector(
            "#basicInfoForm > div.other-id-type-wrap > div:nth-child(3) > span:nth-child(4) > span > input").send_keys(
            Keys.ENTER)
    elif key == '01' or key == '0e':
        # 外国人和护照
        # 性别
        cssXB = "#basicInfoForm > div:nth-child(3) > span:nth-child(2) > span > input"

        self.inputListComma(cssXB, globaVar.sex)

        sexTitle = self.driver.find_element_by_css_selector(cssXB).get_attribute('title')

        # 出生日期
        if sexTitle == "1-女性":
            globaVar.birth = globaVar.birtGirl
        else:
            globaVar.birth = globaVar.birtBoy

        self.driver.find_element_by_css_selector(
            "#basicInfoForm > div:nth-child(3) > span:nth-child(4) > span > input").send_keys(globaVar.birth)

        cssBJ = '#basicInfoForm > div:nth-child(7) > span:nth-child(6) > span > input'
        self.inputListComma(cssBJ, 'ABW,ARG,MTQ,TTO,VCT,WLF,UMI')


def inputEdu(self):
    '''学历'''
    cssXN = '#EDUCATION + span > input'
    self.inputListComma(cssXN, '0,1,2,3,4,5,6,Z')

def inputOccu(self):

    '''职业类型'''
    cssZYLX = "#OCCU_TYPE + span > input"
    #取消了职业为军人,为了涉税
    self.inputListComma(cssZYLX, '01,02,03,04,05,06,07,09')

    cssHYLB = '#CIF_TRADE + span > input[type=text]'
    self.inputListComma(cssHYLB, '01,02,03,04,05,06,07,09')

def inputPost(self):
    '''职务'''
    cssZW = '#POST_TYPE + span > input'
    self.inputListComma(cssZW, '0,1,2,Z')

def inputTrade(self):
    '''行业大类'''
    cssHYDL = '#INDUS_GB + span > input.combo-text.validatebox-text'
    cssHYZL ='#INDUS_GB_SUB + span > input.combo-text.validatebox-text'
    self.browerClear(cssHYDL)
    self.inputListComma(cssHYDL,'A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T')
    self.browerClear(cssHYZL)
    self.clickEnter(cssHYZL)



def inputYoung2(self,income):
    '''输入未成年人信息未成年人'''
    flag = self.driver.find_element_by_css_selector("#SUBJECT_IDENTITY + span > input").get_attribute("title")
    age = self.driver.find_element_by_css_selector("#basicInfoForm > div:nth-child(3) > span:nth-child(4) > span > input.combo-value").get_attribute("value")
    ageFlag = self.getAge(age)

    if flag == '1-未成年' and ageFlag < 16:
        self.inputListComma("#UNDER_AGE + span > input", '0,1')
        self.my_print_info('小于16周岁')
    if flag == '1-未成年' and ageFlag < 18 and ageFlag >= 16 and income == '1':
        self.inputListComma("#UNDER_AGE + span > input", '2')
        self.my_print_info('有劳动收入')
    elif flag == '1-未成年' and ageFlag < 18 and ageFlag >= 16 and income == '0':
        self.inputListComma("#UNDER_AGE + span > input", '0,1')
        self.my_print_info('16-18没有劳动收入')



def update(self, hj, org, um):
    '''修改uum_operator表中所UM号所属的营业部'''
    import cx_Oracle
    if hj == 'fat':

        db = cx_Oracle.connect(globaDB.dbfat)
    elif hj == 'uat':
        db = cx_Oracle.connect(globaDB.dbuat)
    cursor = db.cursor()

    sql = "update uum_operator set org_code = \'%s\' where op_code = \'%s\'" % (org, um)
    rs = cursor.execute(sql)
    db.commit()
    db.close()
    time.sleep(1)

def createPhone(self):
    '''随机生成手机号码'''

    prelist = ["130", "131", "132", "133", "134", "135", "136", "137", "138", "139", "147", "150", "151", "152",
               "153",
               "155", "156", "157", "158", "159", "186", "187"]
    return random.choice(prelist) + "".join(random.choice("0123456789") for i in range(8))

def autoPhone13(self):
    '''随机生成手机号码, 并以13开头'''

    prelist = ["130", "131", "132", "133", "134", "135", "136", "137", "138", "139"]
    return random.choice(prelist) + "".join(random.choice("0123456789") for i in range(8))

def autoPhone15(self):
    '''随机生成手机号码, 并以15开头'''

    prelist = ["150", "151", "152", "153", "155", "156", "157", "158", "159"]
    return random.choice(prelist) + "".join(random.choice("0123456789") for i in range(8))

def autoPhone18(self):
    '''随机生成手机号码, 并以18开头'''

    prelist = ["186", "187"]
    return random.choice(prelist) + "".join(random.choice("0123456789") for i in range(8))

def inputMobile(self, hj):
    '''通过方法来输入手机号码,指定css local'''

    cssAN = '#MOBILE_TEL+ span'
    if globaVar.douWitness =='0':
        self.my_print_info('需要录入验证码')
        self.inputMobile2(globaVar.event, '#MOBILE_TEL', cssAN, '#VALIDATE_CODE')
    elif globaVar.douWitness =='1':
        time.sleep(1)
        self.my_print_info('双人见证开户,不需要录入验证码')
        telval = self.createPhone()
        self.driver.find_element_by_css_selector('#MOBILE_N span > input[type=text]').clear()
        self.driver.find_element_by_css_selector('#MOBILE_N span > input[type=text]').send_keys(telval)
        time.sleep(2)
    else:
        pass

def reOperation(self, userCode):
    '''我的业务里面输入客户代码进行继办'''
    self.driver.find_element_by_css_selector('#my-biz').click()
    self.ifrmaeSwitch('iframe[src*=genericParam]')
    cssUserCode = 'body > div.panel.datagrid > div.datagrid-wrap.panel-body.panel-body-noborder > div.datagrid-queryForm > form > div > div:nth-child(5) > input'

    self.driver.find_element_by_css_selector(cssUserCode).send_keys(userCode)
    cssXB = '#datagrid-row-r1-2-0 > td:nth-child(3) > div > a.opAccept'
    self.driver.find_element_by_css_selector(cssXB).click()
    time.sleep(3)




def imputContInfor(self, key):
    '''如果是身份证则显示使用地址,否则输入地址和邮编'''
    flag = '0'

    if key == '00':
        listQH = ['0755', '0938', '010']
        listYX = ['[email protected]', '[email protected]', '[email protected]']
        rad = random.randrange(len(listQH))
        # 使用证件地址

        cssQH = '#linkInfoForm > div:nth-child(2) > span > span.teltextarea-wrap.inline-block > input:nth-child(1)'
        cssGDDH = '#linkInfoForm > div:nth-child(2) > span > span.teltextarea-wrap.inline-block > input:nth-child(3)'
        if flag == '1':
            time.sleep(2)
            self.driver.find_element_by_css_selector(cssQH).send_keys(listQH[rad])
            time.sleep(1)
            self.driver.find_element_by_css_selector(cssGDDH).send_keys('9999999')
            time.sleep(1)
            self.driver.find_element_by_css_selector('#EMAIL').send_keys(listYX[rad])
        time.sleep(2)
        buttenAddr = self.driver.find_element_by_css_selector("span.desc-val.idAddress > div > a")
        self.driver.execute_script('$(arguments[0]).click()', buttenAddr)

    else:
        listQH1 = ['+86-0755-9999999', '+86-0938-9999999', '+86-010-9999999']
        listYX = ['[email protected]', '[email protected]', '[email protected]']
        rad = random.randrange(len(listQH1))
        time.sleep(1)
        if flag == '1':
            self.driver.find_element_by_css_selector('#EMAIL').send_keys(listYX[rad])
            time.sleep(1)

            cssDH = '#linkInfoForm > div:nth-child(2) > span.desc-val.tel-width.hide.other-country-wrap >input'
            self.driver.find_element_by_css_selector(cssDH).send_keys(listQH1[rad])

        # self.driver.find_element_by_css_selector(
        #     "#linkInfoForm > div:nth-child(3) > span.desc-val.idAddress > span.other-country-wrap.hide >input").send_keys(
        #     globaVar.addr + currtime)
        self.driver.find_element_by_css_selector(
            "#ADDRESS.kui-textinput.validatebox-text.validatebox-must").send_keys(
            globaVar.addr + currtime)

        # self.driver.find_element_by_css_selector(
        #     "#linkInfoForm > div:nth-child(4) > span.desc-val > input  ").send_keys("123456")
        self.browerInput('#ZIP_CODE','123456')

def clickNext(self):
    '''下一步next,然后等待了1秒'''

    buttenNext = self.driver.find_element_by_css_selector("#next")
    self.driver.execute_script('$(arguments[0]).click()', buttenNext)
    time.sleep(1)

def submit(self):

    '''提交submit,其中等待了3秒'''

    time.sleep(2)
    self.is_visible('##submit')
    self.driver.find_element_by_css_selector("#submit").click()
    time.sleep(3)

    self.driver.switch_to.default_content()
    cssqjcg = 'body > div.panel.window.messager-window > div.messager-body.panel-body.panel-body-noborder.window-body > div.messager-button > div > a.l-btn'
    self.executeJSClick(cssqjcg)

# 控制人信息
def inputKZRInfo(self):
    '''输入控制人信息'''
    # flag = self.driver.find_element_by_css_selector("#GUARDIAN_RELA + span >input").get_attribute("title")

    cssGDGL = '#controllerForm > div:nth-child(1) > span.desc-val > span > input'
    cssZJLX = '#controllerForm > div:nth-child(2) > span:nth-child(5) > span > input'
    cssZJHM = '#controllerForm > div:nth-child(2) > span:nth-child(7) >input'
    cssZYXJ = '#controllerForm > div:nth-child(3) > span:nth-child(2) > span > input'
    cssLXDH = '#controllerForm > div:nth-child(3) > span:nth-child(4) > input'

    if globaVar.birth == '20100101' or globaVar.birth == '19991231':
        '''通过判断来输入控制人信息'''
        self.inputListComma(cssGDGL, '00,01,02')
        self.driver.find_element_by_css_selector("#ASSOCIATE_NAME").send_keys('控制人' + currtime)
        self.inputListComma(cssZJLX, '0d')

        self.driver.find_element_by_css_selector(cssZJHM).send_keys(globaVar.gzrCard)
        self.driver.find_element_by_css_selector(cssZYXJ).send_keys(globaVar.endDate)
        self.driver.find_element_by_css_selector(cssLXDH).send_keys(globaVar.gzrMobile)

def inputKZRInfo2(self):
    '''输入控制人信息'''
    # flag = self.driver.find_element_by_css_selector("#GUARDIAN_RELA + span >input").get_attribute("title")

    cssGDGL = '#controllerForm > div:nth-child(1) > span.desc-val > span > input'
    cssZJLX = '#controllerForm > div:nth-child(2) > span:nth-child(5) > span > input'
    cssZJHM = '#controllerForm > div:nth-child(2) > span:nth-child(7) >input'
    cssZYXJ = '#controllerForm > div:nth-child(3) > span:nth-child(2) > span > input'
    cssLXDH = '#controllerForm > div:nth-child(3) > span:nth-child(4) > input'

    if self.is_title_null("#ASSOCIATE_NAME"):
        '''通过判断来输入控制人信息'''
        self.inputListComma(cssGDGL, '00,01,02')
        self.driver.find_element_by_css_selector("#ASSOCIATE_NAME").send_keys('控制人' + currtime)
        self.inputListComma(cssZJLX, '0d')

        self.driver.find_element_by_css_selector(cssZJHM).send_keys(globaVar.gzrCard)
        self.driver.find_element_by_css_selector(cssZYXJ).send_keys(globaVar.endDate)
        self.driver.find_element_by_css_selector(cssLXDH).send_keys(globaVar.gzrMobile)

def inputCX(self, pa):
    '''通过参数来判断是否输入诚信记录和其他联系统人信息'''
    if pa == '1':

        cssCX = '#honestyForm > div > span:nth-child(4) > span > input'

        self.inputListComma(cssCX, '00,01,02')

        self.driver.find_element_by_css_selector("#CREDIT_REMARK").send_keys("不良诚信记录备注……")

        '''其他联系人信息'''
        # self.driver.find_element_by_css_selector("#LINKMAN").send_keys(u"其他联系人李达康")
        self.driver.find_element_by_css_selector("#LINKMAN").send_keys("三仔xe4xbbx818")
        self.driver.find_element_by_css_selector("#LINKMAN_TEL").send_keys('15112530458')
    else:
        print ('不需要其他联系人信息……')

def inputJHRInfo(self):

    '''输入监护人信息'''

    cssGDBX = '#GUARDIAN_RELA + span > input'
    cssZHLX = '#GUARDIAN_ID_TYPE + span > input'
    cssZYXQ = '#guardianForm > div:nth-child(3) > span:nth-child(2) > span > input'

    if globaVar.birth == '20100101' or globaVar.birth == '19991231':
        self.inputListComma(cssGDBX, '00,01,02')
        self.driver.find_element_by_css_selector("#GUARDIAN_NAME").send_keys("监护人" + currtime)
        self.inputListComma(cssZHLX, '0d')

        self.driver.find_element_by_css_selector("#GUARDIAN_SFZH").send_keys(globaVar.jhrCard)
        self.driver.find_element_by_css_selector(cssZYXQ).send_keys(globaVar.endDate)
        self.driver.find_element_by_css_selector("#GUARDIAN_PHONE").send_keys(globaVar.jhrMobile)

def inputJHRInfo2(self):

    '''输入监护人信息'''

    cssGDBX = '#GUARDIAN_RELA + span > input'
    cssZHLX = '#GUARDIAN_ID_TYPE + span > input'
    cssZYXQ = '#guardianForm > div:nth-child(3) > span:nth-child(2) > span > input'

    if self.is_element_exist('#GUARDIAN_RELA'):
        self.inputListComma(cssGDBX, '00,01,02')
        self.driver.find_element_by_css_selector("#GUARDIAN_NAME").send_keys("监护人" + currtime)
        self.inputListComma(cssZHLX, '0d')

        self.driver.find_element_by_css_selector("#GUARDIAN_SFZH").send_keys(globaVar.jhrCard)
        self.driver.find_element_by_css_selector(cssZYXQ).send_keys(globaVar.endDate)
        self.driver.find_element_by_css_selector("#GUARDIAN_PHONE").send_keys(globaVar.jhrMobile)

def inputOtherInfo(self,key):

    '''工作单位,出行工具、年收入、婚姻、兴趣爱好、我司以外'''
    self.driver.find_element_by_css_selector("#otherMForm > div > span > input").send_keys(globaVar.gzdw+self.getRandString(5))
    time.sleep(1)

    # 出行工具
    cssCXGJ = '#otherMForm > div:nth-child(1) > span:nth-child(4) > span > input'
    self.inputListComma(cssCXGJ, '0,1,2,3,4')

    # 住宅
    cssZZ = '#otherMForm > div:nth-child(1) > span:nth-child(6) > span > input'
    self.inputListComma(cssZZ, '0,1,2,3,4,5')

    # 年收入
    #cssNSR = '#otherMForm > div:nth-child(2) > span:nth-child(2) > span > input.combo-text.validatebox-text.form-input-disabled'
    cssNSR = '#otherMForm > div:nth-child(2) > span:nth-child(2) > span > span + input'

    print((self.my_print_info(self.getAttribute(cssNSR,'class'))))

    time.sleep(2)
    #暂时把这个值取下反
    if  self.getAttribute(cssNSR,'clas') == 'combo-text validatebox-text form-input-disabled':
        print ('不需要输入收入……')
        pass

    if self.getAttribute(cssNSR,'class') == 'combo-text validatebox-text' :

        print ('需要输入收入……')
        # self.clickEnter(cssNSR)
        listYSR =['0-10万', '10-30万', '30-50万', '50-100万', '100-300万', '300万以上']
        rad = random.randrange(len(listYSR))
        self.my_print_info('帐入 %s' %listYSR[rad])
        self.inputListComma(cssNSR,listYSR[rad])
        print((self.driver.find_element_by_css_selector(cssNSR).get_attribute('title')))


    # 婚姻

    self.inputListComma('#otherMForm > div:nth-child(2) > span:nth-child(4) > span > input', '0,1,2,3,4,')

    # 兴趣爱好
    cssXQAH = '#otherMForm > div:nth-child(2) > span:nth-child(6) > span > input'
    self.inputListComma(cssXQAH, '01,02,03,04,05,06,07,08,09,10,11')

    # 我司以外

    cssWSYW = '#otherMForm > div:nth-child(3) > span.desc-val > span > input'
    self.inputListComma(cssWSYW, '1,2,3,4,5,6,7')

def inputTax(self,kk):

    cssSSFZ = '#taxBasicForm input[id=TAX_RESIDENT_TYPE]  + span > input'
    cssQMR = '#taxBasicForm input[id=SIGN_NAME]  + span > input'
    self.inputListComma(cssSSFZ,kk)
    self.browerClear(cssQMR)
    self.inputListComma(cssQMR,'1')

    if kk == '1':
        pass
    else:
        #姓  名  出生日期:  现居街道地址  现居省市  现居国家:  出生街道地址  出生省市  出生国家:
        self.browerInput('#taxBasicForm input[name=SURNAME_ENG]','zhang')
        self.browerInput('#taxBasicForm input[name=NAME_ENG]','shan')
        # self.browerInput('#taxBasicForm input[id=BIRTHDAY] + span > input',globaVar.endDate)
        addressList = ['When you dreams come a liveyo','Never quitand never stop','We will glowin the dark turning dust to gold']
        rad1 = random.randrange(len(addressList))
        self.browerInput('#taxBasicForm input[name=ADDRESS_ENG]',addressList[rad1])
        self.browerInput('#taxBasicForm input[name=CITY_ENG]','shenzhen')
        #现居国家
        cssXJGJ = '#taxBasicForm input[id=NATION_ENG] + span > input'
        self.inputListComma(cssXJGJ,'AD,AE,AF,AG,AI,AL,AM,AO')
        addressEngList = ['We will glow in the dark turning dust to gold', 'And we ll dream it possible possible possible possible', 'From the bottom to the top']
        rad2 = random.randrange(len(addressEngList))
        self.my_print_info(self.getListVal(addressEngList))
        self.browerInput('#taxBasicForm input[name=BIRTH_ADDRESS_ENG]',addressEngList[rad2])
        self.browerInput('#taxBasicForm input[name=BIRTH_CITY_ENG]','shenzhen')
        cssCSGJ = '#taxBasicForm input[id=BIRTH_NATION_ENG] + span > input'
        self.inputListComma(cssCSGJ, 'AD,AE,AF,AG,AI,AL,AM,AO')

        #税收居民国(地区)以及纳税人识别号
        cssSSDQ = '#taxNationForm input[id=CITIZENSHIP_ST] + span > input'
        cssNSYY = 'input[id=OPP_NO_TAXPAYERID_REASON] + span > input'
        self.inputListComma(cssSSDQ, 'AD,AE,AF,AG,AI,AL,AM,AO')
        self.inputListComma(cssNSYY,'2')
        self.browerInput('input[id=NO_TAXPAYERID_REASON]','There is no reason')

    self.clickNext()


def clickShare2(self, key, val):
    ''' 选择股票板块,通过key来判断,其中包括集数控制'''
    time.sleep(1)

    cssSzA = "#stockInfoWrap > div.account-body > div > div.tb-body > div:nth-child(1) > div:nth-child(2) > div > div > label:nth-child(1) > span.ovs-item-a"
    cssShA = "#stockInfoWrap > div.account-body > div > div.tb-body > div:nth-child(1) > div:nth-child(5) > div > div > label:nth-child(1) > span.ovs-item-a"
    cssSzB = "#stockInfoWrap > div.account-body > div > div.tb-body > div:nth-child(2) > div:nth-child(2) > div > div > label:nth-child(1) > span.ovs-item-a"
    cssShB = "#stockInfoWrap > div.account-body > div > div.tb-body > div:nth-child(2) > div:nth-child(5) > div > div > label:nth-child(1) > span.ovs-item-a"
    cssSzJ = "#stockInfoWrap > div.account-body > div > div.tb-body > div:nth-child(3) > div:nth-child(2) > div > div > label:nth-child(1) > span.ovs-item-a"
    cssShJ = "#stockInfoWrap > div.account-body > div > div.tb-body > div:nth-child(3) > div:nth-child(5) > div > div > label:nth-child(1) > span.ovs-item-a"

    butSzA = "#checkSzA + div > div  > label > span"
    butShA = "#checkShA + div > div  > label > span"
    butSzB = "#checkSzB + div > div  > label > span"
    butShB = "#checkShB + div > div  > label > span"
    butSzJ = "#checkSzJj + div > div  > label > span"
    butShJ = "#checkShJj + div > div  > label > span"
    butGZ = "#checkGzA + div > div  > label > span"

    if key == '01':
        # 如果是护照,则选择深B,沪
        list1 = [butSzB, cssSzB, cssSzB, butShB]
        for i in range(4):
            self.driver.find_element_by_css_selector(list1[i]).click()
            time.sleep(1)
    elif globaVar.stockCount == '0':

        # 当参数为二时,则选择深a沪a
        pass

    elif globaVar.stockCount == '2':

        # 当参数为二时,则选择深a沪a
        list2 = [butSzA, cssSzA, butShA, cssShA]
        for i in range(4):
            self.driver.find_element_by_css_selector(list2[i]).click()
            time.sleep(1)


    elif globaVar.stockCount == '7':

        # 当参数为4或7时,则选择深a沪a,深b沪b,深基金,沪基金,股转

        list3 = [butSzA, cssSzA, butShA, cssShA, butSzB, cssSzB, butShB, cssShB, butSzJ, cssSzJ, butShJ, cssShJ,
                 butGZ]
        for i in range(13):
            self.driver.find_element_by_css_selector(list3[i]).click()
            time.sleep(1)

    elif globaVar.stockCount == "4":
        # 当参数为4或7时,则选择深a沪a,深b沪b,深基金,沪基金,股转

        list3 = [butSzA, cssSzA, butShA, cssShA, butSzB, cssSzB, butShB, cssShB]

        for i in range(8):
            self.driver.find_element_by_css_selector(list3[i]).click()
        time.sleep(1)

    else:

        print ("请检查输入参数……")

def getNumberSart(self, start):
    '''输入开始字符后拼接时分秒'''
    v = start + time.strftime('%H%M%S%m%d%Y', time.localtime(time.time()))

    return v

# 判断银行是否必填和是否显示
#######################################################################

def inputBack(self, cssDH, backDH):
    '''输入银行卡代号'''
    self.driver.find_element_by_css_selector(cssDH).send_keys(backDH)
    time.sleep(1)
    self.driver.find_element_by_css_selector(cssDH).send_keys(Keys.ENTER)

def inpuBackSCSR(self, cssKH, backVal):
    ''''#输入银行确认框,参数css,值'''
    time.sleep(1)

    self.inputDouble(cssKH, backVal)

    time.sleep(1)


def inputBackJudge2(self, cssDH, valDH, cssYHZH, cssMM, val):
    '''#判断银行是否需要输入账户和密码,适用于美元和港币'''
    # 输入银行代号美元和银行
    self.inputBack(cssDH, valDH)
    time.sleep(1)
    if self.is_title_null(cssDH):
        print ('递归进行银行代号输入……')
        self.inputBack(cssDH, valDH)
    # 判断
    if self.isDisableBack(cssYHZH) == '1':
        print ('该银行卡号distable')
        # 显示后
    elif self.isMustBack(cssYHZH) == '1':
        print ('该银行卡号必填')
        self.inpuBackSCSR(cssYHZH, val)
        # 判断密码
        if self.isMustBack(cssMM) == '1':
            print ('该银行密码必填')
            self.driver.find_element_by_css_selector(cssMM).send_keys(globaVar.backPWD)
            # self.driver.find_element_by_css_selector(cssMM).send_keys(Keys.ENTER)
        elif self.isDisableBack(cssMM) == '0':
            print ('该银行不需要密码2')
    # 否则如果不是必填、不是disable 且参数为1时
    elif self.isDisableBack(cssYHZH) == '0' and self.isMustBack(cssYHZH) == '0' and globaVar.backMust == '1':
        print ('银行卡号非必填,但参数控制填写……')
        self.inpuBackSCSR(cssYHZH, val)
        # 判断密码
        if self.isMustBack(cssMM) == '1':
            self.driver.find_element_by_css_selector(cssMM).send_keys(globaVar.backPWD)
            self.driver.find_element_by_css_selector(cssMM).send_keys(Keys.ENTER)
        elif self.isDisableBack(cssMM) == '0':
            print ('该银行不需要密码3')

    else:
        print ('银行卡号非必填,目前不填……')

    def inputBackJudge(self, cssDH, cssYHZH, cssMM, val):
        # 输入银行代号
        self.inputBack(cssDH, globaVar.back)
        # 判断
        if self.isDisableBack(cssYHZH) == '1':
            print ('该银行卡号distable')
            # 显示后
        elif self.isMustBack(cssYHZH) == '1':
            print ('该银行卡号必填')
            self.inpuBackSCSR(cssYHZH, val)
            # 判断密码
            if self.isMustBack(cssMM) == '1':
                print ('该银行密码必填')
                self.driver.find_element_by_css_selector(cssMM).send_keys(globaVar.backPWD)
                self.driver.find_element_by_css_selector(cssMM).send_keys(Keys.ENTER)
            elif self.isDisableBack(cssMM) == '0':
                print ('该银行不需要密码2')
        # 否则如果不是必填、不是disable 且参数为1时
        elif self.isDisableBack(cssYHZH) == '0' and self.isMustBack(
                cssYHZH) == '0' and globaVar.backMust == '1':
            print ('银行卡号非必填,但参数控制填写……')
            self.inpuBackSCSR(cssYHZH, val)
            # 判断密码
            if self.isMustBack(cssMM) == '1':
                self.driver.find_element_by_css_selector(cssMM).send_keys(globaVar.backPWD)
                self.driver.find_element_by_css_selector(cssMM).send_keys(Keys.ENTER)
            elif self.isDisableBack(cssMM) == '0':
                print ('该银行不需要密码3')

        else:
            print ('银行卡号非必填,目前不填……')

######################################start #################################################





def selectBack2(self, key):
    '''此方法选择银行,只需要传入Key'''
    try:
        val = '99999' + time.strftime('%Y%m%d%H%M%S', time.localtime(time.time()))
        val2 = '8888' + time.strftime('%Y%m%d%H%M%S', time.localtime(time.time()))
        val3 = '8888' + time.strftime('%Y%m%d%H%M%S', time.localtime(time.time()))

        # 三方存管银行、账号、密码

        csssfyh = "#cnyBankInfoForm > div > span:nth-child(2) > span > input"
        csssfzh = "#cnyBankInfoForm > div > span:nth-child(4) >  input"
        csssfmm = "#cnyBankInfoForm > div  > span.desc-val > input[name=BANK_PWD]"

        # 港币存管银行、账号、密码

        csshkyh = "#hkBankInfoForm > div > span:nth-child(2) > span > input"
        csshkzh = "#hkBankInfoForm > div > span:nth-child(4) >  input"
        csshkmm = "#hkBankInfoForm > div  > span.desc-val > input[name=BANK_PWD]"

        # 美元存管银行、账号、密码

        cssusyh = "#usBankInfoForm > div > span:nth-child(2) > span > input"
        cssuszh = "#usBankInfoForm > div > span:nth-child(4) >  input"
        cssusmm = "#usBankInfoForm > div  > span.desc-val > input[name=BANK_PWD]"

        if key == '01':
            # 如果是护照,则输入美元和港币

            self.inputBackJudge2(csshkyh, globaVar.hkback, csshkzh, csshkmm, val2)
            self.inputBackJudge2(cssusyh, globaVar.usback, cssuszh, cssusmm, val3)

        elif globaVar.stockCount == '7' or globaVar.stockCount == '4':
            # 否则选择7个模块,前四个时,输入三方,美元、港币

            self.inputBackJudge2(csssfyh, globaVar.back, csssfzh, csssfmm, val)

            # 港币 和 美元

            self.inputBackJudge2(csshkyh, globaVar.hkback, csshkzh, csshkmm, val2)
            self.inputBackJudge2(cssusyh, globaVar.usback, cssuszh, cssusmm, val3)

        elif  globaVar.stockCount == '2' or globaVar.stockCount == '0':
            # 选择二个时,只填三方

            self.inputBackJudge2(csssfyh, globaVar.back, csssfzh, csssfmm, val)
        else:
            self.my_print_info('error')

        time.sleep(1)
        # cssAN = '#passwordInfoWrap > div.item-row.link-wrap > span.desc-val > div > div > label:nth-child(1) > span.ovs-item-a'
        cssAN = '#passwordInfoWrap label:nth-child(1) > span.ovs-item-a'

        self.browerClick(cssAN)

        self.driver.find_element_by_css_selector("#TRD_PWD").send_keys(globaVar.backPWD)
        time.sleep(0.5)
        self.driver.find_element_by_css_selector("#TRD_PWD").send_keys(Keys.ENTER)

    finally:

        time.sleep(2)
        self.browerClick('#usBankInfoForm > div > span:nth-child(5)')
        self.driver.find_element_by_css_selector("#TRD_PWD2").send_keys(globaVar.backPWD)
        time.sleep(0.5)

#######################################################################


def inputRiskAss2(self, listVal):
    '''风险测评,输入列表字符串,后台方法自动处理'''
    time.sleep(3)
    str2 = globaVar.fxcp
    ls = list(listVal)
    size = len(listVal)

    for i in range(size):
        indexa = i + 2
        indexb = int(ls[i])
        var = "#flowPanel > div.flow-busi-wrap.clearfix > div.flow-work-wrap.clearfix > " \
              "div.risk-node.hide > div > div.risk-content-wrap > div.risk-col-wrap > div:nth-child(%d) > " \
              "div.obviousbox.clearfix > div > label:nth-child(%d) > span" % (indexa, indexb)

        time.sleep(1)
        self.driver.find_element_by_css_selector(var).click()
        time.sleep(1)

    # 下一步
    buttenNext = self.driver.find_element_by_css_selector("#next")
    self.driver.execute_script('$(arguments[0]).click()', buttenNext)
    time.sleep(2)

    # 测评结果下一步,在弹出框
    self.driver.find_element_by_css_selector("#next > span").click()

def setImage(self):
    '''影像节点提交'''

    # 提交
    time.sleep(3)
    self.driver.find_element_by_css_selector("#submit").click()
    time.sleep(1)

    self.driver.switch_to.default_content()
    cssqjcg = 'body > div.panel.window.messager-window > div.messager-body.panel-body.panel-body-noborder.window-body > div.messager-button > div > a.l-btn'
    self.executeJSClick(self.is_visible(cssqjcg))

    self.is_not_visible("body > div.panel.window.messager-window.message-loading > div")

def logout(self):
    '''登出,目前只判断了二类登出的情况'''
    self.driver.switch_to.default_content()
    self.driver.find_element_by_css_selector("div.user-info-box.pull-right  a.icon-logout").click()

    # cssAN2 = 'body > div.panel.window.messager-window > div.messager-body.panel-body.panel-body-noborder.window-body > div.messager-button > div:nth-child(1) > a'
    # if self.is_element_exist(cssAN2):
    #     self.executeJSClick(cssAN2)
    # else:

    for i in range(8, 20):
        cssAN1 = 'body > div:nth-child(%d) > div.messager-body.panel-body.panel-body-noborder.window-body > div.messager-button > div:nth-child(1) > a' % i
        if self.is_element_exist(cssAN1):
            self.executeJSClick(cssAN1)
            return True
        else:
            pass

def close(self):
    '''关闭浏览器,且无其它任何操作'''
    self.driver.close()

def auditOnelogin(self, url):
    ''' 一审操作页面登,需要输入环境fat或uat'''

    if url == "fat" and globaVar.um == '0':
        self.gylogin('10036', '123321', globaVar.url)
    elif url == "fat" and globaVar.um == '1':
        self.umlogin('LIUCHENG867', 'LIUCHENG867', globaVar.url)


    else:
        # uat审核
        url = 'http://10.25.168.170:30073/opp_webapp/'
        umname = 'ITBANLI528'
        umpass = '123321'
        self.umlogin(umname, umpass, url)

def auditTwologin(self, url):
    ''' 二审操作页面登,需要输入环境fat或uat'''

    if url == "fat" and globaVar.um == '0':
        self.gylogin('10036', '123321', globaVar.url)
    elif url == "fat" and globaVar.um == '1':
        self.umlogin('LIUCHENG867', 'LIUCHENG867', globaVar.url)


    else:
        # uat审核
        url = 'http://10.25.168.170:30073/opp_webapp/'
        umname = 'ITFUHE868'
        umpass = '123321'
        self.umlogin(umname, umpass, url)

def accountReview(self, k, v):
    '''开户审核,需要输入Key和val证件类型所对应的证件号码,其中通过后台参数来判断环境'''
    if globaVar.event == 'fat':
        shuser = 'LIUCHENG867'
        shpwd = 'LIUCHENG867'
        shuser2 = 'LIUCHENG867'
        shpwd2 = 'LIUCHENG867'
    elif globaVar.event == 'uat':
        shuser = 'ITBANLI528'
        shpwd = '123321'
        shuser2 = 'ITFUHE868'
        shpwd2 = '123321'

    print((self.getUserCode(globaVar.event, k, v)))
    # 登录审核页面#######
    self.loginNoRUL(shuser, shpwd)
    custCode = self.getUserCode(globaVar.event, k, v)
    # 调用输入客户代码
    self.inputBusName(custCode)
    # 一次审核
    self.auth()
    self.logout()
    # 调用输入客户代码,二次审核
    self.loginNoRUL(shuser2, shpwd2)
    self.inputBusName(custCode)
    self.auth()

def inputBusName(self, vuserCode):
    '''审核页面输入客户代码,清空开始日志输入当前日志后点击搜索'''

    self.ifrmaeSwitch('iframe[src*=genericParam]')
    time.sleep(1)
    # 开始日期
    cssKSRQ = "body > div.panel.datagrid > div > div.datagrid-queryForm > form > div > div:nth-child(5) > span.combo.datebox > input"

    cssKHDM = 'body > div.panel.datagrid > div > div.datagrid-queryForm > form > div > div:nth-child(4) > input'

    # 右边的查询按钮
    cssCQAN = 'body > div.panel.datagrid > div > div.datagrid-queryForm > form > div > div:nth-child(7) > div > a > span.btn-text'


    # self.driver.find_element_by_css_selector(cssKSRQ).clear()
    # self.driver.find_element_by_css_selector(cssKSRQ).send_keys(time.strftime("%Y%m%d"))
    # self.driver.find_element_by_css_selector(cssKHDM).clear()
    # self.driver.find_element_by_css_selector(cssKHDM).send_keys(vuserCode)
    # self.driver.find_element_by_css_selector(cssCQAN).click()
    self.browerClear(cssKSRQ)
    self.browerInput(cssKSRQ,time.strftime("%Y%m%d"))
    self.browerClear(cssKHDM)
    self.browerInput(cssKHDM,vuserCode)
    self.browerClick(cssCQAN)

def auth(self):
    '''开户审核时,判断生成资金帐户'''

    time.sleep(3)
    # 选择一列
    cssClick = '#datagrid-row-r1-2-0 > td:nth-child(3)'

    # 生成资金账号
    cssSC = '#bizInfo > div > fieldset.kui-fieldset.account-info-wrap.fieldset > div.info-wrap > div:nth-child(1) > span.desc-val.desc-full-width > span > span'

    # 点击第一列
    self.driver.find_element_by_css_selector(cssClick).click()

    time.sleep(5)
    # 确认按钮
    cssQRAN = "body > div.panel.window.messager-window > div.messager-body > div > div:nth-child(1) > a"

    # 获取是否有资金账号,此处选切回默认然后再到切一次

    self.driver.switch_to.default_content()
    self.driver.switch_to.frame(self.driver.find_element_by_css_selector('div.panel > div> iframe:nth-child(1)'))
    time.sleep(1)
    cjzhText = self.driver.find_element_by_css_selector('#CUACCT_CODE').get_attribute("title")
    print (cjzhText)
    cjzhDis = self.driver.find_element_by_css_selector('#CUACCT_CODE').get_attribute("disabled")

    if cjzhText.strip() == '':
        print ('info 第一次审核')
        self.driver.find_element_by_css_selector(cssSC).click()
        time.sleep(1)
        self.driver.find_element_by_css_selector('#passBtn').click()
        time.sleep(1)
        self.driver.find_element_by_css_selector(cssQRAN).click()

        time.sleep(1)

        self.driver.switch_to.default_content()

        cssqjcg = 'body > div > div.messager-body.panel-body.panel-body-noborder.window-body > div.messager-button > div > a'
        self.is_visible(cssqjcg)
        buttonqj1 = self.driver.find_element_by_css_selector(cssqjcg)
        time.sleep(1)
        self.driver.execute_script('$(arguments[0]).click()', buttonqj1)

    elif cjzhDis == 'true':
        try:
            time.sleep(1)
            self.driver.find_element_by_css_selector('#passBtn').click()
            time.sleep(1)
            self.driver.find_element_by_css_selector(cssQRAN).click()
            time.sleep(1)
            self.driver.switch_to.default_content()
            cssqjcg2 = 'body > div > div.messager-body.panel-body.panel-body-noborder.window-body > div.messager-button > div > a >'
            buttonqj2 = self.driver.find_element_by_css_selector(cssqjcg2)
            time.sleep(1)
            self.driver.execute_script('$(arguments[0]).click()', buttonqj2)
        except:
            pass

        finally:
            self.close()

def table(self):
    csstable = 'body > div.panel.datagrid > div.datagrid-wrap.panel-body.panel-body-noborder > div.datagrid-view > div.datagrid-view2 > div.datagrid-body > table > tbody'
    table = self.driver.find_element_by_css_selector(csstable)
    table_rows = table.find_elements_by_tag_name('tr')
    # print "u总行数:", len(table_rows)

    # tabler的总列数
    table_cols = table_rows[0].find_elements_by_tag_name('td')
    # print "u总列数:", len(table_cols)





    for i in range(len(table_rows) - 1):

        row_con1 = table_rows[i].find_elements_by_tag_name('td')[1].text
        row_con2 = table_rows[i].find_elements_by_tag_name('td')[2].text
        row_con3 = table_rows[i].find_elements_by_tag_name('td')[3].text
        row_con4 = table_rows[i].find_elements_by_tag_name('td')[4].text

        # 客户名称前二位
        row_con3Value1 = row_con3[:2]
        time.sleep(1)
        # 全局前变量二位
        row_con3Value2 = globaVar.userCode[:2]
        time.sleep(1)
        if row_con1 == globaVar.authStat1 or row_con1 == globaVar.authStat2 and row_con2 == globaVar.businessName and row_con3Value1 == row_con3Value2:
            self.driver.find_element_by_css_selector(
                "body > div.panel.datagrid > div.datagrid-wrap.panel-body.panel-body-noborder > div.datagrid-queryForm > form > div > div:nth-child(3) > input").send_keys(
                row_con4)
            self.driver.find_element_by_css_selector("#datagrid-row-r1-2-0").click()
            self.driver.find_element_by_css_selector(
                "body > div.panel.datagrid > div.datagrid-wrap.panel-body.panel-body-noborder > div.datagrid-queryForm > form > div > div:nth-child(6) > div > a > span.btn-text").click()
            time.sleep(3)
            self.driver.switch_to.frame(self.driver.find_element_by_css_selector("iframe:nth-child(1)"))
            time.sleep(1)
            self.driver.find_element_by_css_selector(
                "#bizInfo > div > fieldset.kui-fieldset.account-info-wrap.fieldset > div.info-wrap > div:nth-child(1) > span.desc-val.desc-full-width > span > span").click()
            time.sleep(1)
            self.driver.find_element_by_css_selector("#passBtn").click()

def getUserCode(self, hj, key, val):

    # 查询返回对等审核的usercode

    import cx_Oracle

    if hj == 'fat':

        db = cx_Oracle.connect(globaVar.dbfat)
    elif hj == 'uat':
        db = cx_Oracle.connect(globaVar.dbuat)

    cursor = db.cursor()

    # sql = "select cust_code from opp_busi_data where id_code = \'%s\'  and id_type = \'%s\'" % (cardid, idtype)
    sql = "select * from (select cust_code from opp_busi_data where id_type =\'%s\' and  id_code = \'%s\' order by oper_time desc ) where rownum = 1" % (
    key, val)
    # print sql
    time.sleep(1)
    rs = cursor.execute(sql)
    li = rs.fetchall()
    code = str(li)[3:12]
    db.close()
    # print code
    return code
    time.sleep(3)

#########################################################################################


def recognitionCust(self, custCode, passVal):
    # 识别客户代码
    # self.driver.switch_to.frame(self.driver.find_element_by_css_selector('iframe[src*=cust-recognite]'))
    self.ifrmaeSwitch('iframe[src*=cust-recognite]')
    time.sleep(2)
    # 输入客户代码来进行识别
    self.driver.find_element_by_css_selector('#IDENT_CODE').clear()
    self.driver.find_element_by_css_selector('#IDENT_CODE').send_keys(custCode)
    self.driver.find_element_by_css_selector('#regBtn').click()
    # 选中数据占且点击
    self.driver.find_element_by_css_selector('#datagrid-row-r1-2-0').click()
    self.driver.find_element_by_css_selector('#CUACCT_PWD').send_keys(passVal)
    time.sleep(1)
    # 确认按钮
    cssQRAN = 'body > div.panel.window > div.panel-body.panel-body-noborder.window-body > div.dialog-button > div:nth-child(1) > a'
    self.driver.find_element_by_css_selector(cssQRAN).click()

def enterMenu(self, menu):
    '''管理员业务中进入数字菜单,需要输入菜单序列号'''

    self.is_not_visible("body > div.panel.window.messager-window.message-loading > div")
    self.ifrmaeSwitch('iframe[src*=pages]')

    # 进入菜单
    cssInput = 'body > div.biz-nav-new.clearfix > div.menu-search-wrap > div.menu-search-box > input'
    cssSelect = 'body > div.biz-nav-new.clearfix > div.menu-search-wrap > div.menu-search-box > div > ul > li[data-menu-name="%s"]'%(menu)
    self.driver.find_element_by_css_selector(cssInput).send_keys(menu)
    time.sleep(1)
    print (cssSelect)
    #选择对应的菜单
    self.driver.find_element_by_css_selector(cssSelect).click()


    self.is_not_visible("body > div.panel.window.messager-window.message-loading > div > div")

    self.ifrmaeSwitch('iframe[src*=apps]')


def getPubStaticAccess(self):
    '''获取静态准入,待优化'''
    self.ifrmaeSwitch('iframe[src*=apps]')

    if self.is_element_exist('#accessBanTip'):
        # 禁止

        lists = self.driver.find_element_by_css_selector('#accessBanTip').find_elements_by_css_selector(
            'div.item-row-word')
        time.sleep(3)
        print((self.driver.text))
        print((len(lists)))
        print((self.driver.find_element_by_css_selector('#accessBanTip > div.item-title').text))
        for i in range(len(lists)):
            print((lists[i].text))
    elif self.is_element_exist('#accessWarnTip'):
        # 警告

        lists = self.driver.find_element_by_css_selector('#accessWarnTip').find_elements_by_css_selector(
            'div.item-row-word')
        time.sleep(3)
        print((self.driver.title))
        print((len(lists)))
        print((self.driver.find_element_by_css_selector('#accessWarnTip > div.item-title').text))
        for i in range(len(lists)):
            print((lists[i].text))
    elif self.is_element_exist('#accessPromptTip'):
        # 提示

        lists = self.driver.find_element_by_css_selector('#accessPromptTip').find_elements_by_css_selector(
            'div.item-row-word')
        time.sleep(3)
        print((self.driver.title))
        print((len(lists)))
        print((self.driver.find_element_by_css_selector('#accessPromptTip > div.item-title').text))
        for i in range(len(lists)):
            print((lists[i].text))
    elif self.is_element_exist('#msgTip > div.tip-content > span'):
        print((self.driver.find_element_by_css_selector('#msgTip > div.tip-content > span').text))

def clickZJZH(self, flag):
    '''点击股东账户,根据flag来判断开通类型,目前支持T+0'''

    self.driver.find_element_by_css_selector('#GEM_FIELDSET > div> div > label > span.ovs-item-a').click()

    self.is_not_visible('body > div.panel.window.messager-window.message-loading > div > div')
    if flag == '0':
        # 如果是开通创业板t+0
        self.browerClick('#BUTTON_GEMSTOCK > span')
        # self.driver.find_element_by_css_selector('#BUTTON_GEMSTOCK > span').click()
        self.executeJSClick(
            'body > div.panel.window.messager-window > div.messager-body.panel-body.panel-body-noborder.window-body > div.messager-button > div > a')

def getMarketInfo(self):

    '''获取创业板数据信息,并打印'''

    cssSRRJ = '#CUST_GEM_DATA_FORM > ul:nth-child(1) > li:nth-child(1) > span.sform-value'
    cssJYJY = '#CUST_GEM_DATA_FORM > ul:nth-child(1) > li:nth-child(2) > span.sform-value'
    cssFXCP = '#CUST_GEM_DATA_FORM > ul:nth-child(1) > li:nth-child(3) > span.sform-value'
    cssQYRQ = '#CUST_GEM_DATA_FORM > ul:nth-child(3) > li:nth-child(1) > span.sform-value'
    cssSXRQ = '#CUST_GEM_DATA_FORM > ul:nth-child(3) > li:nth-child(2) > span.sform-value'
    cssKTLX = '#CUST_GEM_DATA_FORM > ul:nth-child(3) > li:nth-child(3) > span.sform-value'
    cssKHZC = '#CUST_GEM_DATA_FORM > ul:nth-child(5) > li > span.sform-value'
    cssFXQS = '#GEM_FIELDSET > div.cust-gem-data-form-1 > div.cust-gem-data-form-2 > div.obviousbox.clearfix > div > label > span.item-checkbox'
    cssFXQSAN = '#GEM_FIELDSET > div.cust-gem-data-form-1 > div.cust-gem-data-form-2 > div.obviousbox.clearfix > div > label'
    cssGFCX = '#BUTTON_GEMSTOCK > span'

    valSRRJ = self.driver.find_element_by_css_selector(cssSRRJ).text
    valJYJY = self.driver.find_element_by_css_selector(cssJYJY).text
    valFXCP = self.driver.find_element_by_css_selector(cssFXCP).text
    valQYRQ = self.driver.find_element_by_css_selector(cssQYRQ).text
    valSXRQ = self.driver.find_element_by_css_selector(cssSXRQ).text
    valKTLX = self.driver.find_element_by_css_selector(cssKTLX).text
    valKHZC = self.driver.find_element_by_css_selector(cssKHZC).text
    valFXQS = self.driver.find_element_by_css_selector(cssFXQS).text
    isClick = self.driver.find_element_by_css_selector(cssFXQSAN).get_attribute('class')
    if isClick == 'ovs-item':
        print ('未勾选【客户可提供创业板风险揭示书副本】')
    elif isClick == 'ovs-item ovs-item-select':
        print ('已勾选【客户可提供创业板风险揭示书副本】')
    valGFCX = self.driver.find_element_by_css_selector(cssGFCX).text
    print (valSRRJ)
    print (valJYJY)
    print (valFXCP)
    print (valQYRQ)
    print (valSXRQ)
    print (valKTLX)
    print (valKHZC)
    print (valFXQS)
    print (valGFCX)

def inputMarkInof(self):
    '''创业板输入紧急联系人和电话号码'''
    self.browerClear('#LINKMAN')
    self.browerInput('#LINKMAN', '创业板联系人')
    cssAN = '#infoNodeWrap > fieldset:nth-child(4) > div > div:nth-child(2) > span.input-wrap > span'
    self.inputMobile2(globaVar.event, '#LINKMAN_TEL', cssAN, '#VALIAD_CODE')

    #
    cssQRAN = 'body > div.panel.window.messager-window > div.messager-body > div.messager-button > div > a > span'
    if self.is_element_exist(cssQRAN):
        self.browerClick(cssQRAN)

猜你喜欢

转载自blog.csdn.net/qq_24790545/article/details/82495298