日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

Appium环境的安装与配置,Python测试脚本测试

發布時間:2025/3/19 python 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Appium环境的安装与配置,Python测试脚本测试 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Appium自動化測試系列1 - Appium環境的安裝與配置

發表于4個月前(2015-01-27 14:34)?? 閱讀(803)?|?評論(0 0人收藏此文章, 我要收藏 贊0

尋找 會’偷懶’的開發者線下公開課,報名即享受免費體驗云主機

摘要 看了網上很多有關Appium的安裝配置貼,都寫得語焉不詳,不清不楚,正好打算把自動化測試框架從Robotium切換到Appium, 順手記錄一下,給大家參考。轉載請注明出處。 Appium 安裝 配置 測試

?

之前一直使用Robotium做為Android App測試框架的底層基礎,受限于跨進程,以及控件加載的一些限制,很多特殊場景無法覆蓋,決定嘗試久聞的Appium(它也差不多成熟了),順便做個筆記,方便其他有同樣需求的朋友。

先從安裝說起吧,關于Appium的安裝,網上的資料大多語焉不詳,基本上你按照他們寫的步驟,是不可能裝的出一個完整的環境的。所以,為了把步驟 寫得詳細一點,自己從無到有反復試了幾次,確保自己的安裝步驟是完整的。(當然,安裝方法其實有多種,這里只是其中的一種而已。) 這里以Python作為腳本開發語言為例:

1 安裝并配置JDK,1.6或者1.7版均可,建議1.7,Java SDK的安裝很簡單,不詳述了。(裝JDK是因為后面Android SDK要依賴它)

2 安裝Android SDK并配置環境變量(測試中用到Android SDK的一些工具)

? ?1) 安裝Android SDK ?https://developer.android.com/sdk/installing/index.html?pkg=tools

? ?2) 安裝完畢后啟動Android SDK Manger (SDK Manager.exe,在Android SDK的安裝目錄下),安裝需要的Android Packages,比如一些工具,需要的Android版本, EABI(模擬器相關的包)等等

? ?3) 添加環境變量Android_HOME, 值是Android SDK的安裝路徑; 并把Android SDK下的platform-tools路徑和tools路徑添加到環境變量Path (%ANDROID_HOME%\platform-tools; %ANDROID_HOME%\tools;)?

3 安裝Python開發環境并配置環境變量

? ?1) 下載并安裝Python2.7?https://www.python.org/ftp/python/2.7.9/python-2.7.9.msi

? ?2)將Python2.7的安裝路徑(也就是python.exe所在的目錄)添加到環境變量Path

4 安裝Nodejs (Appium使用Node.js作為服務器引擎)

? ?1) 下載并安裝Node.js?http://nodejs.org/dist/v0.10.35/node-v0.10.35-x86.msi

? ?2) 把Node.js的安裝路徑(也就是node.exe文件所在的目錄)添加到環境變量Path

5 安裝Appium。?

? ? 1) 打開CMD窗口,執行 npm install -g appium 命令開始安裝Appium. Appium默認被安裝到C:\Users\Administrator\AppData\Roaming\npm\ 下。?

? ? 2) 把路徑C:\Users\Administrator\AppData\Roaming\npm\ (appium可執行文件所在的目錄)添加到環境變量Path

至此,Appium的環境就算搭建好了。打開CMD窗口,執行 appium 即可運行起來。默認偵端口為4723。運行狀態如下圖:

?

Appium自動化測試系列2- 寫一個Python測試腳本來測試一下YY語音

發表于4個月前(2015-01-27 15:18)?? 閱讀(1332)?|?評論(0 7人收藏此文章, 我要收藏 贊0

尋找 會’偷懶’的開發者線下公開課,報名即享受免費體驗云主機

摘要 以YY語音為被測對象,寫一個最簡單的Python腳本來測試它,熟悉Appium的測試過程。 Appium Python 測試 腳本 實踐

?

我們在《Appium自動化測試系列1-Appium環境的安裝和配置》里已經搭好了Appium的基本環境,這一章,我們就來真刀真槍使用一下Appium, 看看Appium是如果來實現自動化測試的。在寫測試腳本之前,我們先安裝幾個必要的Python三方庫。

1 安裝Python的setuptools庫 (因為安裝Python的Selenium庫需要用到它)

? ? 1) 下載setuptools文件并解壓?https://pypi.python.org/pypi/setuptools/12.0.4#downloads

? ? 2) 打開CMD窗口,進入解壓后的setuptools目錄,執行命令python setup.py install 進行安裝?

?
1 D:\setuptools-12.0.4>python?setup.py?install

2 安裝Python的Selenium庫(Appium是采用WebDriver傳輸測試請求,利用Selenium的WebDriver功能)

? ? 1) 下載selenium文件并解壓?https://pypi.python.org/pypi/selenium/2.44.0

? ? 2) 打開CMD窗口,進入解壓后的selenium目錄,執行命令python setup.py install 進行安裝?

?
1 D:\selenium-2.44.0>python?setup.py?install

3 下載Python的HTMLTestRunner.py,保存到Python安裝路徑的Lib目錄下(如C:\Python27\Lib)。

下載地址?http://tungwaiyip.info/software/HTMLTestRunner.html

?

接下來,在你的Android手機上安裝一個YY語音(我們以YY語音為例),然后把你的手機連接到電腦(建議采用Android4.x的手機), 執行命令adb devices 查看手機的deviceName,比如我的手機deviceName是?4d00b6a5bee8a047

?
1 2 3 D:\>adb?devices List?of?devices?attached 4d00b6a5bee8a047????????device

?

開始寫測試腳本my_android_test.py(腳本里要配置正確deviceName,軟件包和啟動Activity):

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 #coding:utf-8 import?os import?HTMLTestRunner import?unittest from?selenium?import?webdriver #?Returns?abs?path?relative?to?this?file?and?not?cwd PATH?=?lambda?p:?os.path.abspath( ????os.path.join(os.path.dirname(__file__),?p) ) class?elementA(unittest.TestCase): ????def?test_(self):?? ????????desired_caps?=?{} ????????desired_caps['deviceName']?=?'4d00b6a5bee8a047'??#adb?devices查到的設備名 ????????desired_caps['platformName']?=?'Android' ????????desired_caps['platformVersion']?=?'4.2'?????? ????????desired_caps['appPackage']?=?'com.duowan.mobile'??#被測App的包名 ????????desired_caps['appActivity']?=?'com.yy.mobile.ui.splash.SplashActivity'?#啟動時的Activity ????????driver?=?webdriver.Remote('http://localhost:4723/wd/hub',?desired_caps) ????????el?=?driver.find_element_by_name(u"神曲") ????????self.assertIsNotNone(el) ????????el.click()????? ????????yueBang?=?driver.find_element_by_name(u"月榜") ????????self.assertIsNotNone(yueBang) ????????yueBang.click()???? ????????driver.quit() ????? if?__name__?==?'__main__': ????testunit=unittest.TestSuite()????????#定義一個單元測試容器 ????testunit.addTest(elementA("test_"))??#將測試用例加入到測試容器中???? ????filename="./myAppiumLog.html"????????#定義個報告存放路徑,支持相對路徑。 ????fp=file(filename,'wb') ????runner?=?HTMLTestRunner.HTMLTestRunner(stream=fp,title='Report_title',description='Report_description')??#使用HTMLTestRunner配置參數,輸出報告路徑、報告標題、描述 ????runner.run(testunit)?????????????????#自動進行測試

?

打開一個CMD窗口,啟動Appium。 再打開一個CMD新窗口,執行命令 python my_android_test.py 執行測試腳本。

測試完成后,會在測試腳本的同目錄下生成一個名為 myAppiumLog.html的Log文件(見腳本中相應的代碼段)。同時,Appium運行窗口默認會打印整個測試過程的所有信息,如下所示:(整 個測試過程,Appium做了以下一些事:獲取手機系統信息、啟動UIAutomator、端口forward、啟動手機上的Appium服務、執行控件 的操作如查找點擊等等)

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 info:?-->?POST?/wd/hub/session?{"desiredCapabilities":{"platformVersion":"4.2","deviceName":"4d00b6a5bee8a047","platformName":"Android","appActivity": "com.yy.mobile.ui.splash.SplashActivity","appPackage":"com.duowan.mobile"}} info:?Client?User-Agent?string:?Python-urllib/2.7 info:?[debug]?Didn't?get?app?but?did?get?Android?package,?will?attempt?to?launch?it?on?the?device info:?[debug]?Creating?new?appium?session?1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35 info:?Starting?android?appium info:?[debug]?Getting?Java?version info:?Java?version?is:?1.6.0_45 info:?[debug]?Using?fast?reset??true info:?[debug]?Preparing?device?for?session info:?[debug]?Not?checking?whether?app?is?present?since?we?are?assuming?it's?already?on?the?device info:?[debug]?Checking?whether?adb?is?present info:?[debug]?Using?adb?from?C:\Android\sdk\platform-tools\adb.exe info:?Retrieving?device info:?[debug]?Trying?to?find?a?connected?android?device info:?[debug]?Getting?connected?devices... info:?[debug]?executing?cmd:?C:\Android\sdk\platform-tools\adb.exe?devices info:?[debug]?2?device(s)?connected info:?Found?device?4d00b6a5bee8a047 info:?[debug]?Setting?device?id?to?4d00b6a5bee8a047 info:?[debug]?Waiting?for?device?to?be?ready?and?to?respond?to?shell?commands?(timeout?=?5) info:?[debug]?executing?cmd:?C:\Android\sdk\platform-tools\adb.exe?-s?4d00b6a5bee8a047?wait-for-device info:?[debug]?executing?cmd:?C:\Android\sdk\platform-tools\adb.exe?-s?4d00b6a5bee8a047?shell?"echo?'ready'" info:?[debug]?Starting?logcat?capture warn:?No?app?capability,?can't?parse?package/activity info:?[debug]?Getting?device?API?level info:?[debug]?executing?cmd:?C:\Android\sdk\platform-tools\adb.exe?-s?4d00b6a5bee8a047?shell?"getprop?ro.build.version.sdk" info:?[debug]?Device?is?at?API?Level?19 info:?Device?API?level?is:?19 info:?[debug]?Apk?doesn't?exist?locally info:?[debug]?executing?cmd:?C:\Android\sdk\platform-tools\adb.exe?-s?4d00b6a5bee8a047?shell?"rm?-rf?/data/local/tmp/strings.json" info:?[debug]?Not?uninstalling?app?since?server?not?started?with?--full-reset info:?[debug]?Skipping?install?since?we?launched?with?a?package?instead?of?an?app?path info:?[debug]?Forwarding?system:4724?to?device:4724 info:?[debug]?executing?cmd:?C:\Android\sdk\platform-tools\adb.exe?-s?4d00b6a5bee8a047?forward?tcp:4724?tcp:4724 info:?[debug]?Pushing?appium?bootstrap?to?device... info:?[debug]?executing?cmd:?C:\Android\sdk\platform-tools\adb.exe?-s?4d00b6a5bee8a047?push?"C:\\Users\\Administrator\\AppData\\Roaming\\npm\\node_mod ules\\appium\\build\\android_bootstrap\\AppiumBootstrap.jar"?/data/local/tmp/ info:?[debug]?Pushing?settings?apk?to?device... info:?[debug]?executing?cmd:?C:\Android\sdk\platform-tools\adb.exe?-s?4d00b6a5bee8a047?install?"C:\Users\Administrator\AppData\Roaming\npm\node_module s\appium\build\settings_apk\settings_apk-debug.apk" info:?[debug]?Pushing?unlock?helper?app?to?device... info:?[debug]?executing?cmd:?C:\Android\sdk\platform-tools\adb.exe?-s?4d00b6a5bee8a047?install?"C:\Users\Administrator\AppData\Roaming\npm\node_module s\appium\build\unlock_apk\unlock_apk-debug.apk" info:?Starting?App info:?[debug]?Attempting?to?kill?all?'uiautomator'?processes info:?[debug]?Getting?all?processes?with?'uiautomator' info:?[debug]?executing?cmd:?C:\Android\sdk\platform-tools\adb.exe?-s?4d00b6a5bee8a047?shell?"ps?'uiautomator'" info:?[debug]?No?matching?processes?found info:?[debug]?Running?bootstrap info:?[debug]?spawning:?C:\Android\sdk\platform-tools\adb.exe?-s?4d00b6a5bee8a047?shell?uiautomator?runtest?AppiumBootstrap.jar?-c?io.appium.android.b ootstrap.Bootstrap info:?[debug]?[UIAUTOMATOR?STDOUT]?INSTRUMENTATION_STATUS:?numtests=1 info:?[debug]?[UIAUTOMATOR?STDOUT]?INSTRUMENTATION_STATUS:?stream= info:?[debug]?[UIAUTOMATOR?STDOUT]?io.appium.android.bootstrap.Bootstrap: info:?[debug]?[UIAUTOMATOR?STDOUT]?INSTRUMENTATION_STATUS:?id=UiAutomatorTestRunner info:?[debug]?[UIAUTOMATOR?STDOUT]?INSTRUMENTATION_STATUS:?test=testRunServer info:?[debug]?[UIAUTOMATOR?STDOUT]?INSTRUMENTATION_STATUS:?class=io.appium.android.bootstrap.Bootstrap info:?[debug]?[UIAUTOMATOR?STDOUT]?INSTRUMENTATION_STATUS:?current=1 info:?[debug]?[UIAUTOMATOR?STDOUT]?INSTRUMENTATION_STATUS_CODE:?1 info:?[debug]?[BOOTSTRAP]?[debug]?Socket?opened?on?port?4724 info:?[debug]?[BOOTSTRAP]?[debug]?Appium?Socket?Server?Ready info:?[debug]?[BOOTSTRAP]?[debug]?Loading?json... info:?[debug]?Waking?up?device?if?it's?not?alive info:?[debug]?Pushing?command?to?appium?work?queue:?["wake",{}] info:?[debug]?[BOOTSTRAP]?[debug]?Registered?crash?watchers. info:?[debug]?[BOOTSTRAP]?[debug]?Client?connected info:?[debug]?[BOOTSTRAP]?[debug]?Got?data?from?client:?{"cmd":"action","action":"wake","params":{}} info:?[debug]?[BOOTSTRAP]?[debug]?Got?command?of?type?ACTION info:?[debug]?[BOOTSTRAP]?[debug]?Got?command?action:?wake info:?[debug]?[BOOTSTRAP]?[debug]?Returning?result:?{"value":true,"status":0} info:?[debug]?executing?cmd:?C:\Android\sdk\platform-tools\adb.exe?-s?4d00b6a5bee8a047?shell?"dumpsys?window" info:?[debug]?Screen?already?unlocked,?continuing. info:?[debug]?Pushing?command?to?appium?work?queue:?["getDataDir",{}] info:?[debug]?[BOOTSTRAP]?[debug]?Got?data?from?client:?{"cmd":"action","action":"getDataDir","params":{}} info:?[debug]?[BOOTSTRAP]?[debug]?Got?command?of?type?ACTION info:?[debug]?[BOOTSTRAP]?[debug]?Got?command?action:?getDataDir info:?[debug]?[BOOTSTRAP]?[debug]?Returning?result:?{"value":"\/data\/local\/tmp","status":0} info:?[debug]?dataDir?set?to:?/data/local/tmp info:?[debug]?Pushing?command?to?appium?work?queue:?["compressedLayoutHierarchy",{"compressLayout":false}] info:?[debug]?[BOOTSTRAP]?[debug]?Got?data?from?client:?{"cmd":"action","action":"compressedLayoutHierarchy","params":{"compressLayout":false}} info:?[debug]?[BOOTSTRAP]?[debug]?Got?command?of?type?ACTION info:?[debug]?[BOOTSTRAP]?[debug]?Got?command?action:?compressedLayoutHierarchy info:?[debug]?[BOOTSTRAP]?[debug]?Returning?result:?{"value":false,"status":0} info:?[debug]?Getting?device?API?level info:?[debug]?executing?cmd:?C:\Android\sdk\platform-tools\adb.exe?-s?4d00b6a5bee8a047?shell?"getprop?ro.build.version.sdk" info:?[debug]?Device?is?at?API?Level?19 info:?[debug]?executing?cmd:?C:\Android\sdk\platform-tools\adb.exe?-s?4d00b6a5bee8a047?shell?"am?start?-S?-a?android.intent.action.MAIN?-c?android.int ent.category.LAUNCHER?-f?0x10200000?-n?com.duowan.mobile/com.yy.mobile.ui.splash.SplashActivity" info:?[debug]?Waiting?for?pkg?"com.duowan.mobile"?and?activity?"com.yy.mobile.ui.splash.SplashActivity"?to?be?focused info:?[debug]?Getting?focused?package?and?activity info:?[debug]?executing?cmd:?C:\Android\sdk\platform-tools\adb.exe?-s?4d00b6a5bee8a047?shell?"dumpsys?window?windows" info:?[debug]?Device?launched!?Ready?for?commands info:?[debug]?Setting?command?timeout?to?the?default?of?60?secs info:?[debug]?Appium?session?started?with?sessionId?1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35 info:?<--?POST?/wd/hub/session?303?8377.855?ms?-?9 info:?-->?GET?/wd/hub/session/1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35?{} info:?[debug]?Responding?to?client?with?success:?{"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"4.2","webStorageEn abled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"w arnings":{},"desired":{"platformVersion":"4.2","deviceName":"4d00b6a5bee8a047","platformName":"Android","appActivity":"com.yy.mobile.ui.splash.SplashA ctivity","appPackage":"com.duowan.mobile"},"deviceName":"4d00b6a5bee8a047","platformName":"Android","appActivity":"com.yy.mobile.ui.splash.SplashActiv ity","appPackage":"com.duowan.mobile"},"sessionId":"1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35"} info:?<--?GET?/wd/hub/session/1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35?200?2.143?ms?-?641?{"status":0,"value":{"platform":"LINUX","browserName":"Android", "platformVersion":"4.2","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":t rue,"locationContextEnabled":false,"warnings":{},"desired":{"platformVersion":"4.2","deviceName":"4d00b6a5bee8a047","platformName":"Android","appActiv ity":"com.yy.mobile.ui.splash.SplashActivity","appPackage":"com.duowan.mobile"},"deviceName":"4d00b6a5bee8a047","platformName":"Android","appActivity" :"com.yy.mobile.ui.splash.SplashActivity","appPackage":"com.duowan.mobile"},"sessionId":"1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35"} info:?-->?POST?/wd/hub/session/1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35/element?{"using":"name","sessionId":"1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35","value" :"神曲"} info:?[debug]?Waiting?up?to?0ms?for?condition info:?[debug]?Pushing?command?to?appium?work?queue:?["find",{"strategy":"name","selector":"神曲","context":"","multiple":false}] info:?[debug]?[BOOTSTRAP]?[debug]?Got?data?from?client:?{"cmd":"action","action":"find","params":{"strategy":"name","selector":"神曲","context":"","mu ltiple":false}} info:?[debug]?[BOOTSTRAP]?[debug]?Got?command?of?type?ACTION info:?[debug]?[BOOTSTRAP]?[debug]?Got?command?action:?find info:?[debug]?[BOOTSTRAP]?[debug]?Finding?神曲?using?NAME?with?the?contextId:??multiple:?false info:?[debug]?[BOOTSTRAP]?[debug]?Using:?UiSelector[DESCRIPTION=神曲,?INSTANCE=0] info:?[debug]?[BOOTSTRAP]?[debug]?Using:?UiSelector[TEXT=神曲,?INSTANCE=0] info:?[debug]?[BOOTSTRAP]?[debug]?Returning?result:?{"value":{"ELEMENT":"1"},"status":0} info:?[debug]?Responding?to?client?with?success:?{"status":0,"value":{"ELEMENT":"1"},"sessionId":"1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35"} info:?<--?POST?/wd/hub/session/1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35/element?200?30359.695?ms?-?87?{"status":0,"value":{"ELEMENT":"1"},"sessionId":"1b0 e4603-d4c8-44d7-868a-cd1c0d1f4b35"} info:?-->?POST?/wd/hub/session/1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35/element/1/click?{"sessionId":"1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35","id":"1"} info:?[debug]?Pushing?command?to?appium?work?queue:?["element:click",{"elementId":"1"}] info:?[debug]?[BOOTSTRAP]?[debug]?Got?data?from?client:?{"cmd":"action","action":"element:click","params":{"elementId":"1"}} info:?[debug]?[BOOTSTRAP]?[debug]?Got?command?of?type?ACTION info:?[debug]?[BOOTSTRAP]?[debug]?Got?command?action:?click info:?[debug]?[BOOTSTRAP]?[debug]?Returning?result:?{"value":true,"status":0} info:?[debug]?Responding?to?client?with?success:?{"status":0,"value":true,"sessionId":"1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35"} info:?<--?POST?/wd/hub/session/1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35/element/1/click?200?3267.154?ms?-?76?{"status":0,"value":true,"sessionId":"1b0e460 3-d4c8-44d7-868a-cd1c0d1f4b35"} info:?-->?POST?/wd/hub/session/1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35/element?{"using":"name","sessionId":"1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35","value" :"站臺"} info:?[debug]?Waiting?up?to?0ms?for?condition info:?[debug]?Pushing?command?to?appium?work?queue:?["find",{"strategy":"name","selector":"站臺","context":"","multiple":false}] info:?[debug]?[BOOTSTRAP]?[debug]?Got?data?from?client:?{"cmd":"action","action":"find","params":{"strategy":"name","selector":"站臺","context":"","mu ltiple":false}} info:?[debug]?[BOOTSTRAP]?[debug]?Got?command?of?type?ACTION info:?[debug]?[BOOTSTRAP]?[debug]?Got?command?action:?find info:?[debug]?[BOOTSTRAP]?[debug]?Finding?站臺?using?NAME?with?the?contextId:??multiple:?false info:?[debug]?[BOOTSTRAP]?[debug]?Using:?UiSelector[DESCRIPTION=站臺,?INSTANCE=0] info:?[debug]?[BOOTSTRAP]?[debug]?Using:?UiSelector[TEXT=站臺,?INSTANCE=0] info:?[debug]?[BOOTSTRAP]?[debug]?Returning?result:?{"value":"No?element?found","status":7} info:?[debug]?Condition?unmet?after?190ms.?Timing?out. info:?[debug]?Responding?to?client?with?error:?{"status":7,"value":{"message":"An?element?could?not?be?located?on?the?page?using?the?given?search?para meters.","origValue":"No?element?found"},"sessionId":"1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35"} info:?<--?POST?/wd/hub/session/1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35/element?500?196.363?ms?-?195 info:?-->?POST?/wd/hub/session/1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35/element?{"using":"name","sessionId":"1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35","value" :"月榜"} info:?[debug]?Waiting?up?to?0ms?for?condition info:?[debug]?Pushing?command?to?appium?work?queue:?["find",{"strategy":"name","selector":"月榜","context":"","multiple":false}] info:?[debug]?[BOOTSTRAP]?[debug]?Got?data?from?client:?{"cmd":"action","action":"find","params":{"strategy":"name","selector":"月榜","context":"","mu ltiple":false}} info:?[debug]?[BOOTSTRAP]?[debug]?Got?command?of?type?ACTION info:?[debug]?[BOOTSTRAP]?[debug]?Got?command?action:?find info:?[debug]?[BOOTSTRAP]?[debug]?Finding?月榜?using?NAME?with?the?contextId:??multiple:?false info:?[debug]?[BOOTSTRAP]?[debug]?Using:?UiSelector[DESCRIPTION=月榜,?INSTANCE=0] info:?[debug]?[BOOTSTRAP]?[debug]?Using:?UiSelector[TEXT=月榜,?INSTANCE=0] info:?[debug]?[BOOTSTRAP]?[debug]?Returning?result:?{"value":{"ELEMENT":"2"},"status":0} info:?[debug]?Responding?to?client?with?success:?{"status":0,"value":{"ELEMENT":"2"},"sessionId":"1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35"} info:?<--?POST?/wd/hub/session/1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35/element?200?242.911?ms?-?87?{"status":0,"value":{"ELEMENT":"2"},"sessionId":"1b0e4 603-d4c8-44d7-868a-cd1c0d1f4b35"} info:?-->?POST?/wd/hub/session/1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35/element/2/click?{"sessionId":"1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35","id":"2"} info:?[debug]?Pushing?command?to?appium?work?queue:?["element:click",{"elementId":"2"}] info:?[debug]?[BOOTSTRAP]?[debug]?Got?data?from?client:?{"cmd":"action","action":"element:click","params":{"elementId":"2"}} info:?[debug]?[BOOTSTRAP]?[debug]?Got?command?of?type?ACTION info:?[debug]?[BOOTSTRAP]?[debug]?Got?command?action:?click info:?[debug]?[BOOTSTRAP]?[debug]?Returning?result:?{"value":true,"status":0} info:?[debug]?Responding?to?client?with?success:?{"status":0,"value":true,"sessionId":"1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35"} info:?<--?POST?/wd/hub/session/1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35/element/2/click?200?3377.934?ms?-?76?{"status":0,"value":true,"sessionId":"1b0e460 3-d4c8-44d7-868a-cd1c0d1f4b35"} info:?-->?POST?/wd/hub/session/1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35/element?{"using":"name","sessionId":"1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35","value" :"站臺"} info:?[debug]?Waiting?up?to?0ms?for?condition info:?[debug]?Pushing?command?to?appium?work?queue:?["find",{"strategy":"name","selector":"站臺","context":"","multiple":false}] info:?[debug]?[BOOTSTRAP]?[debug]?Got?data?from?client:?{"cmd":"action","action":"find","params":{"strategy":"name","selector":"站臺","context":"","mu ltiple":false}} info:?[debug]?[BOOTSTRAP]?[debug]?Got?command?of?type?ACTION info:?[debug]?[BOOTSTRAP]?[debug]?Got?command?action:?find info:?[debug]?[BOOTSTRAP]?[debug]?Finding?站臺?using?NAME?with?the?contextId:??multiple:?false info:?[debug]?[BOOTSTRAP]?[debug]?Using:?UiSelector[DESCRIPTION=站臺,?INSTANCE=0] info:?[debug]?[BOOTSTRAP]?[debug]?Using:?UiSelector[TEXT=站臺,?INSTANCE=0] info:?[debug]?[BOOTSTRAP]?[debug]?Returning?result:?{"value":{"ELEMENT":"3"},"status":0} info:?[debug]?Responding?to?client?with?success:?{"status":0,"value":{"ELEMENT":"3"},"sessionId":"1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35"} info:?<--?POST?/wd/hub/session/1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35/element?200?630.792?ms?-?87?{"status":0,"value":{"ELEMENT":"3"},"sessionId":"1b0e4 603-d4c8-44d7-868a-cd1c0d1f4b35"} info:?-->?DELETE?/wd/hub/session/1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35?{} info:?Shutting?down?appium?session info:?[debug]?Pressing?the?HOME?button info:?[debug]?executing?cmd:?C:\Android\sdk\platform-tools\adb.exe?-s?4d00b6a5bee8a047?shell?"input?keyevent?3" info:?[debug]?Stopping?logcat?capture info:?[debug]?Logcat?terminated?with?code?null,?signal?SIGTERM info:?[debug]?[BOOTSTRAP]?[debug]?Got?data?from?client:?{"cmd":"shutdown"} info:?[debug]?[BOOTSTRAP]?[debug]?Got?command?of?type?SHUTDOWN info:?[debug]?[BOOTSTRAP]?[debug]?Returning?result:?{"value":"OK,?shutting?down","status":0} info:?[debug]?[BOOTSTRAP]?[debug]?Closed?client?connection info:?[debug]?[UIAUTOMATOR?STDOUT]?INSTRUMENTATION_STATUS:?numtests=1 info:?[debug]?[UIAUTOMATOR?STDOUT]?INSTRUMENTATION_STATUS:?stream=. info:?[debug]?[UIAUTOMATOR?STDOUT]?INSTRUMENTATION_STATUS:?id=UiAutomatorTestRunner info:?[debug]?[UIAUTOMATOR?STDOUT]?INSTRUMENTATION_STATUS:?test=testRunServer info:?[debug]?[UIAUTOMATOR?STDOUT]?INSTRUMENTATION_STATUS:?class=io.appium.android.bootstrap.Bootstrap info:?[debug]?[UIAUTOMATOR?STDOUT]?INSTRUMENTATION_STATUS:?current=1 info:?[debug]?[UIAUTOMATOR?STDOUT]?INSTRUMENTATION_STATUS_CODE:?0 info:?[debug]?[UIAUTOMATOR?STDOUT]?INSTRUMENTATION_STATUS:?stream= info:?[debug]?[UIAUTOMATOR?STDOUT]?Test?results?for?WatcherResultPrinter=. info:?[debug]?[UIAUTOMATOR?STDOUT]?Time:?41.607 info:?[debug]?[UIAUTOMATOR?STDOUT]?OK?(1?test) info:?[debug]?[UIAUTOMATOR?STDOUT]?INSTRUMENTATION_STATUS_CODE:?-1 info:?[debug]?Sent?shutdown?command,?waiting?for?UiAutomator?to?stop... info:?[debug]?UiAutomator?shut?down?normally info:?[debug]?Cleaning?up?android?objects info:?[debug]?Cleaning?up?appium?session info:?[debug]?Responding?to?client?with?success:?{"status":0,"value":null,"sessionId":"1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35"} info:?<--?DELETE?/wd/hub/session/1b0e4603-d4c8-44d7-868a-cd1c0d1f4b35?200?1333.091?ms?-?76?{"status":0,"value":null,"sessionId":"1b0e4603-d4c8-44d7-86 8a-cd1c0d1f4b35"}

?

有任何問題,歡迎大家指正。

?

至于網上說的還要安裝Ant和Maven,其實不必,除非你的代碼和庫管理需要用到他們。

接下來我們將以手機YY為例,寫一個簡單的Python測試腳本,來看看Appium到底怎么使用。

轉載于:https://www.cnblogs.com/zhengah/p/4554408.html

與50位技術專家面對面20年技術見證,附贈技術全景圖

總結

以上是生活随笔為你收集整理的Appium环境的安装与配置,Python测试脚本测试的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。