{"id":793,"date":"2023-02-28T11:18:06","date_gmt":"2023-02-28T03:18:06","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=793"},"modified":"2023-04-29T16:55:08","modified_gmt":"2023-04-29T08:55:08","slug":"appium-automation-testing-appium-api-application","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/28\/appium-automation-testing-appium-api-application\/","title":{"rendered":"appium\u81ea\u52a8\u5316\u6d4b\u8bd5\uff089\uff09-appium-api-\u4e4b\u5e94\u7528\u64cd\u4f5c"},"content":{"rendered":"<p>\u672c\u6587\u7684\u6240\u7f57\u5217\u7684\u65b9\u6cd5\u4e3b\u8981\u9488\u5bf9\u5e94\u7528\u7684\u64cd\u4f5c\uff0c\u5982\u5e94\u7528\u7684\u5b89\u88c5\u3001\u5378\u8f7d\u3001\u5173\u95ed\u3001\u542f\u52a8\u7b49\u3002<\/p>\n<h2>\u5b89\u88c5\u5e94\u7528<\/h2>\n<p>\u65b9\u6cd5\uff1a<\/p>\n<ul>\n<li>installApp()<\/li>\n<\/ul>\n<p><!-- more --><\/p>\n<p>\u5b89\u88c5\u5e94\u7528\u5230\u8bbe\u5907\u4e2d\u53bb\u3002\u9700\u8981apk\u5305\u7684\u8def\u5f84\u3002<\/p>\n<pre><code class=\"language-java\">driver.installApp(&quot;path\/to\/my.apk&quot;);\ndriver.installApp(&quot;D:\\\\android\\\\apk\\\\ContactManager.apk&quot;);<\/code><\/pre>\n<h2>\u5378\u8f7d\u5e94\u7528<\/h2>\n<p>\u65b9\u6cd5\uff1a<\/p>\n<ul>\n<li>removeApp()<\/li>\n<\/ul>\n<p>\u4ece\u8bbe\u5907\u4e2d\u5220\u9664\u4e00\u4e2a\u5e94\u7528\u3002<\/p>\n<pre><code class=\"language-java\">driver.removeApp(&quot;com.example.android.apis&quot;);<\/code><\/pre>\n<h2>\u5173\u95ed\u5e94\u7528<\/h2>\n<p>\u65b9\u6cd5\uff1a<\/p>\n<ul>\n<li>closeApp()<\/li>\n<\/ul>\n<p>\u5173\u95ed\u6253\u5f00\u7684\u5e94\u7528\uff0c\u9ed8\u8ba4\u5173\u95ed\u5f53\u524d\u6253\u5f00\u7684\u5e94\u7528\uff0c\u6240\u4ee5\u4e0d\u9700\u8981\u5165\u53c2\u3002\u8fd9\u4e2a\u65b9\u6cd5\u5e76\u975e\u771f\u6b63\u7684\u5173\u95ed\u5e94\u7528\uff0c\u76f8\u5f53\u4e8e\u6309home\u952e\u5c06\u5e94\u7528\u7f6e\u4e8e\u540e\u53f0\uff0c\u53ef\u4ee5\u901a\u8fc7launchApp()\u518d\u6b21\u542f\u52a8\u3002<\/p>\n<h2>\u542f\u52a8\u5e94\u7528<\/h2>\n<p>\u65b9\u6cd5\uff1a<\/p>\n<ul>\n<li>launchApp()<\/li>\n<\/ul>\n<p>\u542f\u52a8\u5e94\u7528\u3002\u4f60\u4e00\u5b9a\u5f88\u8ff7\u60d1\uff0c\u4e0d\u662f\u5728\u521d\u59cb\u5316\u7684\u914d\u7f6e\u4fe1\u606f\u5df2\u7ecf\u6307\u5b9a\u4e86\u5e94\u7528\uff0c\u811a\u672c\u8fd0\u884c\u7684\u65f6\u5019\u5c31\u9700\u8981\u542f\u52a8\u5e94\u7528\uff0c\u4e3a\u4ec0\u4e48\u8fd8\u8981\u6709\u8fd9\u4e2a\u65b9\u6cd5\u53bb\u542f\u52a8\u5e94\u7528\u5462\uff1f\u91cd\u65b0\u542f\u52a8\u5e94\u7528\u4e5f\u662f\u4e00\u4e2a\u6d4b\u8bd5\u70b9\uff0c\u8be5\u65b9\u6cd5\u9700\u8981\u914d\u5408closeApp()\u4f7f\u7528\u7684\u3002<\/p>\n<pre><code class=\"language-java\">driver.closeApp();\ndriver.launchApp();<\/code><\/pre>\n<h2>\u68c0\u67e5\u5e94\u7528\u662f\u5426\u5b89\u88c5<\/h2>\n<p>\u65b9\u6cd5\uff1a<\/p>\n<ul>\n<li>isAppInstalled()<\/li>\n<\/ul>\n<p>\u68c0\u67e5\u5e94\u7528\u662f\u5426\u5df2\u7ecf\u5b89\u88c5\u3002\u9700\u8981\u4f20\u53c2\u5e94\u7528\u5305\u7684\u540d\u5b57\uff0c\u8fd4\u56de\u7ed3\u679c\u4e3aTure\u6216False\u3002<\/p>\n<pre><code class=\"language-java\">driver.isAppInstalled(&#039;com.example.android.apis&#039;);<\/code><\/pre>\n<h2>\u5c06\u5e94\u7528\u7f6e\u4e8e\u540e\u53f0<\/h2>\n<p>\u65b9\u6cd5\uff1a<\/p>\n<ul>\n<li>runAppInBackground()<\/li>\n<\/ul>\n<p>\u5c06\u5f53\u524d\u6d3b\u8dc3\u7684\u5e94\u7528\u7a0b\u5e8f\u53d1\u9001\u5230\u540e\u53f0\u3002\u8fd9\u4e2a\u65b9\u6cd5\u9700\u8981\u5165\u53c2\uff0c\u9700\u8981\u6307\u5b9a\u5e94\u7528\u7f6e\u4e8e\u540e\u53f0\u7684\u65f6\u957f\u3002<\/p>\n<pre><code class=\"language-java\">driver.runAppInBackground(2);<\/code><\/pre>\n<h2>\u5e94\u7528\u91cd\u7f6e<\/h2>\n<p>\u65b9\u6cd5\uff1a<\/p>\n<ul>\n<li>resetApp()<\/li>\n<\/ul>\n<p>\u91cd\u7f6e\u5f53\u524d\u88ab\u6d4b\u7a0b\u5e8f\u5230\u51fa\u59cb\u5316\u72b6\u6001\u3002\u8be5\u65b9\u6cd5\u4e0d\u9700\u8981\u5165\u53c2\u3002<\/p>\n<pre><code class=\"language-java\">driver.resetApp();<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u7684\u6240\u7f57\u5217\u7684\u65b9\u6cd5\u4e3b\u8981\u9488\u5bf9\u5e94\u7528\u7684\u64cd\u4f5c\uff0c\u5982\u5e94\u7528\u7684\u5b89\u88c5\u3001\u5378\u8f7d\u3001\u5173\u95ed\u3001\u542f\u52a8\u7b49\u3002 \u5b89\u88c5\u5e94\u7528 \u65b9\u6cd5\uff1a installAp [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[223],"tags":[],"class_list":["post-793","post","type-post","status-publish","format-standard","hentry","category-appium"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/793","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=793"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/793\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=793"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=793"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=793"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}