1、項(xiàng)目架構(gòu)解析
2.1碴巾、用例? ?test0001_installAndStart_new.py
1)截圖
2)文本
#coding=utf-8
from AW.aw_install import Init
'''
@author: shipanpan
@attention: install and start? (sleep/while/click/if/check)
'''
#安裝并確認(rèn)權(quán)限
Init.confirmPower()
#判斷當(dāng)前是否為首頁
Init.checkContent()? ?
2.2、 AW封裝:aw_install.py
1)截圖
2)文本
# ecoding=utf-8
__author__ = "shipanpan"
# 導(dǎo)入appium
from appium import webdriver
from time import sleep
import os
import Const.const_init
class Init:
? ? global driver
? ? #封裝driver:初始化手機(jī)
? ? print('提示-----> 配置 server 啟動參數(shù)')
? ? desired_caps = {}
? ? desired_caps['platformName'] = Const.const_init.PLATFORM_NAME
? ? desired_caps['platformVersion'] = Const.const_init.PLATFORM_VERSION
? ? desired_caps['deviceName'] = Const.const_init.DEVICE_NAME
? ? desired_caps['appPackage'] = Const.const_init.APP_PACKAGE
? ? desired_caps['app'] = os.path.abspath(Const.const_init.APK_PATH)
? ? desired_caps['appActivity'] = Const.const_init.APP_ACTIVITY
? ? driver = webdriver.Remote(Const.const_init.COMMAND_EXECUTOR_URL, desired_caps)
? ? print('提示-----> 休眠6秒')
? ? sleep(6)
? ? #擊app獲取手機(jī)權(quán)限確認(rèn)彈框
? ? def confirmPower():
? ? ? ? print('提示-----> 點(diǎn)擊app獲取手機(jī)權(quán)限確認(rèn)彈框')
? ? ? ? Content = 1
? ? ? ? while Content<7:
? ? ? ? ? ? driver.find_element_by_id('com.android.packageinstaller:id/permission_allow_button').click()
? ? ? ? ? ? Content += 1
? ? ? ? else:
? ? ? ? ? ? print('提示-----> 確認(rèn)完畢员寇,預(yù)計(jì)進(jìn)入首頁')
? ? #判斷當(dāng)前是否為首頁
? ? def checkContent():? ? ? ?
? ? ? ? print('提示-----> 判斷當(dāng)前是否為首頁')
? ? ? ? if driver.find_element_by_id('com.iflytek.smartsq:id/home_menu_home_txt').text == '首頁':
? ? ? ? ? ? print('提示-----> 判斷結(jié)果:當(dāng)前為首頁')
? ? ? ? else:
? ? ? ? ? ? print('提示-----> 判斷結(jié)果:當(dāng)前非首頁')
? ? #關(guān)閉驅(qū)動? ?
? ? def quit():
? ? ? ? print('提示-----> 關(guān)閉驅(qū)動')
? ? ? ? driver.quit()
2.3、 Const常量:const_init.py
1)截圖
2)文本
# ecoding=utf-8
__author__ = "shipanpan"
#初始化手機(jī):public
PLATFORM_NAME = 'Android'
PLATFORM_VERSION = '7.0'
DEVICE_NAME = '4e6f9690'
APP_PACKAGE = 'com.iflytek.smartsq'
COMMAND_EXECUTOR_URL = 'http://localhost:4723/wd/hub'
#初始化手機(jī):install 安裝的附加?
APK_PATH = 'D:\\apk\\shangqiubmw.apk'
APP_ACTIVITY = 'com.iflytek.cip.activity.WelcomeActivity'
'''默認(rèn)的屬性如下'''
#'autoLaunch':'false'? #appium是否要自動啟動或安裝APP塘偎,默認(rèn)為ture
#'newCommandTimeout':'60'? #設(shè)置未接受到新命令的超時(shí)時(shí)間虎韵,默認(rèn)60s易稠,說明:
#? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 如果60s內(nèi)沒有接收到新命令,appium會自動斷開包蓝,如果我需要很長時(shí)間做driver之外的操作驶社,可設(shè)置延長接收新命令的超時(shí)時(shí)間
#'unicodeKeyboard':True,
#'resetKeyboard':True?
#'noReset':'false'? #在會話前是否重置APP狀態(tài),默認(rèn)是false
3养晋、執(zhí)行結(jié)果