コード例 #1
0
class TeleActions():
    '''
    classdocse
    '''
    def __init__(self):

        self.getinfo = SetParameters()
        self.commonActions = CommonActions()

    def accessTeleRecharge(self, driver, area_row, area_col, num_row, num_col):
        #进入固话充值
        try:
            self.commonActions.publishMsg(driver)
        except:
            print "没有推送消息!"
        teleRechargexpath = self.getinfo.setElementConfig(10, 5)
        try:
            WebDriverWait(
                driver,
                30).until(lambda the_driver: the_driver.find_element_by_xpath(
                    teleRechargexpath).is_displayed())
        except:
            print "not found!"
        time.sleep(1)
        driver.find_element_by_xpath(teleRechargexpath).click()
        telephoneAreaId = self.getinfo.setTelePhoneConfig(1, 8)
        telephoneAreaNum = self.getinfo.setTelePhoneConfig(area_row, area_col)
        self.commonActions.switchToIframe(driver)
        driver.find_element_by_id(telephoneAreaId).send_keys(telephoneAreaNum)
        telephoneNumId = self.getinfo.setTelePhoneConfig(2, 8)
        telephoneNum = self.getinfo.setTelePhoneConfig(num_row, num_col)
        driver.find_element_by_id(telephoneNumId).send_keys(telephoneNum)

    def clickConfirmRecharge(self, driver):
        confirmPayxpath = self.getinfo.setTelePhoneConfig(10, 8)
        driver.find_element_by_xpath(confirmPayxpath).click()

    def teleRecharge(self, driver, area_row, area_col, num_row, num_col):
        self.accessTeleRecharge(driver, area_row, area_col, num_row, num_col)
        amountXpath = self.getinfo.setTelePhoneConfig(5, 8)
        driver.find_element_by_xpath(amountXpath).click()
        quickPayXpath = self.getinfo.setTelePhoneConfig(9, 8)
        driver.find_element_by_xpath(quickPayXpath).click()
        self.clickConfirmRecharge(driver)

    def teleRechargeError(self, driver, area_row, area_col, num_row, num_col):
        self.accessTeleRecharge(driver, area_row, area_col, num_row, num_col)
        amountXpath = self.getinfo.setTelePhoneConfig(5, 8)
        driver.find_element_by_xpath(amountXpath).click()
        quickPayXpath = self.getinfo.setTelePhoneConfig(9, 8)
        driver.find_element_by_xpath(quickPayXpath).click()

    def verifyTeleRechargeError(self, driver):
        errorResult = self.getinfo.setTelePhoneConfig(16, 7)
        errorResultXpath = self.getinfo.setTelePhoneConfig(16, 8)
        errorInfo = driver.find_element_by_xpath(errorResultXpath).text
        flag = False
        if errorInfo == errorResult:
            flag = True
            return flag

        return flag

    def verifyTeleRechargeNotSupport(self, driver):
        errorResult = self.getinfo.setTelePhoneConfig(17, 7)
        errorResultXpath = self.getinfo.setTelePhoneConfig(17, 8)
        errorInfo = driver.find_element_by_xpath(errorResultXpath).text
        flag = False
        if errorInfo == errorResult:
            flag = True
            return flag

        return flag

    def teleRechargeProvinceCheck(self, driver, area_row, area_col, num_row,
                                  num_col):
        self.accessTeleRecharge(driver, area_row, area_col, num_row, num_col)
        province = self.getinfo.setTelePhoneConfig(area_row, (area_col + 4))
        l_province_xpath = self.getinfo.setTelePhoneConfig(12, 8)
        try:
            WebDriverWait(
                driver,
                30).until(lambda the_driver: the_driver.find_element_by_xpath(
                    l_province_xpath).is_displayed())
        except:
            print "not found!"
        l_province = driver.find_element_by_xpath(l_province_xpath).text
        flag = False
        if province == l_province:
            flag = True
            return flag
        else:
            return flag

        return flag

    def teleRechargeNumCheck(self, driver, area_row, area_col, num_row,
                             num_col):
        self.accessTeleRecharge(driver, area_row, area_col, num_row, num_col)
        l_area = self.getinfo.setTelePhoneConfig(area_row, area_col)
        l_num = str(int(self.getinfo.setTelePhoneConfig(num_row, num_col)))
        l_area_num = l_area + "-" + l_num
        l_area_checkId = self.getinfo.setTelePhoneConfig(3, 8)
        l_area_check = driver.find_element_by_xpath(l_area_checkId).text
        l_num_checkId = self.getinfo.setTelePhoneConfig(4, 8)
        l_num_check = driver.find_element_by_xpath(l_num_checkId).text
        l_area_num_check = l_area_check + l_num_check
        flag = False
        if l_area_num == l_area_num_check:
            flag = True
            return flag

        return flag

    def cancleRecharge(self, driver, area_row, area_col, num_row, num_col):
        self.accessTeleRecharge(driver, area_row, area_col, num_row, num_col)
        amountXpath = self.getinfo.setTelePhoneConfig(5, 8)
        driver.find_element_by_xpath(amountXpath).click()
        quickPayXpath = self.getinfo.setTelePhoneConfig(9, 8)
        driver.find_element_by_xpath(quickPayXpath).click()
        canclexpathId = self.getinfo.setTelePhoneConfig(11, 8)
        try:
            WebDriverWait(driver, 30).until(
                lambda the_driver: the_driver.find_element_by_xpath(
                    canclexpathId).is_displayed(), u"没有找到取消按钮")
        except Exception, e:
            print e
            pass
        driver.find_element_by_xpath(canclexpathId).click()
        area_num = self.getAreaNum(area_row, area_col, num_row, num_col)

        return area_num
コード例 #2
0
class AcountCenterActions():
    '''
    classdocs
    '''
    def __init__(self):
        self.commonActions = CommonActions()
        self.getinfo = SetParameters()

    def accessAc(self, driver):
        self.commonActions.readPublishINfo(driver)
        myAccountXpath = self.getinfo.setMyAccountXpath()
        accountCenterXpath = self.getinfo.setAccountCenterXpath()
        self.commonActions.moveToElement(driver, accountCenterXpath)
        self.commonActions.click(driver, myAccountXpath)
        self.commonActions.switchToIframe(driver)

    def checkUserInfo(self, driver):
        self.accessAc(driver)
        sql = 'select balance,credit_amount,frozen_amount from account_fund where account_id=' + "'" + '5279' + "'"
        data = self.commonActions.conn(sql)

        return data

    def verifyUserInfo(self, driver, data):
        totalBalanceXpath = self.getinfo.setTotalBalanceXpath()
        balanceXpath = self.getinfo.setBalanceXpath()
        frozenXpath = self.getinfo.setFrozenXpath()
        totalBalance = self.commonActions.getElementText(
            driver, totalBalanceXpath)
        balance = self.commonActions.getElementText(driver, balanceXpath)
        frozen = self.commonActions.getElementText(driver, frozenXpath)
        flag = False
        if data[0] == int(float(totalBalance) * 100):
            if data[1] == int(float(balance) * 100):
                if data[2] == int(float(frozen) * 100):
                    flag = True
                    return flag
                else:
                    print "冻结余额不正确!"
                    return flag
            else:
                print "可用余额不正确!"
                return flag
        else:
            print "总金额不正确!"
            return flag

    def cardAdd(self, driver, card_row, card_col, num_row, num_col):
        self.accessAc(driver)
        #点击添加银行卡
        cardAddXpath = self.getinfo.setCardAddXpath()
        self.commonActions.click(driver, cardAddXpath)
        #点击选择其他银行
        choseOtherBankXpath = self.getinfo.setChoseOtherCardXpath()
        self.commonActions.click(driver, choseOtherBankXpath)
        #选择银行卡
        BankXpath = self.getinfo.setAcConfig(card_row, card_col)
        self.commonActions.click(driver, BankXpath)
        bankNum = self.getinfo.setAcConfig(num_row, num_col)
        bankNumXpath = self.getinfo.setBankNumXpath()
        self.commonActions.sendContent(driver, bankNumXpath, bankNum)
        phoneXpath = self.getinfo.setPhoneNumXpath()
        phoneNum = self.commonActions.userName
        self.commonActions.sendContent(driver, phoneXpath, phoneNum)
        sendVercodeXpath = self.getinfo.setSendVerCodeXpath()
        self.commonActions.click(driver, sendVercodeXpath)
        time.sleep(2)
        #获取验证码
        sql = 'select version from account_fund where account_id=' + "'" + '5279' + "'"
        time.sleep(1)
        data = self.commonActions.conn(sql)
        vercodeXpath = self.getinfo.setVerCodeXpath()
        self.commonActions.sendContent(driver, vercodeXpath, data[0])
        dredgeQuickPayXpath = self.getinfo.setDredgeQuickPay()
        self.commonActions.click(driver, dredgeQuickPayXpath)

        return data
コード例 #3
0
ファイル: modifyInfo.py プロジェクト: dingerhuang/selenium
class ModifyInfo():
    '''
    classdocs
    '''


    def __init__(self):
        '''
        Constructor
        '''
        self.commonActions=CommonActions()
        self.getinfo=ModifyInfoElements()
        
    def accessModifyInfo(self,driver):
        self.commonActions.readPublishINfo(driver)
        safeCenterXpath=self.getinfo.getSafeCenterXpath()
        modifyInfoXpath=self.getinfo.getModifyInfoXpath()
        modifyNowXpath=self.getinfo.getModifyBtnXpath()
        self.commonActions.moveToElement(driver, safeCenterXpath)
        #self.commonActions.switchToIframe(driver)
        self.commonActions.click(driver, modifyInfoXpath)
        self.commonActions.switchToIframe(driver)
        self.commonActions.click(driver, modifyNowXpath)
        
    def modifyInfo(self,driver,sn_row,sn_col,st_row,st_col,p_row,p_col,c_row,c_col,a_row,a_col,ad_row,ad_col,qq_row,qq_col):
        self.accessModifyInfo(driver)
        #填写店铺名称
        shopNameXpath=self.getinfo.getShopNameXpath()
        shopName=self.getinfo.getModifyInfo(sn_row,sn_col)
        self.commonActions.sendContent(driver, shopNameXpath, shopName)
        #填写店铺类型
        shopTypeXpath=self.getinfo.getShopTypeXpath()
        shopType=self.getinfo.getModifyInfo(st_row,st_col)
        self.commonActions.click(driver, shopTypeXpath)
        self.commonActions.click(driver, shopType)
        #选择省份
        provinceXpath=self.getinfo.getProvinceXpath()
        self.commonActions.click(driver, provinceXpath)
        province=self.getinfo.getModifyInfo(p_row,p_col)
        self.commonActions.click(driver, province)
        #选择城市
        cityXpath=self.getinfo.getCityXpath()
        self.commonActions.click(driver, cityXpath)
        city=self.getinfo.getModifyInfo(c_row,c_col)
        self.commonActions.click(driver, city)
        #选择地区
        areaXpath=self.getinfo.getAreaXpath()
        self.commonActions.click(driver, areaXpath)
        area=self.getinfo.getModifyInfo(a_row,a_col)
        self.commonActions.click(driver, area)
        #填写地址
        addressXpath=self.getinfo.getAddressXpath()
        address=self.getinfo.getModifyInfo(ad_row,ad_col)
        self.commonActions.sendContent(driver, addressXpath, address)
        qqNumXpath=self.getinfo.getQQNumXpath()
        qqNum=self.getinfo.getModifyInfo(qq_row,qq_col)
        self.commonActions.sendContent(driver, qqNumXpath, qqNum)
        
        #点击确定
        confirmXpath=self.getinfo.getConfirmBtnXpath()
        self.commonActions.click(driver, confirmXpath)
        
    def verifyModifyInfo(self,driver):
        standard=self.getinfo.getModifyInfo(17, 0)
        resultXpath=self.getinfo.getSuccessInfoXpath()
        result=self.commonActions.getElementText(driver, resultXpath)
        flag=False
        print standard,result
        if standard==result:
            flag=True
            return flag
        
        return flag