def runTest(): logger.info('[' + result.getTestId() + ']start runTest') initAdb() booDChk = util.chkDeviceConn() booPChk = util.chkPing() logger.info('[' + result.getTestId() + ']status : DChk ' + str(booDChk) + ' / PChk ' + str(booPChk)) result.setDeviceStatus(booDChk) result.setPingStatus(booPChk) if booDChk is False or booPChk is False: return # now = datetime.today().strftime("%Y%m%d_%H%M%S") # recFileName = "apptest_"+now+".mp4" # logger.info('start screenrecord no : '+now) # subprocess.call("adb shell mkdir /sdcard/apptest", shell=True) # subprocess.call("adb shell screenrecord /sdcard/apptest"+recFileName, shell=True) removeApps() unittest.TextTestRunner(verbosity=2).run( unittest.TestLoader().loadTestsFromTestCase(membership_test.TableSearchTest)) if (result.getResultCode('m') is 'f'): unittest.TextTestRunner(verbosity=2).run( unittest.TestLoader().loadTestsFromTestCase(membership_test.TableSearchTest)) if (result.getResultCode('m') is 'f'): unittest.TextTestRunner(verbosity=2).run( unittest.TestLoader().loadTestsFromTestCase(membership_test.TableSearchTest)) unittest.TextTestRunner(verbosity=2).run( unittest.TestLoader().loadTestsFromTestCase(familybox_test.TableSearchTest)) if result.getResultCode('f') is 'f': unittest.TextTestRunner(verbosity=2).run( unittest.TestLoader().loadTestsFromTestCase(familybox_test.TableSearchTest)) if result.getResultCode('f') is 'f': unittest.TextTestRunner(verbosity=2).run( unittest.TestLoader().loadTestsFromTestCase(familybox_test.TableSearchTest)) unittest.TextTestRunner(verbosity=2).run(unittest.TestLoader().loadTestsFromTestCase(ydata_test.TableSearchTest)) if result.getResultCode('y') is 'f': unittest.TextTestRunner(verbosity=2).run( unittest.TestLoader().loadTestsFromTestCase(ydata_test.TableSearchTest)) if result.getResultCode('y') is 'f': unittest.TextTestRunner(verbosity=2).run( unittest.TestLoader().loadTestsFromTestCase(ydata_test.TableSearchTest)) # logger.info('save screenrecord no : '+now) # subprocess.call("adb pull /sdcard/apptest/"+recFileName+" D:\work\movie", shell=True) # subprocess.call("adb shell rm /sdcard/apptest/"+recFileName, shell=True) # logger.info('saved screenrecord no : '+now) subprocess.call("adb shell input keyevent 26", shell=True) # 화면끄기 logger.info('[' + result.getTestId() + ']finished runTest')
def test_search_field(self): logger = appLogger.getLogger(__name__) try: result.setResult('f', 'start') driver = self.driver wait = WebDriverWait(driver, 20) result.setResult('f', 'conn') ''' util.clickElementByIdWithCnt(driver, "com.android.packageinstaller:id/permission_allow_button", 3) util.clickElementById(driver, "com.olleh.android.oc2:id/guide_start") util.clickElementByXPath(driver, "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout") ''' util.clickElementById( driver, "com.kt.ollehfamilybox:id/btn_setting_permission_confirm") util.clickElementByIdWithCnt( driver, "com.android.packageinstaller:id/permission_allow_button", 2) util.clickElementById(driver, "com.kt.ollehfamilybox:id/next_button") util.clickElementById(driver, "com.kt.ollehfamilybox:id/next_button") util.clickElementById(driver, "com.kt.ollehfamilybox:id/next_button") util.clickElementById(driver, "com.kt.ollehfamilybox:id/begin_button") time.sleep(2) try: el7 = driver.find_element_by_id( "com.kt.ollehfamilybox:id/bt_notice_dialog_not_visible_one_week" ) el7.click() except NoSuchElementException: print("no notice popup") result.setResult('f', 'boot') util.clickElementByXPath( driver, "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.ScrollView/android.widget.LinearLayout/android.widget.LinearLayout[1]/android.widget.HorizontalScrollView/android.widget.LinearLayout/android.widget.FrameLayout[1]/android.widget.LinearLayout/android.widget.Button[1]" ) util.clickElementByXPath( driver, "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.ScrollView/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.TextView" ) util.clickElementById(driver, "com.kt.ollehfamilybox:id/tab2_button") result.setResult('f', 'login') util.sendKeyElementById( driver, "com.kt.ollehfamilybox:id/et_id_login_input_id", prop.loginId) util.sendKeyElementById( driver, "com.kt.ollehfamilybox:id/et_id_login_input_pw", prop.loginpwd) util.clickElementById(driver, "com.kt.ollehfamilybox:id/bt_id_login") util.clickElementByXPath( driver, "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.LinearLayout[2]/android.widget.ListView/android.widget.LinearLayout[2]" ) util.clickElementByXPath( driver, "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.Button" ) util.clickElementById( driver, "com.kt.ollehfamilybox:id/btn_common_dialog_right") time.sleep(10) util.screenshot("f.png") util.clickElementByXPath( driver, "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.RelativeLayout" ) result.setResult('f', 'logout') util.clickElementById( driver, "com.kt.ollehfamilybox:id/iv_navigation_logout") util.clickElementById( driver, "com.kt.ollehfamilybox:id/btn_common_dialog_right") ''' el1 = driver.find_element_by_id("com.kt.ollehfamilybox:id/btn_setting_permission_confirm") el1.click() el2 = driver.find_element_by_id("com.android.packageinstaller:id/permission_allow_button") el2.click() el2.click() el3 = driver.find_element_by_id("com.kt.ollehfamilybox:id/next_button")p el3.click() el4 = driver.find_element_by_id("com.kt.ollehfamilybox:id/next_button") el4.click() el5 = driver.find_element_by_id("com.kt.ollehfamilybox:id/next_button") el5.click() el6 = driver.find_element_by_id("com.kt.ollehfamilybox:id/begin_button") el6.click() result.setResult('f', 'boot') el7 = driver.find_element_by_xpath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.ScrollView/android.widget.LinearLayout/android.widget.LinearLayout[1]/android.widget.HorizontalScrollView/android.widget.LinearLayout/android.widget.FrameLayout[1]/android.widget.LinearLayout/android.widget.Button[1]") el7.click() el8 = driver.find_element_by_xpath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.ScrollView/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.TextView") el8.click() el9 = driver.find_element_by_id("com.kt.ollehfamilybox:id/tab2_button") el9.click() result.setResult('f', 'login') el10 = driver.find_element_by_id("com.kt.ollehfamilybox:id/et_id_login_input_id") el10.send_keys(prop.loginId) el11 = driver.find_element_by_id("com.kt.ollehfamilybox:id/et_id_login_input_pw") el11.send_keys(prop.loginpwd) el12 = driver.find_element_by_id("com.kt.ollehfamilybox:id/bt_id_login") el12.click() el12_1 = driver.find_element_by_xpath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.LinearLayout[2]/android.widget.ListView/android.widget.LinearLayout[2]") el12_1.click() #el12_2 = driver.find_element_by_id("com.kt.ollehfamilybox:id/com.kt.ollehfamilybox:id/bt_submit") #el12_2.click() el12_1 = driver.find_element_by_xpath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.Button") el12_1.click() el13 = driver.find_element_by_id("com.kt.ollehfamilybox:id/btn_common_dialog_right") el13.click() el14 = driver.find_element_by_xpath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.RelativeLayout") el14.click() logger.info('send mail4444') result.setResult('f', 'logout') el15 = driver.find_element_by_id("com.kt.ollehfamilybox:id/iv_navigation_logout") el15.click() el16 = driver.find_element_by_id("com.kt.ollehfamilybox:id/btn_common_dialog_right") el16.click() ''' wait = WebDriverWait(driver, 200) result.setResult('f', 'done') time.sleep(3) util.closeRecentApp() except Exception as ex: logger.error('[' + result.getTestId() + ']_s__') logger.exception(ex) logger.error('[' + result.getTestId() + ']_e__')
def makeResult(startTime, endTime): today = datetime.today().strftime("%m/%d") resultTitle = '앱 서비스 점검 결과 보고 (' + today + ')' resultMsg = {} resultMsg['_today_'] = datetime.today().strftime("%Y%m%d") resultMsg['_startTime_'] = startTime resultMsg['_endTime_'] = endTime resultMsg['_mresult_'] = result.getResult('m') resultMsg['_fresult_'] = result.getResult('f') resultMsg['_yresult_'] = result.getResult('y') resultMsg['_mcomment_'] = result.getResultDetail('m') resultMsg['_fcomment_'] = result.getResultDetail('f') resultMsg['_ycomment_'] = result.getResultDetail('y') totalResult = '' if result.getDeviceStatus() is False: totalResult = '단말 연결' elif result.getPingStatus() is False: totalResult = '단말 인터넷 접속' else: if result.getResultCode('m') == 'f': totalResult += 'KT멤버십앱' if result.getResultCode('f') == 'f': if len(totalResult) > 0: totalResult += '/' totalResult += '패밀리박스' if result.getResultCode('y') == 'f': if len(totalResult) > 0: totalResult += '/' totalResult += 'Y데이터박스' if len(totalResult) > 0: totalResult += ' 오류' else: totalResult = '정상' resultMsg['_comment_'] = totalResult detailRowTdHtml = '' detailRowTdHtml = makeDetailRowResult('m', prop.m, detailRowTdHtml) detailRowTdHtml = makeDetailRowResult('f', prop.f, detailRowTdHtml) detailRowTdHtml = makeDetailRowResult('y', prop.y, detailRowTdHtml) resultMsg['_detailRowTdHtml_'] = detailRowTdHtml logger.info('[' + result.getTestId() + ']_m_' + result.getResult('m')) logger.info('[' + result.getTestId() + ']_f_' + result.getResult('f')) logger.info('[' + result.getTestId() + ']_y_' + result.getResult('y')) if result.getDeviceStatus() is True and result.getPingStatus() is True: sendMail(resultTitle, resultMsg) resultStr = '' resultStr += '*점검 결과* (id:' + result.getTestId() + ')\n' anyError = False if (result.getDeviceStatus() is True and result.getPingStatus() is True): mResult = '실패' fResult = '실패' yResult = '실패' errorMsg = '' if result.getResultCode('m') == 's': mResult = '정상' else: anyError = True errorMsg += '`kt멤버십앱` ' if result.getResultCode('f') == 's': fResult = '정상' else: anyError = True errorMsg += '`패밀리박스` ' if result.getResultCode('y') == 's': yResult = '정상' else: anyError = True errorMsg += '`Y데이터박스` ' resultStr += '*kt멤버십앱* `' + mResult + '`\n*패밀리박스* `' + fResult + '`\n*Y데이터박스* `' + yResult + '`' else: anyError = True resultStr += '*단말접속* `' + str(result.getDeviceStatus()) + '`\n*Ping테스트* `' + str(result.getPingStatus()) + '`' errorMsg = '*단말접속* `' + str(result.getDeviceStatus()) + ' `*Ping테스트* `' + str(result.getPingStatus()) + '`' slackMsg.sendSlackMsg(resultStr) if anyError is True: slackMsg.sendSlackMsgError('*점검오류* : ' + errorMsg) if result.getResultCode('m') is 's': slackMsg.sendSlackFile("d:/work/screen/m.png") if result.getResultCode('f') == 's': slackMsg.sendSlackFile("d:/work/screen/f.png") if result.getResultCode('y') is 's': slackMsg.sendSlackFile("d:/work/screen/y.png") writeResultFile(resultStr)
def sendMail(title, msg): logger.info('[' + result.getTestId() + ']send mail') mail.sendMail(title, msg) logger.info('[' + result.getTestId() + ']sent mail')
unittest.TestLoader().loadTestsFromTestCase(ydata_test.TableSearchTest)) # logger.info('save screenrecord no : '+now) # subprocess.call("adb pull /sdcard/apptest/"+recFileName+" D:\work\movie", shell=True) # subprocess.call("adb shell rm /sdcard/apptest/"+recFileName, shell=True) # logger.info('saved screenrecord no : '+now) subprocess.call("adb shell input keyevent 26", shell=True) # 화면끄기 logger.info('[' + result.getTestId() + ']finished runTest') if __name__ == '__main__': result.init() logger = appLogger.getLogger(__name__) result.setTestId(datetime.today().strftime("%Y%m%dV%H%M%S")) logger.info('_s_' + result.getTestId() + '_') logger.info('[' + result.getTestId() + ']___________________________start app test process') startTime = datetime.today().strftime("%H:%M:%S") logger.info('[' + result.getTestId() + ']start app tester') result.setStep('m', ['setup', 'start', 'conn', 'boot', 'login', 'card', 'logout', 'done']) result.setStep('f', ['setup', 'start', 'conn', 'boot', 'login', 'logout', 'done']) result.setStep('y', ['setup', 'start', 'conn', 'boot', 'login', 'logout', 'done']) slackMsg.sendSlackMsg('`' + datetime.today().strftime("%Y/%m/%d %H:%M:%S") + '` 점검 시작') runTest() slackMsg.sendSlackMsg('`' + datetime.today().strftime("%Y/%m/%d %H:%M:%S") + '` 점검 완료') logger.info('[' + result.getTestId() + ']finished app tester') endTime = datetime.today().strftime("%H:%M:%S")
def test_search_field(self): logger = appLogger.getLogger(__name__) try: result.setResult('m', 'start') driver = self.driver result.setResult('m', 'conn') wait = WebDriverWait(driver, 20) result.setResult('m', 'boot') util.clickElementById(driver, "com.olleh.android.oc2:id/check_all") util.clickElementById( driver, "com.olleh.android.oc2:id/mainPermission_btn") util.clickElementByIdWithCnt( driver, "com.android.packageinstaller:id/permission_allow_button", 3) util.clickElementById(driver, "com.olleh.android.oc2:id/guide_start") util.clickElementByXPath( driver, "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout" ) result.setResult('m', 'login') util.clickElementById(driver, "com.olleh.android.oc2:id/Leftnavi_login") try: el6_1 = driver.find_element_by_id( "com.olleh.android.oc2:id/spl_btn_other_id") el6_1.click() except NoSuchElementException: print("no one touch btn!") util.sendKeyElementById(driver, "com.olleh.android.oc2:id/spl_edit_id", prop.loginId) util.sendKeyElementById(driver, "com.olleh.android.oc2:id/spl_edit_pwd", prop.loginpwd) util.clickElementById(driver, "com.olleh.android.oc2:id/spl_btn_login") util.screenshot("m.png") util.clickElementById(driver, "com.olleh.android.oc2:id/left_rating_img") util.clickElementById(driver, "com.olleh.android.oc2:id/my_back") util.clickElementById(driver, "com.olleh.android.oc2:id/viewcell") result.setResult('m', 'card') util.clickElementById(driver, "com.olleh.android.oc2:id/main_card") util.clickElementById( driver, "com.olleh.android.oc2:id/kpay_card_close_button") result.setResult('m', 'logout') util.clickElementByXPath( driver, "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout" ) util.clickElementByXPath( driver, "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout[1]/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.RelativeLayout[1]/android.widget.LinearLayout/android.widget.LinearLayout[4]/android.widget.ImageView" ) util.clickElementById(driver, "com.olleh.android.oc2:id/set_logout_btn") ''' el1 = driver.find_element_by_id("com.olleh.android.oc2:id/check_all") el1.click() el2 = driver.find_element_by_id("com.olleh.android.oc2:id/mainPermission_btn") el2.click() el3 = driver.find_element_by_id("com.android.packageinstaller:id/permission_allow_button") el3.click() el3.click() el3.click() el4 = driver.find_element_by_id("com.olleh.android.oc2:id/guide_start") el4.click() el5 = driver.find_element_by_xpath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout") el5.click() result.setResult('m', 'login') el6 = driver.find_element_by_id("com.olleh.android.oc2:id/Leftnavi_login") el6.click() try : el6_1 = driver.find_element_by_id("com.olleh.android.oc2:id/spl_btn_other_id") el6_1.click() except NoSuchElementException : print ("no one touch btn!") el7 = driver.find_element_by_id("com.olleh.android.oc2:id/spl_edit_id") el7.send_keys(prop.loginId) el8 = driver.find_element_by_id("com.olleh.android.oc2:id/spl_edit_pwd") el8.send_keys(prop.loginpwd) el9 = driver.find_element_by_id("com.olleh.android.oc2:id/spl_btn_login") el9.click() el10 = driver.find_element_by_id("com.olleh.android.oc2:id/left_rating_img") el10.click() el11 = driver.find_element_by_id("com.olleh.android.oc2:id/my_back") el11.click() el12 = driver.find_element_by_id("com.olleh.android.oc2:id/viewcell") el12.click() result.setResult('m', 'card') el13 = driver.find_element_by_id("com.olleh.android.oc2:id/main_card") el13.click() el14 = driver.find_element_by_id("com.olleh.android.oc2:id/kpay_card_close_button") el14.click() result.setResult('m', 'logout') el15 = driver.find_element_by_xpath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout") el15.click() el16 = driver.find_element_by_xpath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout[1]/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.RelativeLayout[1]/android.widget.LinearLayout/android.widget.LinearLayout[4]/android.widget.ImageView") el16.click() el17 = driver.find_element_by_id("com.olleh.android.oc2:id/set_logout_btn") el17.click() ''' wait = WebDriverWait(driver, 200) result.setResult('m', 'done') time.sleep(3) util.closeRecentApp() except Exception as ex: logger.error('[' + result.getTestId() + ']_s__') logger.exception(ex) logger.error('[' + result.getTestId() + ']_e__')