Пример #1
0
 def to_cash_with_drawl(self, case_name):
     try:
         util = Utils()
         util.getElementById(CashWithDrawalHelper.driver,
                             MyPage.resid_my_button).click()
         util.getElementById(CashWithDrawalHelper.driver,
                             MyPage.resid_my_record).click()
         util.take_screenShot(CashWithDrawalHelper.driver, case_name, 2)
         util.getElementById(CashWithDrawalHelper.driver,
                             MyPage.resid_back_button).click()
     except Exception as e:
         print("发现异常")
         print(e)
         raise SystemError
Пример #2
0
 def to_my_page(self,case_name,second):
     try:
         time.sleep(second)
         my_page = MyPage()
         util=Utils()
         util.getElementById(MyHelper.driver,my_page.resid_my_button).click()
         if second>0 :
             util.getImage(MyHelper.driver, case_name, second)
         else:
             util.getImage(MyHelper.driver, case_name, second)
     except Exception as e:
         print("发现异常")
         print(e)
         raise SystemError
Пример #3
0
 def to_exhibition_room(self,case_name,second):
     try:
         time.sleep(second)
         my_page = MyPage()
         util=Utils()
         util.getElementById(MyHelper.driver,my_page.resid_exhibitionRoom_button).click();
         print("点击大奖展厅完成")
         if second>0 :
             util.take_screenShot(MyHelper.driver,case_name,second)
         else:
             util.take_screenShot(MyHelper.driver,case_name,0)
     
         pass
     except Exception as e:
         print("发现异常")
         print(e)
         raise SystemError
Пример #4
0
 def to_hot_page(self, case_name, second=0):
     try:
         hot_anchor_page = HotAnchorPage()
         util = Utils()
         util.getElementById(HotAnchorHelper.driver,
                             hot_anchor_page.resid_home_button).click()
         if second > 0:
             #util.take_screenShot(LoginHelper.driver, case_name, second)
             util.getImage(HotAnchorHelper.driver, case_name, second)
         else:
             #util.take_screenShot(LoginHelper.driver, case_name, 0)
             util.getImage(HotAnchorHelper.driver, case_name, 0)
         print("本次测试完成")
     except Exception as e:
         print("发现异常")
         print(e)
         raise SystemError
Пример #5
0
 def to_anchor_room(self, case_name, anchor_index, second=0):
     try:
         hot_anchor_page = HotAnchorPage()
         util = Utils()
         util.get_element_by_index(HotAnchorHelper.driver,
                                   hot_anchor_page.resid_anchor,
                                   anchor_index).click()
         if second > 0:
             #util.take_screenShot(LoginHelper.driver, case_name, second)
             util.getImage(HotAnchorHelper.driver, case_name, second)
         else:
             #util.take_screenShot(LoginHelper.driver, case_name, 0)
             util.getImage(HotAnchorHelper.driver, case_name, 0)
         print("本次测试完成")
     except Exception as e:
         print("发现异常")
         print(e)
         raise SystemError
Пример #6
0
 def recharge_wechat_input(self,amount,case_name,second):    #输入金额进行充值
     try:
         time.sleep(second)
         Utils.getElementById(self,MyHelper.driver,MyPage.resid_my_button).click()
         
         if second>0 :
             Utils.getImage(self,MyHelper.driver, case_name, second)
         else:
             Utils.getImage(self,MyHelper.driver, case_name, 1)
     except Exception as e:
         print("发现异常")
         print(e)
         raise SystemError
Пример #7
0
 def exit(
     self,
     stat=0,
     case_name="",
     second=0
 ):  #退出登录  param:stat-是否确认退出,1是确定0是取消,case_name--用例名称,second-截图等待秒数
     try:
         Utils.getElementById(self, MyInfoHelper.driver,
                              MyInfoPage.resid_my_button).click()
         Utils.getElementById(self, MyInfoHelper.driver,
                              MyInfoPage.resid_myinfo_button).click()
         Utils.getElementById(self, MyInfoHelper.driver,
                              MyInfoPage.resid_myinfo_exit_button).click()
         if (stat > 0):
             Utils.tap(self, MyInfoHelper.driver,
                       MyInfoPage.resposition_confirm_x1,
                       MyInfoPage.resposition_confirm_y1,
                       MyInfoPage.resposition_confirm_x2,
                       MyInfoPage.resposition_confirm_y2)
             time.sleep(1)
             Utils.getImage(self, MyInfoHelper.driver, case_name, 1)
             Utils.getElementById(self, MyInfoHelper.driver,
                                  LoginPage.password).click()
             Utils.getElementById(self, MyInfoHelper.driver,
                                  LoginPage.password).send_keys("111111")
             Utils.getElementById(self, MyInfoHelper.driver,
                                  LoginPage.loginButton).click()
             time.sleep(4)
         else:
             Utils.tap(self, MyInfoHelper.driver,
                       MyInfoPage.resposition_cancel_x1,
                       MyInfoPage.resposition_cancel_y1,
                       MyInfoPage.resposition_cancel_x2,
                       MyInfoPage.resposition_cancel_y2)
             Utils.getImage(self, MyInfoHelper.driver, case_name, 1)
             Utils.tap(self, MyInfoHelper.driver, 28, 72, 56,
                       110)  #此处返回使用绝对坐标来点击,使用id会有获取不到元素异常
     except Exception as e:
         print("发现异常")
         print(e)
         raise SystemError
     time.sleep(1)
Пример #8
0
 def get_code_by_mobile(
         self,
         mobile="",
         case_name="",
         second=0):  #实名认证   param:mobile-手机号,case_name-用例名称,second-截图等待秒数
     try:
         my_info_page = MyInfoPage()
         util = Utils()
         util.getElementById(MyInfoHelper.driver,
                             my_info_page.resid_my_button).click()
         util.getElementById(MyInfoHelper.driver,
                             my_info_page.resid_myinfo_button).click()
         util.getElementById(MyInfoHelper.driver,
                             my_info_page.resid_myinfo_updatepwd).click()
         util.getElementById(MyInfoHelper.driver,
                             my_info_page.resid_updatepwd_mobile).click()
         util.getElementById(
             MyInfoHelper.driver,
             my_info_page.resid_updatepwd_mobile).send_keys(mobile)
         util.getElementById(
             MyInfoHelper.driver,
             my_info_page.resid_updatepwd_get_code_button).click()
         if (second > 1):
             util.getImage(MyInfoHelper.driver, case_name, second)
         else:
             util.getImage(MyInfoHelper.driver, case_name, 1)
         util.tap(MyInfoHelper.driver, 28, 72, 56,
                  110)  #此处返回使用绝对坐标来点击,使用id会有获取不到元素异常
         time.sleep(1)
         util.tap(MyInfoHelper.driver, 28, 72, 56, 110)
     except Exception as e:
         print("发现异常")
         print(e)
         raise SystemError
Пример #9
0
 def to_my_info(self, case_name,
                second):  #去我的个人信息页面   param:case_name-用例名称,second-截图等待秒数
     try:
         my_info_page = MyInfoPage()
         util = Utils()
         util.getElementById(MyInfoHelper.driver,
                             my_info_page.resid_my_button).click()
         util.getElementById(MyInfoHelper.driver,
                             my_info_page.resid_myinfo_button).click()
         if (second > 1):
             util.getImage(MyInfoHelper.driver, case_name, second)
         else:
             util.getImage(MyInfoHelper.driver, case_name, 1)
         util.getElementById(MyInfoHelper.driver,
                             my_info_page.resid_back_button).click()
     except Exception as e:
         print("发现异常")
         print(e)
         raise SystemError
Пример #10
0
    def identity_relname(
        self,
        relname="",
        relcard="",
        case_name="",
        second=0
    ):  #实名认证   param:relname-真实姓名,relcard-身份证号,case_name-用例名称,second-截图等待秒数
        try:

            my_info_page = MyInfoPage()
            util = Utils()
            util.getElementById(MyInfoHelper.driver,
                                my_info_page.resid_my_button).click()
            util.getElementById(MyInfoHelper.driver,
                                my_info_page.resid_myinfo_button).click()
            util.getElementById(MyInfoHelper.driver,
                                my_info_page.resid_myinfo_identity).click()
            if (relname == "" and relcard == ""):
                pass
            else:
                util.getElementById(
                    MyInfoHelper.driver,
                    my_info_page.resid_identity_relname).click()
                util.getElementById(
                    MyInfoHelper.driver,
                    my_info_page.resid_identity_relname).clear()
                util.getElementById(
                    MyInfoHelper.driver,
                    my_info_page.resid_identity_relname).send_keys(relname)
                if (relcard == ""):
                    pass
                else:
                    util.getElementById(
                        MyInfoHelper.driver,
                        my_info_page.resid_identity_relcard).click()
                    util.getElementById(
                        MyInfoHelper.driver,
                        my_info_page.resid_identity_relcard).clear()
                    util.getElementById(
                        MyInfoHelper.driver,
                        my_info_page.resid_identity_relcard).send_keys(relcard)
            util.getElementById(
                MyInfoHelper.driver,
                my_info_page.resid_identity_commit_button).click()
            if (second > 1):
                util.getImage(MyInfoHelper.driver, case_name, second)
            else:
                util.getImage(MyInfoHelper.driver, case_name, 0)
            util.tap(MyInfoHelper.driver, 28, 72, 56,
                     110)  #此处返回使用绝对坐标来点击,使用id会有获取不到元素异常
            time.sleep(1)
            util.tap(MyInfoHelper.driver, 28, 72, 56, 110)
        except Exception as e:
            print("发现异常")
            print(e)
            raise SystemError
Пример #11
0
    def recharge_wechat_click_first(self, amount, case_name,
                                    second):  #点击金额进行充值
        try:
            time.sleep(second)
            Utils.getElementById(self, MyHelper.driver,
                                 MyPage.resid_my_button).click()
            Utils.getElementById(self, MyHelper.driver,
                                 MyPage.resid_recharge).click()
            if (amount == 10):
                Utils.getElementById(
                    self, MyHelper.driver,
                    FinancialOperationPage.resid_recharge_ten).click()

            elif (amount == 20):
                Utils.getElementById(
                    self, MyHelper.driver,
                    FinancialOperationPage.resid_recharge_twenty).click()

            elif (amount == 50):
                Utils.getElementById(
                    self, MyHelper.driver,
                    FinancialOperationPage.resid_recharge_fifty).click()
            elif (amount == 100):
                Utils.getElementById(
                    self, MyHelper.driver,
                    FinancialOperationPage.resid_recharge_oneHundred).click()
            elif (amount == 150):
                Utils.getElementById(
                    self, MyHelper.driver, FinancialOperationPage.
                    resid_recharge_oneHundredAndFifty).click()
            elif (amount == 200):
                Utils.getElementById(
                    self, MyHelper.driver,
                    FinancialOperationPage.resid_recharge_twoHundred).click()
            elif (amount == 300):
                Utils.getElementById(
                    self, MyHelper.driver,
                    FinancialOperationPage.resid_recharge_threeHundred).click(
                    )
            elif (amount == 500):
                Utils.getElementById(
                    self, MyHelper.driver,
                    FinancialOperationPage.resid_recharge_fiveHundred).click()
            else:
                print("请输入要点击选择的正确金额")
                raise SystemError
            Utils.getElementById(
                self, MyHelper.driver,
                FinancialOperationPage.resid_recharge_wechatpay).click()
            Utils.getElementById(
                self, MyHelper.driver,
                FinancialOperationPage.resid_recharge_commit).click()
            Utils.tap(
                self, MyHelper.driver, FinancialOperationPage.
                resposition_recharge_instruction_agree_x1,
                FinancialOperationPage.
                resposition_recharge_instruction_agree_y1,
                FinancialOperationPage.
                resposition_recharge_instruction_agree_x2,
                FinancialOperationPage.
                resposition_recharge_instruction_agree_y2)
            if second > 0:
                Utils.getImage(self, MyHelper.driver, case_name, second)
            else:
                Utils.getImage(self, MyHelper.driver, case_name, 1)
            Utils.getElementById(
                self, MyHelper.driver,
                FinancialOperationPage.resid_recharge_wechat_back).click()
            Utils.getElementById(
                self, MyHelper.driver,
                FinancialOperationPage.resid_back_button).click()
        except Exception as e:
            print("发现异常")
            print(e)
            raise SystemError
Пример #12
0
 def clear_cache_really(self, case_name, second):  #清理缓存点确定
     try:
         time.sleep(second)
         my_page = MyPage()
         util = Utils()
         util.getElementById(MyHelper.driver, my_page.resid_my_button)
         #点击清理缓存,会弹出确认框
         util.getElementById(MyHelper.driver,
                             my_page.resid_clear_cache).click()
         #由于uiauto定位不到确认框元素,此处采用绝对定位
         #取消  128  680,245-744
         #确定  449  695,600 746
         #点击取消
         util.tap(MyHelper.driver, 449, 695, 600, 746)
         if second > 0:
             util.take_screenShot(MyHelper.driver, case_name, second)
         else:
             util.take_screenShot(MyHelper.driver, case_name, 0)
     except Exception as e:
         print("发现异常")
         print(e)
         raise SystemError
Пример #13
0
sys.path.append('/Users/Administrator/Desktop/py/TestPython1/com/caibo/case')
sys.path.append('/Users/Administrator/Desktop/py/TestPython1/com/caibo/api')
from com.caibo.api.Utils import Utils
from com.caibo.api.HTMLTestRunner import HTMLTestRunner

#sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding='utf-8')
#sys.stderr = io.TextIOWrapper(sys.stderr.detach(), encoding='utf-8')

case_path = os.getcwd()
now_time = datetime.datetime.now().strftime('%Y_%m_%d')  #当前日期,每天的报告放在每天的文件夹下
a = 'hello word'
b = a.replace('word', 'python')
temp_report_path = os.getcwd()
temp2_report_path = temp_report_path.replace('case', '')
report_path = "/Users/Administrator/Desktop/py/TestPython1/com/caibo/report/" + now_time  # 存放报告路径
utils = Utils()
utils.mkdir(report_path)  #创建测试报告目录
utils.mkdir(
    "/Users/Administrator/Desktop/py/TestPython1/com/caibo/screenShots/" +
    now_time)  #创建截图目录


def creat_suite():
    uit = unittest.TestSuite()

    # 获取所有以test开头.py结尾的测试用例文件
    #discover = unittest.defaultTestLoader.discover(case_path, pattern="Test_*.py", top_level_dir=None)
    discover = unittest.defaultTestLoader.discover(
        r'/Users/Administrator/Desktop/py/TestPython1/com/caibo/case',
        pattern="Test_*.py",
        top_level_dir=None)
Пример #14
0
    def login(self, mobile, pwd, case_name, second, driver_stat):
        try:

            if driver_stat == 1:
                print("driver_stat=1,初始化driver")
                LoginHelper.driver = BaseHelper.get_redmi_driver(
                    self)  # 创建driver
            else:

                pass
            loginPage = LoginPage()
            util = Utils()
            if mobile == "":
                util.getElementById(LoginHelper.driver,
                                    loginPage.mobile).click()
                util.getElementById(LoginHelper.driver,
                                    loginPage.mobile).clear()
            else:
                util.getElementById(LoginHelper.driver,
                                    loginPage.mobile).click()
                util.getElementById(LoginHelper.driver,
                                    loginPage.mobile).clear()
                util.getElementById(LoginHelper.driver,
                                    loginPage.mobile).send_keys(mobile)
            if pwd == "":
                util.getElementById(LoginHelper.driver,
                                    loginPage.password).click()
                util.getElementById(LoginHelper.driver,
                                    loginPage.password).clear()
            else:
                util.getElementById(LoginHelper.driver,
                                    loginPage.password).click()
                util.getElementById(LoginHelper.driver,
                                    loginPage.password).clear()
                util.getElementById(LoginHelper.driver,
                                    loginPage.password).send_keys(pwd)
            util.getElementById(LoginHelper.driver, loginPage.seepwd).click()
            # util.clearText(loginPage.password, driver);
            # util.clearText(driver, loginPage.password);
            LoginHelper.driver.hide_keyboard()
            util.getElementById(LoginHelper.driver,
                                loginPage.loginButton).click()
            if second > 0:
                #util.take_screenShot(LoginHelper.driver, case_name, second)
                util.getImage(LoginHelper.driver, case_name, second)
            else:
                #util.take_screenShot(LoginHelper.driver, case_name, 0)
                util.getImage(LoginHelper.driver, case_name, 0)
            print("本次测试完成")

        except Exception as e:
            print("发现异常")
            print(e)
            raise SystemError
Пример #15
0
sys.path.append(
    '/Users/lipengjie/eclipse-workspace/TestPython1/src/com/caibo/api')
from com.caibo.api.Utils import Utils
from com.caibo.api.HTMLTestRunner import HTMLTestRunner

#sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding='utf-8')
#sys.stderr = io.TextIOWrapper(sys.stderr.detach(), encoding='utf-8')

case_path = os.getcwd()
now_time = datetime.datetime.now().strftime('%Y_%m_%d')  #当前日期,每天的报告放在每天的文件夹下
a = 'hello word'
b = a.replace('word', 'python')
temp_report_path = os.getcwd()
temp2_report_path = temp_report_path.replace('case', '')
report_path = "/Users/lipengjie/eclipse-workspace/TestPython1/src/com/caibo/report/" + now_time  # 存放报告路径
utils = Utils()
utils.mkdir(report_path)  #创建测试报告目录
utils.mkdir(
    "/Users/lipengjie/eclipse-workspace/TestPython1/src/com/caibo/screenShots/"
    + now_time)  #创建截图目录


def creat_suite():
    uit = unittest.TestSuite()

    # 获取所有以test开头.py结尾的测试用例文件
    #discover = unittest.defaultTestLoader.discover(case_path, pattern="Test_*.py", top_level_dir=None)
    discover = unittest.defaultTestLoader.discover(
        '/Users/lipengjie/eclipse-workspace/TestPython1/src/com/caibo/case',
        pattern="Test_*.py",
        top_level_dir=None)
Пример #16
0
    def edit_nickname_error(
            self,
            nick_name="",
            case_name="",
            second=0):  #修改昵称   param:case_name-用例名称,second-截图等待秒数
        try:
            my_info_page = MyInfoPage()
            util = Utils()
            util.getElementById(MyInfoHelper.driver,
                                my_info_page.resid_my_button).click()
            util.getElementById(MyInfoHelper.driver,
                                my_info_page.resid_myinfo_button).click()
            util.getElementById(MyInfoHelper.driver,
                                my_info_page.resid_myinfo_nickname).click()
            util.getElementById(MyInfoHelper.driver,
                                my_info_page.resid_nickname_input).click()
            if (nick_name == ""):
                util.getElementById(
                    MyInfoHelper.driver,
                    my_info_page.resid_savename_button).click()
            else:
                util.getElementById(MyInfoHelper.driver,
                                    my_info_page.resid_nickname_input).clear()
                util.getElementById(
                    MyInfoHelper.driver,
                    my_info_page.resid_nickname_input).send_keys(nick_name)
                util.getElementById(
                    MyInfoHelper.driver,
                    my_info_page.resid_savename_button).click()
                time.sleep(1)
                util.getElementById(MyInfoHelper.driver,
                                    my_info_page.resid_mes_button).click()
                time.sleep(1)
            if (second > 1):
                util.getImage(MyInfoHelper.driver, case_name, second)
            else:
                util.getImage(MyInfoHelper.driver, case_name, 0)

            util.tap(MyInfoHelper.driver, 28, 72, 56,
                     110)  #此处返回使用绝对坐标来点击,使用id会有获取不到元素异常
            time.sleep(1)
            util.tap(MyInfoHelper.driver, 28, 72, 56, 110)
            #util.getElementById(MyInfoHelper.driver,my_info_page.resid_back_button).click()
            #MyInfoHelper.driver.find_element_by_xpath("//*[@resource-id='com.dbljoy.lottery:id/img_goback']").click()
            time.sleep(1)
            #util.getElementById(MyInfoHelper.driver,my_info_page.resid_back_button).click()
            #MyInfoHelper.driver.find_element_by_xpath("//*[@resource-id='com.dbljoy.lottery:id/img_goback']").click()
        except Exception as e:
            print("发现异常")
            print(e)
            raise SystemError
Пример #17
0
 def edit_nickname_right(
         self,
         nick_name="",
         case_name="",
         second=0):  #修改昵称   param:case_name-用例名称,second-截图等待秒数
     try:
         my_info_page = MyInfoPage()
         util = Utils()
         util.getElementById(MyInfoHelper.driver,
                             my_info_page.resid_my_button).click()
         util.getElementById(MyInfoHelper.driver,
                             my_info_page.resid_myinfo_button).click()
         util.getElementById(MyInfoHelper.driver,
                             my_info_page.resid_myinfo_nickname).click()
         util.getElementById(MyInfoHelper.driver,
                             my_info_page.resid_nickname_input).click()
         util.getElementById(MyInfoHelper.driver,
                             my_info_page.resid_nickname_input).clear()
         util.getElementById(
             MyInfoHelper.driver,
             my_info_page.resid_nickname_input).send_keys(nick_name)
         util.getElementById(MyInfoHelper.driver,
                             my_info_page.resid_savename_button).click()
         if (second > 1):
             util.getImage(MyInfoHelper.driver, case_name, second)
         else:
             util.getImage(MyInfoHelper.driver, case_name, 1)
         util.getElementById(MyInfoHelper.driver,
                             my_info_page.resid_back_button).click()
         time.sleep(1)
     except Exception as e:
         print("发现异常")
         print(e)
         raise SystemError
Пример #18
0
 def test_myinfo_f(self):
     case_name = "修改为正确格式昵称-"
     Log.print_case_info_My(self, case_name)
     MyInfoHelper.edit_nickname_right(self, Utils.creat_username(self),
                                      case_name, 0)  #使用随机数生成昵称避免重复(9位)
     print("本条用例执行通过")