{"id":1566,"date":"2024-04-09T10:01:33","date_gmt":"2024-04-09T02:01:33","guid":{"rendered":"https:\/\/www.gyxwsjdxh.com\/?p=1566"},"modified":"2024-04-09T10:01:33","modified_gmt":"2024-04-09T02:01:33","slug":"%e4%bd%bf%e7%94%a8appium%e5%81%9aandroid%e6%89%8b%e6%9c%ba%e8%87%aa%e5%8a%a8%e5%8c%96%e6%b5%8b%e8%af%95%ef%bc%81","status":"publish","type":"post","link":"https:\/\/www.gyxwsjdxh.com\/1566.html","title":{"rendered":"\u4f7f\u7528appium\u505aAndroid\u624b\u673a\u81ea\u52a8\u5316\u6d4b\u8bd5\uff01"},"content":{"rendered":"\n
\n
\u7f51\u4e0a\u5199Appium\u76f8\u5173\u8d44\u6599\u7684\u6587\u7ae0\u5df2\u7ecf\u591a\u5982\u725b\u6bdb\uff0c\u4eca\u5929\u6211\u6240\u63d0\u5230\u7684\u5185\u5bb9\u6216\u8bb8\u662f\u4f60\u4e0d\u592a\u4e86\u89e3\u7684\uff0c\u5e0c\u671b\u80fd\u57283\u5206\u949f\u65f6\u95f4\u4e3a\u5404\u4f4d\u770b\u5b98\u5e26\u6765\u4e0d\u4e00\u6837\u7684\u6536\u83b7~~<\/p>\n
Appium\u8fd9\u4e2a\u542c\u8d77\u6765\u65e2\u751f\u758f\u4e5f\u719f\u6089\u7684\u81ea\u52a8\u5316\u6d4b\u8bd5\u5de5\u5177\uff0c\u6bd4\u8d77\u539f\u751f\u7684UiAutomator\u53ef\u80fd\u662f\u5f02\u5e38\u7684\u4e0d\u8d77\u773c\uff0c\u53ef\u662f\u5374\u662f\u6709\u81ea\u8eab\u72ec\u5f53\u4e00\u9762\u7684\u80fd\u529b\uff0c\u53ef\u4ee5\u5b8c\u6210\u8bb8\u591a\u9ad8\u96be\u5ea6\u4f5c\u4e1a\uff0c\u5b8c\u6210UiAutomator\u4e0d\u53ef\u80fd\u5b8c\u6210\u7684\u4e00\u4e9b\u4efb\u52a1\uff0c\u53ef\u4ee5\u8bf4appium\u4e30\u5bcc\u4e86UiAutomator\u7684\u529f\u80fd\uff0c\u4f7fUiAutomator\u53ef\u4ee5\u5b8c\u6210\u66f4\u591a\u7684\u4efb\u52a1\u3002<\/p>\n
Appium\u5230\u5e95\u6709\u54ea\u4e9b\u4f18\u52bf\u4f1a\u8ba9\u6211\u4eec\u4f18\u5148\u9009\u62e9\u5b83\u53bb\u505a\u81ea\u52a8\u5316\u5462\uff1f<\/p>\n
\u4e00\u3001\u4e00\u53e5\u8bdd\u6982\u62ecAppium<\/p>\n
\u4e00\u6b3e\u5e94\u7528\u4e8e\u79fb\u52a8\u7aef\u7684\u81ea\u52a8\u5316\u6d4b\u8bd5\u6846\u67b6\uff0c\u652f\u6301\u8de8\u5e73\u53f0\u5e94\u7528\uff0cNative\u3001Hybird\u3001Mobile Web\u90fd\u652f\u6301\u3002\u5176\u7279\u70b9\u6982\u62ec\u4e00\u4e0b\uff1a<\/p>\n
\u8de8\u5e73\u53f0\u53ea\u8981\u4e00\u5957\u4ee3\u7801<\/p>\n
\u4e0d\u9700\u8981\u8bbe\u7f6e\u7b7e\u540d\uff0c\u4e0d\u6c61\u67d3\u6e90\u4ee3\u7801<\/p>\n
\u4e0d\u9700\u8981\u9879\u76ee\u6e90\u4ee3\u7801\u5c31\u53ef\u4ee5\u6d4b\u8bd5<\/p>\n
\u591a\u8bed\u8a00\u652f\u6301<\/p>\n
\u53ef\u652f\u6301\u591a\u79cd\u901a\u7528\u6846\u67b6<\/p>\n
\u5b8c\u5168\u5f00\u6e90\uff0c\u793e\u533a\u6d3b\u8dc3<\/p>\n
\u4e8c\u3001\u521d\u6b65\u8ba4\u8bc6appium\u5de5\u4f5c\u8fc7\u7a0b<\/p>\n
1.appium\u6709C\/S\u6a21\u5f0f<\/p>\n
2.appium\u662f\u57fa\u4e8ewebdriver\u534f\u8bae\u5bf9\u79fb\u52a8\u8bbe\u5907\u81ea\u52a8\u5316api\u6269\u5c55\u800c\u6210\u7684\uff0c\u6240\u6709\u5177\u6709\u548cwebdriver\u4e00\u6837\u7684\u7279\u6027\uff0c\u6bd4\u5982\u591a\u8bed\u8a00\u652f\u6301\u3002<\/p>\n
3.webdriver\u662f\u57fa\u4e8ehttp\u534f\u8bae\u7684\uff0c\u7b2c\u4e00\u8fde\u63a5\u4f1a\u5efa\u7acb\u4e00\u4e2asession\u4f1a\u8bdd\uff0c\u5e76\u901a\u8fc7post\u53d1\u9001\u4e00\u4e2ajson\u544a\u77e5\u670d\u52a1\u7aef\u76f8\u5173\u6d4b\u8bd5\u4fe1\u606f\u3002<\/p>\n
4.\u5bf9\u4e8eAndroid\u6765\u8bf4\uff0c4.2\u4ee5\u540e\u662f\u57fa\u4e8eUiAutomator\u6846\u67b6\u5b9e\u73b0\u67e5\u627e\u6ce8\u5165\u4e8b\u4ef6\u7684\uff0c4.2\u4ee5\u524d\u5219\u662finstrumentation\u6846\u67b6\u7684\uff0c\u5e76\u5c01\u88c5\u6210\u4e00\u4e2a\u53ebSelendroid\u63d0\u4f9b\u670d\u52a1\u3002<\/p>\n
5.\u5ba2\u6237\u7aef\u53ea\u9700\u8981\u53d1\u9001http\u8bf7\u6c42\u5b9e\u73b0\u901a\u8baf\uff0c\u610f\u5473\u7740\u5ba2\u6237\u7aef\u5c31\u662f\u591a\u8bed\u8a00\u652f\u6301\u7684\u3002<\/p>\n
6.appium\u670d\u52a1\u7aef\u662fnode.js\u5199\u7684\uff0c\u6240\u4ee5\u5b89\u88c5\u90a3\u4e2a\u5e73\u53f0\u90fd\u662f\u5148\u5b89\u88c5node\uff0c\u7136\u540enpm install -g appium(\u9700\u8981FQ)\u3002<\/p>\n
\u4e09\u3001\u73af\u5883\u642d\u5efa<\/p>\n
\u6b65\u9aa4\uff1a<\/p>\n
1.java\u5f00\u53d1\u73af\u5883JDK<\/p>\n
2.android SDK(platform\/platform tools\/tools\/build tools)<\/p>\n
3.python\u4e0b\u8f7d\u5b89\u88c5\uff08pip\uff09<\/p>\n
4.appium\u4e0b\u8f7d\u5b89\u88c5(\u670d\u52a1\u7aef+\u5ba2\u6237\u7aef)<\/p>\n
5.\u5b89\u88c5appium-python-client<\/p>\n
6.\u5b89\u88c5unittest<\/p>\n
\u7b2c\u4e00\u6b65<\/p>\n
\u5b89\u88c5JDK\uff0c\u5b89\u88c5\u5b8c\u6210\u540e\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3002<\/p>\n
cmd\u4e0bjava -version\u68c0\u67e5\u73af\u5883\u53d8\u91cf\u662f\u5426\u914d\u7f6e\u6210\u529f\u3002<\/p>\n
\u7b2c\u4e8c\u6b65<\/p>\n
\u5b89\u88c5Android SDK\uff08\u5b89\u5353\u8f6f\u4ef6\u5f00\u53d1\u5305\uff09\uff0c\u6d4b\u8bd5Android\u624b\u673a\u5fc5\u7136\u662f\u8981\u5b89\u88c5Android SDK\u3002<\/p>\n
\u4e0b\u8f7d\u5730\u5740\uff1ahttp:\/\/<\/span>tools.android-studio.org<\/span>\/index.php\/sdk\/<\/span><\/a> <\/p>\n \u89e3\u538b\u540e\u5c06\u6587\u4ef6\u5939\u6dfb\u52a0\u5230\u73af\u5883\u53d8\u91cf\u4e2d\uff0c\u6dfb\u52a0\u73af\u5883\u53d8\u91cf\uff0c\u5fc5\u987b\u521b\u5efa\u4e00\u4e2a\u540d\u4e3aANDROID_HOME\u7684\u53d8\u91cf\u3002<\/p>\n \u53cc\u51fbSDK Manager\uff0c\u9009\u88c5\u5de5\u5177\u3002\u5fc5\u88c5\uff1aTools\u6587\u4ef6\u5939\u4e0bAndroid SDK Platform-tools\u548cAndroid SDK Build-tools\uff0cAndroid SDK Tools\u53ef\u4ee5\u9009\u62e9\u662f\u5426\u66f4\u65b0\uff0c\u5efa\u8bae\u7f51\u901fOK\u76f4\u63a5\u66f4\u65b0\u3002GoogleFQ\u5b89\u88c5\uff1aExtras\u6587\u4ef6\u5939\u4e0b\u6240\u6709\u7684\u5168\u90e8\u5b89\u88c5\u3002<\/p>\n Path\u73af\u5883\u53d8\u91cf\u4e2d\u6dfb\u52a0ANDROID_HOME\u3001tools\u3001platform-tools\u3001build-tools\u76ee\u5f55\u3002\u4fdd\u5b58\u4fee\u6539\u3002<\/p>\n \u73af\u5883\u53d8\u91cf\u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u8fde\u63a5\u5b89\u5353\u624b\u673a\uff0c\u5e76\u5c06Android\u624b\u673a\u7684\u5f00\u53d1\u8005\u9009\u9879-USB\u8c03\u8bd5\u6253\u5f00\u3002<\/p>\n \u5728CMD\u4e0b\u6267\u884c\uff0cadb devices\uff0c\u51fa\u73b0\u4e0b\u56fe\u6837\u5f0f\u5219\u4ee3\u8868\u901a\u8fc7adb\u547d\u4ee4\uff0c\u83b7\u53d6\u5230\u4e86\u8fde\u63a5\u5728\u7535\u8111\u4e0aAndroid\u624b\u673a\u7684UDID\u3002<\/p>\n adb devices\u5728\u83b7\u53d6\u8fde\u63a5\u7684\u5b89\u5353\u624b\u673a\u65f6\uff0c\u4e00\u5b9a\u4f1a\u9047\u5230\u5f88\u591a\u5751\uff0c\u8fd9\u91cc\u6211\u4eec\u68b3\u7406\u4e0b\u53ef\u80fd\u4f1a\u9047\u5230\u7684\u5751\u3002<\/p>\n 1\u3001\u624b\u673aUSB\u8c03\u8bd5\u4e00\u5b9a\u8981\u6253\u5f00\u3002<\/p>\n 2\u3001\u591a\u627e\u4e24\u6839USB\u7ebf\uff0c\u6392\u9664\u7ebf\u7684\u95ee\u9898\u3002<\/p>\n 3\u3001\u591a\u6362\u51e0\u4e2aUSB\u63a5\u53e3\uff0c\u6392\u9664USB\u4e2a\u522b\u63a5\u53e3\u4e0d\u597d\u4f7f\u95ee\u9898\uff08\u5982\uff1a3.0 \u4e0e 2.0\uff09<\/p>\n 4\u3001\u9a71\u52a8\u7a0b\u5e8f\uff0c\u901a\u8fc7\u8bbe\u5907\u7ba1\u7406\u5668\u67e5\u770b\u662f\u5426\u5b89\u88c5\u9a71\u52a8\u6216\u9a71\u52a8\u4e0d\u662f\u6700\u65b0\u3002<\/p>\n 5\u3001\u66f4\u65b0adb_usb.ini\u6587\u4ef6\uff0c\u5c11\u6570\u7535\u8111\u4e0d\u80fd\u8bc6\u522bAndroid\u624b\u673a\u65f6\uff0c\u53ef\u4ee5\u5c06\u8bbe\u5907\u7ba1\u7406\u5668\u4e0b\u7684Android\u624b\u673a\u7684VID\u3001PID\u589e\u52a0\u5230adb_usb.ini\u6587\u4ef6\u4e2d\u3002<\/p>\n \u5c06VID\u3001PID\u4e2d\u201c_\u201d\u540e\u76844\u4f4d\u6570\u589e\u52a0\u5230adb_usb.ini\u4e0b\uff08\u6ce8\uff1aadb_usb.ini\u9ed8\u8ba4\u5728C\u76d8\u5f53\u524d\u7528\u6237\u5bb6\u76ee\u5f55\u4e0b\u7684.android\u76ee\u5f55\u4e0b\uff09<\/p>\n \u7406\u8bba\u4e0a\u8fd9\u4e9b\u64cd\u4f5c\u90fd\u64cd\u4f5c\u4e00\u904d\u540e\uff0c\u57fa\u672cadb devices\u5c31\u53ef\u4ee5\u627e\u5230Android\u624b\u673a\u4e86\u3002<\/p>\n \u7b2c\u4e09\u6b65<\/p>\n \u5b89\u88c5node.js\uff0c\u4e4b\u540e\u5c31\u53ef\u4ee5\u76f4\u63a5\u901a\u8fc7npm\u5b89\u88c5Appium\u3002\uff08\u6ce8\uff1anpm\u7c7b\u4f3c\u4e8ePython\u7684pip\uff0c\u4e00\u4e2a\u975e\u5b98\u65b9\u5305\u7ba1\u7406\u5668\uff09<\/p>\n \u5b98\u65b9\u4e0b\u8f7d\u5730\u5740\uff1ahttps:\/\/<\/span>nodejs.org\/en\/download\/<\/span><\/a><\/p>\n \u6839\u636e\u81ea\u5df1\u7684\u64cd\u4f5c\u7cfb\u7edf\u4e0b\u8f7d\u4e0d\u540c\u7248\u672c\u7684node.js<\/p>\n node.js\u7684\u5b89\u88c5\u4e00\u8def\u50bb\u74dc\u5f0fnext\u5c31\u53ef\u4ee5\u4e86\uff0c\u5b89\u88c5\u6210\u529f\u540e\u4f1a\u81ea\u52a8\u6dfb\u52a0\u73af\u5883\u53d8\u91cf\u3002<\/p>\n \u5b89\u88c5\u6210\u529f\u540e\uff0c\u68c0\u6d4b\u4e0bnpm\u662f\u5426\u53ef\u7528\u3002<\/p>\n \u7b2c\u56db\u6b65<\/p>\n \u5b89\u88c5appium\u670d\u52a1\u7aef\uff0c\u53ef\u901a\u8fc7cmd \u4e0b\u8f93\u5165 npm install -g appium \u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n \u5982\u679cnpm install -g appium\u7279\u522b\u6162\uff0c\u65e0\u6cd5\u4e0b\u8f7d\u65f6\uff0c\u53ef\u4ee5\u7528\u56fd\u5185\u7684\u955c\u50cfnpm –registry http:\/\/<\/span>registry.cnpmjs.org<\/span><\/a> install -g appium<\/p>\n \u5b89\u88c5\u5982\u679c\u5931\u8d25\u53ef\u4ee5\u5c1d\u8bd5\u901a\u8fc7cnpm\u5b89\u88c5appium<\/p>\n \u901a\u8fc7npm\u547d\u4ee4\u5b89\u88c5cnpm<\/p>\n npm install -g cnpm –registry=https:\/\/<\/span>registry.npm.taobao.org<\/span><\/a><\/p>\n \u901a\u8fc7cnpm\u5b89\u88c5appium<\/p>\n cnpm install -g appium –no-cache<\/p>\n \u5b89\u88c5\u6210\u529f\u540e\uff0c\u901a\u8fc7appium -v \u67e5\u770b\u5f53\u524dappium\u7248\u672c\uff0c\u76f4\u63a5\u8f93\u5165appium\u5219\u542f\u52a8appium server\u7aef\u3002<\/p>\n \u5982\u679c\u4ecd\u65e0\u6cd5\u4e0b\u8f7dappium\u670d\u52a1\u7aef\uff0c\u90a3\u5c31\u53ea\u80fd\u5728Appium\u5b98\u65b9\u7f51\u7ad9\u4e0a\u4e0b\u8f7d\u64cd\u4f5c\u7cfb\u7edf\u76f8\u5e94\u7684Appium\u7248\u672c\u3002<\/p>\n https:\/\/<\/span>bitbucket.org\/appium\/ap<\/span>pium.app\/downloads\/<\/span><\/a><\/p>\n \u5f53\u524d\u6700\u65b0\u7248\u672c\u4e3a AppiumForWindows_1_4_16_1.zip \uff0c\u6ce8\u610f\u8fd9\u662f\u4e00\u4e2a Windows \u7248\u672c\uff0c\u5982\u679c\u4f60\u7684\u7535\u8111\u4e3aMAC\u8bf7\u4e0b\u8f7d appium-1.5.3.dmg \u3002<\/p>\n