Ejemplo n.º 1
0
 def __init__(self,outdevice=None):
     if outdevice==None:
         # self.d = u2.connect('192.168.199.168')
         self.d = u2.connect_usb('810EBM32TZ4K')
     else:
         self.d = u2.connect_usb(outdevice)
     self.timeStr = GetTimeStr()  # 实例化
Ejemplo n.º 2
0
 def printLog(self):
     stdout_backup = sys.stdout
     gettime = GetTimeStr()
     timestr = gettime.getTimeStr()
     # define the log file that receives your log info
     log_file = open("%s_message.log" % timestr, "w")
     # redirect print output to log file
     sys.stdout = log_file
     print("Now all print info will be written to message.log")
     # any command line that you will execute
     #执行的内容
     log_file.close()
     # restore the output to initial pattern
     sys.stdout = stdout_backup
     print("Now this will be presented on screen")
Ejemplo n.º 3
0
    def printLog(self, fun):
        print('---------------------------')
        stdout_backup = sys.stdout
        gettime = GetTimeStr()
        timestr = gettime.getTimeStr()
        # define the log file that receives your log info
        logpath = "../log/%s_message.txt" % timestr
        log_file = open(logpath, "w", encoding="utf-8")
        print("Now all print info will be written to message.log")
        # redirect print output to log file
        sys.stdout = log_file

        print('----------开始打印日志-----------------\n')

        # any command line that you will execute
        fun
        print('\n----------日志打印结束-----------------')
        log_file.close()
        # restore the output to initial pattern
        sys.stdout = stdout_backup
        print("Now this will be presented on screen")
        # 发送log至邮箱
        send_e = SendEmail()
        send_e.send_main([1], [2], logpath)
Ejemplo n.º 4
0
                    fail_count.append(i + 1)  # 失败的加到集合里
                assertresult = [0, 0]
                i = i + 1
        self.addmerchantfun.activeweb.printgreenword()
        print("添加成功的行数:", pass_count)
        self.addmerchantfun.activeweb.printredword()
        print("添加失败的行数:", fail_count)
        self.addmerchantfun.activeweb.printnormalword()
        self.send_mai.send_main(pass_count, fail_count)  # 调用发送邮件


if __name__ == '__main__':
    run = RunTest()  #实例化
    print('---------------------------')
    stdout_backup = sys.stdout
    gettime = GetTimeStr()
    timestr = gettime.getTimeStr()
    logpath = "../log/%s_message.txt" % timestr
    print("Now all print info will be written to log文件:", logpath)
    # define the log file that receives your log info
    log_file = open(logpath, "w", encoding="utf-8")
    # redirect print output to log file
    sys.stdout = log_file
    print('----------开始打印日志-----------------\n')
    run.go_on_run()
    print('\n----------日志打印结束-----------------')
    log_file.close()
    # restore the output to initial pattern
    sys.stdout = stdout_backup
    print("Now this will be presented on screen")
Ejemplo n.º 5
0
 def __init__(self):
     # self.driver = self.getChromeDriver()
     # self.driver = self.getIeDriver()
     self.driver = self.getFirefoxDriver()
     self.timeStr = GetTimeStr()   #实例化
Ejemplo n.º 6
0
    def define_tips(self,
                    outtipooptionsid=None,
                    outoptiontext=None,
                    outfixedfeeinputid=None,
                    outfixedfeeinputtext=None,
                    outfixedfeeconfirmid=None,
                    outpercentagefeeinputid=None,
                    outpercentagefeeinputtext=None,
                    outpercentagefeeconfirmid=None,
                    outpretext=None,
                    outbeisaoid=None,
                    outzhusaoid=None,
                    outmoneyinputid=None,
                    outmoneyinputtext=None,
                    outpretoastmessage=None):
        if outtipooptionsid == None:
            tipooptionsid = 'com.ahdi.qrindo.merchant:id/tv_tips_show'
        else:
            tipooptionsid = outtipooptionsid

        if outoptiontext == None:
            optiontext = 'No Tips'
        else:
            optiontext = outoptiontext

        if outfixedfeeinputid == None:
            fixedfeeinputid = 'com.ahdi.qrindo.merchant:id/edt_pwd'
        else:
            fixedfeeinputid = outfixedfeeinputid

        if outfixedfeeinputtext == None:
            fixedfeeinputtext = '1000'
        else:
            fixedfeeinputtext = outfixedfeeinputtext

        if outfixedfeeconfirmid == None:
            fixedfeeconfirmid = 'com.ahdi.qrindo.merchant:id/btn_confirm'
        else:
            fixedfeeconfirmid = outfixedfeeconfirmid

        if outpercentagefeeinputid == None:
            percentagefeeinputid = 'com.ahdi.qrindo.merchant:id/edt_pwd'
        else:
            percentagefeeinputid = outpercentagefeeinputid

        if outpercentagefeeinputtext == None:
            percentagefeeinputtext = '100'
        else:
            percentagefeeinputtext = outpercentagefeeinputtext

        if outpercentagefeeconfirmid == None:
            percentagefeeconfirmid = 'com.ahdi.qrindo.merchant:id/btn_confirm'
        else:
            percentagefeeconfirmid = outpercentagefeeconfirmid

        if outpretext == None:
            pretext = 'No Tips'
        else:
            pretext = outpretext

        if outbeisaoid == None:
            beisaoid = 'com.ahdi.qrindo.merchant:id/iv_cashier_show_qr'
        else:
            beisaoid = outbeisaoid

        if outzhusaoid == None:
            zhusaoid = 'com.ahdi.qrindo.merchant:id/iv_cashier_scan_qr'
        else:
            zhusaoid = outzhusaoid

        if outmoneyinputid == None:
            moneyinputid = 'com.ahdi.qrindo.merchant:id/edt_pay_num'
        else:
            moneyinputid = outmoneyinputid

        if outmoneyinputtext == None:
            moneyinputtext = None
        else:
            moneyinputtext = outmoneyinputtext

        if optiontext == 'com.ahdi.qrindo.merchant:id/btn_back':
            cancelid = optiontext
            cancelpretext = self.baseframe.findbyresourceId_and_return_text(
                tipooptionsid)  # 查看小费选项显示内容
            self.baseframe.findbyresourceId_and_click(tipooptionsid)  # 点击小费选项
            self.baseframe.findbyresourceId_and_click(
                cancelid
            )  # # 选择小费选项_No Tips、Consumer Input、Fixed Fee、Percentage Fee、Cancel
            resulttext = self.baseframe.findbyresourceId_and_return_text(
                tipooptionsid)  # 查看小费选项显示内容
            self.assertEqual(cancelpretext, resulttext)
        else:
            self.baseframe.findbyresourceId_and_click(tipooptionsid)  #点击小费选项
            self.baseframe.findbytext_and_click(
                optiontext
            )  # # 选择小费选项_No Tips、Consumer Input、Fixed Fee、Percentage Fee、Cancel

            if optiontext == 'Fixed Fee':
                self.baseframe.findbyresourceId_and_input(
                    fixedfeeinputid, fixedfeeinputtext)  # 输入固定金额费用
                self.baseframe.findbyresourceId_and_click(
                    fixedfeeconfirmid)  # 点击确认按钮
            if optiontext == 'Percentage Fee':
                self.baseframe.findbyresourceId_and_input(
                    percentagefeeinputid, percentagefeeinputtext)  # 输入百分比金额费用
                self.baseframe.findbyresourceId_and_click(
                    percentagefeeconfirmid)  # 点击确认按钮

            resulttext = self.baseframe.findbyresourceId_and_return_text(
                tipooptionsid)  # 查看小费选项显示内容
            self.assertEqual(pretext, resulttext)
            zhusaoenablestatus = self.baseframe.findbyresourceId_and_return_enabledstatus(
                beisaoid)  # 查看被扫可用状态
            self.assertTrue(zhusaoenablestatus)
            beisaoenablestatus = self.baseframe.findbyresourceId_and_return_enabledstatus(
                zhusaoid)  # 查看主扫可用状态
            if optiontext == 'No Tips':
                self.assertTrue(beisaoenablestatus)
            else:
                self.assertFalse(beisaoenablestatus)

        self.baseframe.findbyresourceId_and_input(moneyinputid,
                                                  moneyinputtext)  #输入金额
        toastmessage = self.baseframe.findbyresourceId_and_click(
            beisaoid, outpretoastmessage)  #不输入金额,点击被扫,查看toast提示
        if toastmessage != None:
            self.assertEqual(outpretoastmessage, toastmessage)
        else:
            self.baseframe.delaytime(5)
            self.baseframe.findbytext("Scan to pay me")
            gett = GetTimeStr()  #实例化

            totalamount = self.baseframe.findbyresourceId_and_return_text(
                'com.ahdi.qrindo.merchant:id/tv_fee_total')
            totalamountstr = gett.getsplitstr(totalamount)
            print("totalamountstr:", totalamountstr)

            payamount = self.baseframe.findbyresourceId_and_return_text(
                'com.ahdi.qrindo.merchant:id/tv_Amount')
            payamountstr = gett.getsplitstr(payamount)
            print("payamountstr:", payamountstr)

            tipsamount = self.baseframe.findbyresourceId_and_return_text(
                'com.ahdi.qrindo.merchant:id/tv_tips_fee')
            tipsamountstr = gett.getsplitstr(tipsamount)
            print("tipsamountstr:", tipsamountstr)

            totalamountint = int(totalamountstr)
            pretotalamountint = int(payamountstr) + int(tipsamountstr)
            print("totalamountint:", totalamountint)
            print("pretotalamountint:", pretotalamountint)

            self.assertEqual(pretotalamountint, totalamountint)
            self.baseframe.findbyresourceId_and_click(
                "com.ahdi.qrindo.merchant:id/btn_back")