class QueryOrder(): ''' classdocs ''' def __init__(self): ''' Constructor ''' self.commonActions = CommonActions() self.getinfo = ModifyInfoElements() def accessQueryOrder(self, driver): self.commonActions.readPublishINfo(driver) queryOrderXpath = '//*[@class="menu_list clearfix"]/li[4]/a/span[2]' self.commonActions.click(driver, queryOrderXpath) iframe = 'contentIframeTwo' driver.switch_to_frame(iframe) #时间选择 bgnTimeXpath = '//*[@id="myCommissonStart"]' self.commonActions.click(driver, bgnTimeXpath) time.sleep(2) driver.switch_to_default_content() iframeXpath = '//*[@src="about:blank"]' iframe1 = driver.find_element_by_xpath(iframeXpath) print "123" driver.switch_to_frame(iframe1) yesterdayXpath = '//*[@class="WdayTable"]/tbody/tr[7]/td[2]' self.commonActions.click(driver, yesterdayXpath) time.sleep(6) driver.switch_to_default_content() driver.switch_to_frame(iframe) queryOrderBtnXpath = '//*[@id="reSearch"]' self.commonActions.click(driver, queryOrderBtnXpath)
class AccountCenter(unittest.TestCase): def setUp(self): self.commonActions=CommonActions() self.acActions=AcountCenterActions() self.driver=self.commonActions.login() def tearDown(self): self.driver.quit() def qtest_ac001(self): u"""账户中心-账户金额校验""" driver=self.driver data=self.acActions.checkUserInfo(driver) result=self.acActions.verifyUserInfo(driver, data) print result self.assertEqual(True, result, u'话费充值校验失败:'+sys._getframe().f_code.co_name) driver.close() def qtest_ac002(self): u"""账户中心-添加银行卡""" driver=self.driver data=self.acActions.cardAdd(driver,13,3,13,4) driver.close() def test_ac003(self): u"""账户中心-添加银行卡""" driver=self.driver data=self.acActions.cardAdd(driver,14,3,14,4) driver.close()
class QueryInfo(unittest.TestCase): def setUp(self): print "===" self.commonActions = CommonActions() self.queryOrder = QueryOrder() self.driver = self.commonActions.login_ff() print "1" def tearDown(self): self.driver.quit() def test_md001(self): driver = self.driver self.queryOrder.accessQueryOrder(driver) print "2" time.sleep(20) driver.close()
class ModifyInfoCases(unittest.TestCase): def setUp(self): self.commonActions = CommonActions() self.mdActions = ModifyInfo() self.driver = self.commonActions.login() def tearDown(self): self.driver.quit() def qtest_md001(self): driver = self.driver self.mdActions.modifyInfo(driver, 1, 4, 6, 1, 18, 1, 19, 1, 20, 1, 1, 9, 1, 10) result = self.mdActions.verifyModifyInfo(driver) print result self.assertEqual(True, result, u'修改个人信息:' + sys._getframe().f_code.co_name) time.sleep(20) driver.close()
def setUp(self): self.commonActions=CommonActions() self.acActions=AcountCenterActions() self.driver=self.commonActions.login()
def setUp(self): print "===" self.commonActions = CommonActions() self.queryOrder = QueryOrder() self.driver = self.commonActions.login_ff() print "1"
def __init__(self): self.commonActions = CommonActions() self.getinfo = SetParameters()
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
class MobilePhoneRecharge(unittest.TestCase): def setUp(self): self.actions=CommonActions() self.driver=self.actions.login() self.settIng=SetParameters() def qtest_mpRecharge001(self): u"""话费充值""" #18200583387充值10元 driver=self.driver self.actions.mbRecharge(driver,6, 4, 16, 5) result=self.actions.verifyMbRecharge(driver) print result self.assertEqual(True, result, u'话费充值校验失败:'+sys._getframe().f_code.co_name) self.driver.close() def qtest_mpRecharge002(self): u"""话费充值""" driver=self.driver #18200583387充值10元 self.actions.mbRecharge(driver,7, 4, 17, 5) result=self.actions.verifyMbRecharge(driver) print result self.assertEqual(True, result, u'话费充值校验失败:'+sys._getframe().f_code.co_name) self.driver.close() def qtest_mpRecharge003(self): u"""话费充值""" #18200583387充值10元 driver=self.driver self.actions.mbRecharge(driver,8, 4, 18, 5) result=self.actions.verifyMbRecharge(driver) print result self.assertEqual(True, result, u'话费充值校验失败:'+sys._getframe().f_code.co_name) self.driver.close() def qtest_mpRecharge004(self): u"""话费充值""" #18200583387充值10元 driver=self.driver self.actions.mbRecharge(driver,8, 4, 19, 5) result=self.actions.verifyMbRecharge(driver) print result self.assertEqual(True, result, u'话费充值校验失败:'+sys._getframe().f_code.co_name) self.driver.close() def qtest_mpRecharge005(self): u"""话费充值""" #18200583387充值10元 driver=self.driver self.actions.mbRecharge(driver,9, 4, 20, 5) result=self.actions.verifyMbRecharge(driver) print result self.assertEqual(True, result, u'话费充值校验失败:'+sys._getframe().f_code.co_name) self.driver.close() def qtest_mpRecharge006(self): u"""话费充值""" #18200583387充值10元 driver=self.driver self.actions.mbRecharge(driver,10, 4, 21, 5) result=self.actions.verifyMbRecharge(driver) print result self.assertEqual(True, result, u'话费充值校验失败:'+sys._getframe().f_code.co_name) self.driver.close() def qtest_mpRecharge007(self): u"""话费充值""" #18200583387充值10元 driver=self.driver self.actions.mbRecharge(driver,11, 4, 22, 5) result=self.actions.verifyMbRecharge(driver) print result self.assertEqual(True, result, u'话费充值校验失败:'+sys._getframe().f_code.co_name) self.driver.close() def qtest_mpRecharge008(self): u"""话费充值""" #18200583387充值10元 driver=self.driver self.actions.mbRecharge(driver,12, 4, 23, 5) result=self.actions.verifyMbRecharge(driver) print result self.assertEqual(True, result, u'话费充值校验失败:'+sys._getframe().f_code.co_name) self.driver.close() def qtest_mpRecharge009(self): u"""话费充值""" #18200583387省市检查 driver=self.driver result=self.actions.rechargeProvinceCheck(driver,12, 4) print result self.assertEqual(True, result, u'话费充值校验失败:'+sys._getframe().f_code.co_name) self.driver.close() def qtest_mpRecharge010(self): u"""话费充值""" #18200583387省市检查 driver=self.driver result=self.actions.rechargeProvinceCheck(driver,11, 4) print result self.assertEqual(True, result, u'话费充值校验失败:'+sys._getframe().f_code.co_name) self.driver.close() def qtest_mpRecharge011(self): u"""话费充值""" #18200583387省市检查 driver=self.driver result=self.actions.rechargeProvinceCheck(driver,10, 4) print result self.assertEqual(True, result, u'话费充值校验失败:'+sys._getframe().f_code.co_name) self.driver.close() def qtest_mpRecharge012(self): u"""话费充值""" #18200583387省市检查 driver=self.driver result=self.actions.rechargeProvinceCheck(driver,9, 4) print result self.assertEqual(True, result, u'话费充值校验失败:'+sys._getframe().f_code.co_name) self.driver.close() def qtest_mpRecharge013(self): u"""话费充值""" #18200583387省市检查 driver=self.driver result=self.actions.rechargeProvinceCheck(driver,8, 4) print result self.assertEqual(True, result, u'话费充值校验失败:'+sys._getframe().f_code.co_name) self.driver.close() def qtest_mpRecharge014(self): u"""话费充值""" #18200583387省市检查 driver=self.driver result=self.actions.rechargeProvinceCheck(driver,7, 4) print result self.assertEqual(True, result, u'话费充值校验失败:'+sys._getframe().f_code.co_name) self.driver.close() def qtest_mpRecharge015(self): u"""话费充值""" #18200583387省市检查 driver=self.driver result=self.actions.rechargeProvinceCheck(driver,6, 4) print result self.assertEqual(True, result, u'话费充值校验失败:'+sys._getframe().f_code.co_name) self.driver.close() def qtest_mpRecharge016(self): u"""话费充值""" #18200583387余额查询 driver=self.driver queryInfo=self.actions.balanceQuery(driver,6, 4) result=self.actions.varifybalanceQuery(queryInfo) print result self.assertEqual(True, result, u'话费充值校验失败:'+sys._getframe().f_code.co_name) self.driver.close() def qtest_mpRecharge017(self): u"""话费充值""" #电话号码位数不够 driver=self.driver self.actions.mbRechargeError(driver,14, 4, 16, 5) result=self.actions.verifyMbRecharge(driver) print result self.assertEqual(True, result, u'话费充值校验失败:'+sys._getframe().f_code.co_name) self.driver.close() def qtest_mpRecharge018(self): u"""话费充值""" #不是电话号码 driver=self.driver self.actions.mbRechargeError(driver,15, 4, 16, 5) result=self.actions.verifyMbRechargeError(driver) print result self.assertEqual(True, result, u'话费充值校验失败:'+sys._getframe().f_code.co_name) self.driver.close() def qtest_mpRecharge019(self): u"""话费充值""" #取消支付 driver=self.driver number=self.actions.mbRechargeCancle(driver,16, 4, 16, 5) result=self.actions.verifymbRechargeCancle(driver,number) print result self.assertEqual(True, result, u'话费充值校验失败:'+sys._getframe().f_code.co_name) self.driver.close() def qtest_mpRecharge020(self): u"""话费充值""" #继续支付 driver=self.driver self.actions.mbRechargeContinue(driver,16, 4, 16, 5) result=self.actions.verifyMbRecharge(driver) print result self.assertEqual(True, result, u'话费充值校验失败:'+sys._getframe().f_code.co_name) self.driver.close() def test_mpRecharge023(self): u"""话费充值""" #订单取消 driver=self.driver result=self.actions.mbRechargeCancleOrder(driver,17, 4, 16, 5) print result self.assertEqual(True, result, u'话费充值校验失败:'+sys._getframe().f_code.co_name) self.driver.close() def tearDown(self): self.driver.quit()
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
def setUp(self): self.commonActions = CommonActions() self.teleActions = TeleActions() self.driver = self.commonActions.login()
class TeleRecharge(unittest.TestCase): def setUp(self): self.commonActions = CommonActions() self.teleActions = TeleActions() self.driver = self.commonActions.login() def qtest_teleRecharge001(self): u"""话费充值""" #18200583387充值10元 driver = self.driver self.teleActions.teleRecharge(driver, 1, 0, 1, 1) result = self.commonActions.verifyMbRecharge(driver) print result self.assertEqual(True, result, u'固话充值校验失败:' + sys._getframe().f_code.co_name) driver.close() def qtest_teleRecharge002(self): u"""话费充值""" #18200583387充值10元 driver = self.driver self.teleActions.teleRecharge(driver, 2, 0, 2, 1) result = self.commonActions.verifyMbRecharge(driver) print result self.assertEqual(True, result, u'固话充值校验失败:' + sys._getframe().f_code.co_name) driver.close() def qtest_teleRecharge003(self): u"""话费充值""" #18200583387充值10元 driver = self.driver self.teleActions.teleRecharge(driver, 3, 0, 3, 1) result = self.commonActions.verifyMbRecharge(driver) print result self.assertEqual(True, result, u'固话充值校验失败:' + sys._getframe().f_code.co_name) driver.close() def qtest_teleRecharge004(self): u"""话费充值""" #18200583387充值10元 driver = self.driver self.teleActions.teleRecharge(driver, 4, 0, 4, 1) result = self.commonActions.verifyMbRecharge(driver) print result self.assertEqual(True, result, u'固话充值校验失败:' + sys._getframe().f_code.co_name) driver.close() def qtest_teleRecharge005(self): u"""话费充值""" #省市检查 driver = self.driver result = self.teleActions.teleRechargeProvinceCheck(driver, 7, 0, 7, 1) print result self.assertEqual(True, result, u'固话充值校验失败:' + sys._getframe().f_code.co_name) driver.close() def qtest_teleRecharge006(self): u"""话费充值""" #省市检查 driver = self.driver result = self.teleActions.teleRechargeProvinceCheck(driver, 8, 0, 8, 1) print result self.assertEqual(True, result, u'固话充值校验失败:' + sys._getframe().f_code.co_name) driver.close() def qtest_teleRecharge007(self): u"""话费充值""" #核对号码 driver = self.driver result = self.teleActions.teleRechargeNumCheck(driver, 9, 0, 9, 1) print result self.assertEqual(True, result, u'固话充值校验失败:' + sys._getframe().f_code.co_name) driver.close() def qtest_teleRecharge008(self): u"""话费充值""" #取消支付 driver = self.driver area_num = self.teleActions.cancleRecharge(driver, 5, 0, 5, 1) result = self.teleActions.verifyCancleRecharge(driver, area_num) print result self.assertEqual(True, result, u'固话充值校验失败:' + sys._getframe().f_code.co_name) driver.close() def qtest_teleRecharge009(self): u"""话费充值""" #继续支付 driver = self.driver self.teleActions.continueRecharge(driver, 6, 0, 6, 1) result = self.commonActions.verifyMbRecharge(driver) print result self.assertEqual(True, result, u'固话充值校验失败:' + sys._getframe().f_code.co_name) driver.close() def qtest_teleRecharge010(self): u"""话费充值""" #不支持该类号码 driver = self.driver self.teleActions.teleRechargeError(driver, 10, 0, 10, 1) result = self.teleActions.verifyTeleRechargeNotSupport(driver) print result self.assertEqual(True, result, u'固话充值校验失败:' + sys._getframe().f_code.co_name) driver.close() def qtest_teleRecharge011(self): u"""话费充值""" #号码异常 driver = self.driver self.teleActions.teleRechargeError(driver, 11, 0, 11, 1) result = self.teleActions.verifyTeleRechargeError(driver) print result self.assertEqual(True, result, u'固话充值校验失败:' + sys._getframe().f_code.co_name) driver.close() def qtest_teleRecharge012(self): u"""话费充值""" #号码异常 driver = self.driver self.teleActions.teleRechargeError(driver, 12, 0, 12, 1) result = self.teleActions.verifyTeleRechargeError(driver) print result self.assertEqual(True, result, u'固话充值校验失败:' + sys._getframe().f_code.co_name) driver.close() def qtest_teleRecharge013(self): u"""话费充值""" #号码异常 driver = self.driver self.teleActions.teleRechargeError(driver, 13, 0, 13, 1) result = self.teleActions.verifyTeleRechargeError(driver) print result self.assertEqual(True, result, u'固话充值校验失败:' + sys._getframe().f_code.co_name) driver.close() def qtest_teleRecharge014(self): u"""话费充值""" #进货价验证 driver = self.driver result = self.teleActions.teleRechargePriceCheck( driver, 14, 0, 14, 1, 5, 8) print result self.assertEqual(True, result, u'固话充值校验失败:' + sys._getframe().f_code.co_name) driver.close() def qtest_teleRecharge015(self): u"""话费充值""" #进货价验证 driver = self.driver result = self.teleActions.teleRechargePriceCheck( driver, 15, 0, 15, 1, 6, 8) print result self.assertEqual(True, result, u'固话充值校验失败:' + sys._getframe().f_code.co_name) driver.close() def qtest_teleRecharge016(self): u"""话费充值""" #进货价验证 driver = self.driver result = self.teleActions.teleRechargePriceCheck( driver, 16, 0, 16, 1, 7, 8) print result self.assertEqual(True, result, u'固话充值校验失败:' + sys._getframe().f_code.co_name) driver.close() def qtest_teleRecharge017(self): u"""话费充值""" #进货价验证 driver = self.driver result = self.teleActions.teleRechargePriceCheck( driver, 17, 0, 17, 1, 8, 8) print result self.assertEqual(True, result, u'固话充值校验失败:' + sys._getframe().f_code.co_name) driver.close() def test_teleRecharge018(self): u"""话费充值""" #订单取消 driver = self.driver area_num = self.teleActions.cancleOrder(driver, 18, 0, 18, 1) result = self.teleActions.verifyCancleOrder(driver, area_num) print result self.assertEqual(True, result, u'固话充值校验失败:' + sys._getframe().f_code.co_name) driver.close() def tearDown(self): self.driver.quit()
def setUp(self): self.commonActions = CommonActions() self.mdActions = ModifyInfo() self.driver = self.commonActions.login()
class advantageActions(unittest.TestCase): def setUp(self): self.commonActions=CommonActions() self.adActions=AdvantageActions() self.driver=self.commonActions.login() def tearDown(self): self.driver.quit() def qtest_adRecharge001(self): u"""优势话费充值""" driver=self.driver self.adActions.adRecharge(driver, 1, 0, 16, 5) result=self.commonActions.verifyMbRecharge(driver) print result self.assertEqual(True, result, u'话费充值校验失败:'+sys._getframe().f_code.co_name) driver.close() def qtest_adRecharge002(self): u"""优势话费充值""" driver=self.driver self.adActions.adRecharge(driver, 2, 0, 17, 5) result=self.commonActions.verifyMbRecharge(driver) print result self.assertEqual(True, result, u'话费充值校验失败:'+sys._getframe().f_code.co_name) driver.close() def qtest_adRecharge003(self): u"""优势话费充值""" driver=self.driver self.adActions.adRecharge(driver, 3, 0, 18, 5) result=self.commonActions.verifyMbRecharge(driver) print result self.assertEqual(True, result, u'话费充值校验失败:'+sys._getframe().f_code.co_name) driver.close() def qtest_adRecharge004(self): u"""优势话费充值""" driver=self.driver self.adActions.adRecharge(driver, 4, 0, 19, 5) result=self.commonActions.verifyMbRecharge(driver) print result self.assertEqual(True, result, u'话费充值校验失败:'+sys._getframe().f_code.co_name) driver.close() def qtest_adRecharge005(self): u"""优势话费充值""" driver=self.driver self.adActions.adRecharge(driver, 5, 0, 20, 5) result=self.commonActions.verifyMbRecharge(driver) print result self.assertEqual(True, result, u'话费充值校验失败:'+sys._getframe().f_code.co_name) driver.close() def qtest_adRecharge006(self): u"""优势话费充值""" driver=self.driver self.adActions.adRecharge(driver, 6, 0, 22, 5) result=self.commonActions.verifyMbRecharge(driver) print result self.assertEqual(True, result, u'话费充值校验失败:'+sys._getframe().f_code.co_name) driver.close() def qtest_adRecharge007(self): u"""优势话费充值""" driver=self.driver self.adActions.adRecharge(driver, 7, 0, 23, 5) result=self.commonActions.verifyMbRecharge(driver) print result self.assertEqual(True, result, u'话费充值校验失败:'+sys._getframe().f_code.co_name) driver.close() def qtest_adRecharge008(self): u"""优势话费充值-不是优势地区""" driver=self.driver info=self.adActions.disAdRecharge(driver, 8, 0) result=self.adActions.verifyDisAdRecharge(info) print result self.assertEqual(True, result, u'话费充值校验失败:'+sys._getframe().f_code.co_name) driver.close() def qtest_adRecharge009(self): u"""优势话费充值-不是优势地区""" driver=self.driver info=self.adActions.disAdRecharge(driver, 9, 0) result=self.adActions.verifyAdRechargeErrorNum(info) print result self.assertEqual(True, result, u'话费充值校验失败:'+sys._getframe().f_code.co_name) driver.close()
def setUp(self): self.actions=CommonActions() self.driver=self.actions.login() self.settIng=SetParameters()
def setUp(self): self.commonActions=CommonActions() self.adActions=AdvantageActions() self.driver=self.commonActions.login()
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
def __init__(self): ''' Constructor ''' self.commonActions = CommonActions() self.getinfo = ModifyInfoElements()
class AdvantageActions(): ''' classdocse ''' def __init__(self): self.getinfo = SetParameters() self.commonActions = CommonActions() def adRecharge(self, driver, phone_row, phone_col, amount_row, amount_col): #话费充值 self.enterAdRecharge(driver, phone_row, phone_col, amount_row, amount_col) self.adReChargeConfirm(driver) def enterAdRecharge(self, driver, phone_row, phone_col, amount_row, amount_col): self.commonActions.publishMsg(driver) iframe = self.getinfo.setElementConfig(8, 5) item = self.getinfo.setElementConfig(11, 5) try: #WebDriverWait(driver, 20).until(lambda the_driver: the_driver.find_element_by_xpath(mbRecharge).is_displayed()) #element = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, mbRecharge))) time.sleep(5) driver.find_element_by_xpath(item).click() except: print "element error" driver.switch_to_frame(iframe) phonenumber = self.getinfo.setAdRechargeConfig(phone_row, phone_col) rechargeAmount = self.getinfo.setElementConfig(amount_row, amount_col) #amount=driver.find_element_by_xpath(rechargeAmount).text phonenumberId = self.getinfo.setElementConfig(15, 5) confirmRechargeId = self.getinfo.setElementConfig(24, 5) driver.find_element_by_id(phonenumberId).send_keys(phonenumber) driver.find_element_by_xpath(rechargeAmount).click() driver.find_element_by_xpath(confirmRechargeId).click() def adReChargeConfirm(self, driver): ensureId = self.getinfo.setElementConfig(26, 5) driver.find_element_by_id(ensureId).click() def disAdRecharge(self, driver, phone_row, phone_col): self.commonActions.publishMsg(driver) item = self.getinfo.setElementConfig(11, 5) iframe = self.getinfo.setElementConfig(8, 5) try: #WebDriverWait(driver, 20).until(lambda the_driver: the_driver.find_element_by_xpath(mbRecharge).is_displayed()) #element = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, mbRecharge))) time.sleep(5) driver.find_element_by_xpath(item).click() except: print "element error" driver.switch_to_frame(iframe) phonenumberId = self.getinfo.setElementConfig(15, 5) phonenumber = self.getinfo.setAdRechargeConfig(phone_row, phone_col) driver.find_element_by_id(phonenumberId).send_keys(phonenumber) #回到主窗体,因为提示语在主窗体,否则无法定位 driver.switch_to_default_content() infoXpath = self.getinfo.setAdRechargeConfig(1, 5) self.commonActions.waitForElement(driver, infoXpath) info = driver.find_element_by_xpath(infoXpath).text print info return info def verifyDisAdRecharge(self, info): result = self.getinfo.setAdRechargeConfig(8, 2) flag = False if info == result: flag = True return flag return flag def verifyAdRechargeErrorNum(self, info): result = self.getinfo.setAdRechargeConfig(9, 2) flag = False if info == result: flag = True return flag return flag