NO.2 appium-安裝和卸載


今天是邁開腿得第二步,捋了一遍appium得API,沒有絲毫順序可言,我就根據自己的整理,想到啥寫點啥吧,今天試試安裝和卸載。

好嘞~上菜!!!

 

1.install_app(self, app_path)

Install the application found at `app_path` on the device.
 
:Args:
 - app_path - the local or remote path to the application to install

API大概的意思:通過給予的路勁,安裝app

先看一下,我准備的apk安裝包:

一共准備了三個安裝包,‘test1’是一個低版本的app,‘test2’是一個高版本的app,‘kuaiya411’就是‘快牙’app。那么我准備的‘test1’和‘test2’除了版本號,有啥區別呢?

 

test1:

輸入法會遮擋住‘登錄按鈕’

 

 

test2:

新版的不會遮擋‘登錄按鈕’

我們先裝好低版本‘test1’,然后覆蓋安裝‘test2’。

執行代碼

 

driver.install_app('D:/a/test2.apk')
執行結果:我就慌了~~~裝完之后,沒有改動,還是之前的test1,這是什么鬼~~

於是我手動安裝了test2,然后嘗試用API安裝test1.(理論上來講就是用手動肯定也裝不上test1)

執行代碼

 

driver.install_app('D:/a/test1.apk')
執行結果:跟實際預期一樣,沒變化。

難道是API用錯了?我嘗試裝一個毫不相關的app試試。

 

執行代碼

 

driver.install_app('D:/a/Kuaiya411.apk')
執行結果:這次裝上了。


成功安裝,看來這個命令只能用來安裝,覆蓋這個事貌似做不了,以后再深入探究一下吧。

 

2.is_app_installed(self, bundle_id)

Checks whether the application specified by `bundle_id` is installed on the device. 

:Args:
 - bundle_id - the id of the application to query

API大概意思是:檢查指定的包,是否安裝。返回True/False


這個API使用的時候,需要給他一個包名,那么怎么獲取包名呢?我這有一個最笨的方法,先運行一下app,然后到'設置->應用->正在運行的應用->查看你的app->尋找進程中com.開頭的一段英文',我用快牙給大伙截個圖,大概是這個樣子:

最笨的方法了~

顯然,現在我已經裝了’快牙‘,我們試試API的效果 

執行代碼

 

a = driver.is_app_installed('com.dewmobile.kuaiya')
print(a)
執行結果:True


3.remove_app(self, app_id)
Remove the specified application from the device.
:Args:
 - app_id - the application id to be removed

API大概意思是:卸載

 

沒啥好啰嗦的直接試試就行了,結合一下第二個API,我們看看結果。 

 

執行代碼

 

driver.remove_app('com.dewmobile.kuaiya')
a = driver.is_app_installed('com.dewmobile.kuaiya')
print(a)
執行結果:False




菜齊了~

 

 
        
 
        
 
        

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM