appium常見問題

2022-06-04 04:54:11 字數 2307 閱讀 2098

1、如何處理 android 許可權彈窗

#

處理 android 許可權彈窗

while

true:

for i in range(6):

if'允許'

indriver.page_source:

driver.switch_to.alert.accept()

time.sleep(1)

break

2、如何處理ui自動化中不定時的彈窗,比如公升級提示彈窗、營銷彈窗、許可權彈窗等

可以在指令碼初始化時,啟動乙個執行緒來處理

def

popup(driver):

while

true:

#許可權彈窗if'

允許'indriver.page_source:

driver.switch_to.alert.accept()

#其他彈窗

elements =[

(by.xpath,

'"哈哈"]'),

(by.xpath,

'"去首頁"]'),

(by.xpath,

'//*[@text="暫時離開"]')

]for element in

elements:

try:

driver.find_element(*element).click()

except

(exception) as e:

print(e, end=''

) time.sleep(1)

print('

...checking..popup...')

time.sleep(1)

t = thread(target=popup, args=(driver,))

t.start()

問題: 如何結束子執行緒(是否可以使用子程序呢)

通過程序來解決 

使用queue來進行程序間的通訊, 思路: 指令碼執行完成後, 發生訊息給監聽該佇列的子程序, break掉迴圈

from multiprocessing import

queue

from multiprocessing import

process

q =queue()

defpopup(driver, q):

while

true:

#許可權彈窗if'

允許'indriver.page_source:

driver.switch_to.alert.accept()

#其他彈窗

elements =[

(by.xpath,

'"哈哈"]'),

(by.xpath,

'"去首頁"]'),

(by.xpath,

'//*[@text="暫時離開"]')

]for element in

elements:

try:

driver.find_element(*element).click()

except

(exception) as e:

print(e, end=''

) time.sleep(1)

print('

...checking..popup...')

time.sleep(1)

#獲取到佇列中有值, 則break迴圈

try:

if q.get_nowait() == '

stop

':break

except: pass

if__name__ == '

__main__':

p = process(target=productor, args=(q,))

#等待指令碼執行完成, 往佇列方式訊息

q.put('

stop

')

driver.contexts

# 解決could not proxy. proxy error: could not proxy command to remote server. original error: error: socket hang up

desired_caps['recreatechromedriversessions'] = 'true'

desired_caps['noreset'] = 'true'  # 不清除資料

605 appium操作多台手機常見問題

desired caps 另外再詳細說一下最後一項配置,即 udid be7c2d7f 打個比方 你的電腦上邊了連線了三颱手機,那麼你執行adb devices會出現三颱手機,那麼你的指令碼就必須要指定udid 來說明你要控制具體哪一台手機,如果不指定,也不會同時控制三颱,只會預設控制第一台。udi...

常見問題 朗動常見問題

常見問題一 方向盤變沉 檢查胎壓是否正常,輪胎是否過度磨損。助力幫浦不工作,前輪氣壓低。冬天的話,冷車在冬天助力油比較稠,方向會重一點。檢查轉向助力油。1 應該是是助力系統有問題或則助力潤滑油有問題。2 如果你在駕車時感覺方向盤變緊,汽車偏向一側,需要檢查輪胎,或進行車輪平衡 定位。在這些問題剛剛發...

appium幾個常見環境問題

確保已安裝node.js 二 error command failed c windows system32 cmd.exe s c d android sdk windows tools adb.exe s ak 我們在使用真機去跑自動化的時候是需要先解除安裝這3個apk 實際上我們只解除安裝了前...