Python實現(xiàn)Appium錄屏功能示例代碼
更新時間:2023年06月08日 15:00:20 作者:qq_492448446
這篇文章主要介紹了Python實現(xiàn)Appium錄屏功能,本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
Python實現(xiàn)Appium錄屏功能,具體代碼如下所示:
# coding:utf-8 from time import sleep from appium import webdriver from selenium.webdriver.support.ui import WebDriverWait desired_caps = {} # 系統(tǒng) desired_caps['platformName'] = 'Android' #手機版本,在手機中:設(shè)置--關(guān)于手機 #命令行獲取手機的版本號:adb -s da79fc70 shell getprop ro.build.version.release desired_caps['platformVersion'] = '10' # 設(shè)備號 adb devices # desired_caps['deviceName'] = 'emulator-5554' desired_caps['deviceName'] = '9b2157cfaedb' # 包名 命令行獲取包名和啟動名:adb shell "dumpsys window | grep mCurrentFocus" desired_caps['appPackage'] = 'com.android.settings' # 啟動名 desired_caps['appActivity'] = 'com.android.settings.Settings' # desired_caps["resetKeyboard"] = "True"#程序結(jié)束時重置原來的輸入法 # desired_caps["noReset"] = "True"#不初始化手機app信息(類似不清除緩存) # 聲明手機驅(qū)動對象 driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub",desired_caps) driver.start_recording_screen() WebDriverWait(driver,60) driver.hide_keyboard() sleep(3) record = driver.stop_recording_screen() import base64 data= base64.b64decode(record) #轉(zhuǎn)換成base64編碼數(shù)據(jù) with open('sample.mp4', 'wb') as file: file.write(data) # 退出手機驅(qū)動對象 driver.quit()
到此這篇關(guān)于Python實現(xiàn)Appium錄屏功能的文章就介紹到這了,更多相關(guān)Python Appium錄屏內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
python 操作sqlite數(shù)據(jù)庫的方法
sqlite的官網(wǎng) sqlite.org/index.html SQLite 作為一個SQL數(shù)據(jù)庫引擎,是由C語言實現(xiàn)的,又小又快,具有高可靠性且功能齊全。 作為嵌入式數(shù)據(jù)庫,在移動設(shè)備中使用非常廣泛且方便。本文講解如何使用python操作sqlite數(shù)據(jù)庫2021-06-06python服務(wù)器端收發(fā)請求的實現(xiàn)代碼
這篇文章主要介紹了python服務(wù)器端收發(fā)請求的實現(xiàn)代碼,需要的朋友可以參考下2014-09-09python+opencv邊緣提取與各函數(shù)參數(shù)解析
這篇文章主要介紹了python+opencv邊緣提取與各函數(shù)參數(shù)解析,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-03-03Python對中國500強排行榜數(shù)據(jù)進行可視化分析實戰(zhàn)
這篇文章主要介紹了Python對中國500強排行榜數(shù)據(jù)進行可視化分析實戰(zhàn)示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-04-04