{"id":794,"date":"2023-02-28T11:28:00","date_gmt":"2023-02-28T03:28:00","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=794"},"modified":"2023-04-05T17:44:00","modified_gmt":"2023-04-05T09:44:00","slug":"appium-automation-testing-appium-api-context","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/28\/appium-automation-testing-appium-api-context\/","title":{"rendered":"Appium\u81ea\u52a8\u5316\u6d4b\u8bd5\uff0810\uff09\u2014\u2014 Appium API \u4e4b\u4e0a\u4e0b\u6587\u64cd\u4f5c"},"content":{"rendered":"<p>\u5176\u5b9e\u4e0a\u4e0b\u6587\u7684\u64cd\u4f5c\u4e3b\u8981\u9488\u5bf9\u4e8e\u6df7\u5408\u5e94\u7528\u3002\u5565\u662f\u6df7\u5408\u5e94\u7528\uff0c\u7b80\u5355\u6765\u8bf4\u5c31\u662fAPP\u7528\u91cc\u9762\u5d4c\u5165\u7f51\u9875\u3002Android\u4e0a\u7684\u6d4f\u89c8\u5668\u5c31\u5c5e\u4e8e\u6df7\u5408\u5e94\u7528\u3002<\/p>\n<h2>\u83b7\u53d6\u5f53\u524d\u4e0a\u4e0b\u6587<\/h2>\n<p><!-- more --><\/p>\n<p>\u65b9\u6cd5\uff1a<\/p>\n<ul>\n<li>getContext()<\/li>\n<\/ul>\n<p>\u83b7\u53d6\u5f53\u524d\u6240\u6709\u7684\u53ef\u7528\u7684\u4e0a\u4e0b\u6587\u3002\u8be5\u65b9\u6cd5\u4e0d\u9700\u8981\u5165\u53c2\u3002<\/p>\n<pre><code class=\"language-java\">String ct = driver.getContext();\nSystem.out.println(ct);\n\n--------------------\u8ba1\u7b97\u5668\u5e94\u7528\u7684\u6253\u5370\u7ed3\u679c--------------------\nNATIVE_APP<\/code><\/pre>\n<h2>\u5f53\u524d\u6240\u6709\u4e0a\u4e0b\u6587\u53e5\u67c4<\/h2>\n<p>\u65b9\u6cd5\uff1a<\/p>\n<ul>\n<li>getContextHandles()<\/li>\n<\/ul>\n<p>\u83b7\u53d6\u5f53\u524d\u6240\u6709\u53ef\u7528\u7684\u4e0a\u4e0b\u6587\u3002\u8be5\u65b9\u6cd5\u4e0d\u9700\u8981\u5165\u53c2\u3002<\/p>\n<h2>\u5207\u6362\u4e0a\u4e0b\u6587<\/h2>\n<ul>\n<li>context()<\/li>\n<\/ul>\n<p>\u5207\u6362\u5230\u7279\u5b9a\u7684\u4e0a\u4e0b\u6587\u4e2d\u3002\u9700\u8981\u6307\u5b9a\u4e0a\u4e0b\u6587\u7684\u540d\u79f0\u3002<\/p>\n<pre><code class=\"language-java\">driver.context(&#039;NATIVE_APP&#039;)\ndriver.context(&#039;WEBVIEW_1&#039;)<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5176\u5b9e\u4e0a\u4e0b\u6587\u7684\u64cd\u4f5c\u4e3b\u8981\u9488\u5bf9\u4e8e\u6df7\u5408\u5e94\u7528\u3002\u5565\u662f\u6df7\u5408\u5e94\u7528\uff0c\u7b80\u5355\u6765\u8bf4\u5c31\u662fAPP\u7528\u91cc\u9762\u5d4c\u5165\u7f51\u9875\u3002Android\u4e0a\u7684\u6d4f\u89c8\u5668\u5c31 [&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-794","post","type-post","status-publish","format-standard","hentry","category-appium"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/794","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=794"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/794\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=794"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=794"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=794"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}