{"id":790,"date":"2023-02-28T11:15:40","date_gmt":"2023-02-28T03:15:40","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=790"},"modified":"2023-04-05T17:44:47","modified_gmt":"2023-04-05T09:44:47","slug":"appium-automation-testing-python-client-installation-testing","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/28\/appium-automation-testing-python-client-installation-testing\/","title":{"rendered":"Appium\u81ea\u52a8\u5316\u6d4b\u8bd5\uff086\uff09\u2014\u2014 python-client\u5b89\u88c5\u4e0e\u6d4b\u8bd5"},"content":{"rendered":"<h2>\u524d\u7f6e\u6761\u4ef6<\/h2>\n<p>\u4f7f\u7528 Python \u8bed\u8a00\u7f16\u5199 appium \u81ea\u52a8\u5316\u6d4b\u8bd5\u811a\u672c\uff0c\u9700\u8981\u5b89\u88c5\uff1a<\/p>\n<p><!-- more --><\/p>\n<ul>\n<li>Python<\/li>\n<li>Python IDE\uff0c\u63a8\u8350\uff1aPyCharm<\/li>\n<\/ul>\n<h2>\u5b89\u88c5 python-client<\/h2>\n<p>python-client \u7684\u9879\u76ee\u540d\u79f0\u53eb\uff1aAppium-Python-Client<\/p>\n<h3>PyCharm\u5b89\u88c5\uff08\u63a8\u8350\uff09<\/h3>\n<p>\u641c\u7d22\u5e76\u5b89\u88c5\u4f9d\u8d56\uff1aAppium-Python-Client<\/p>\n<h3>pip\u5b89\u88c5\uff08\u4f7f\u7528\u7ba1\u7406\u5458\u6743\u9650\uff09<\/h3>\n<pre><code class=\"language-python\">> python -V\nPython 3.6.5\n\n> pip install Appium-Python-Client\nCollecting Appium-Python-Client\n  Using cached Appium-Python-Client-0.26.tar.gz\nCollecting selenium&gt;=2.47.0 (from Appium-Python-Client)\n  Using cached selenium-3.11.0-py2.py3-none-any.whl\nInstalling collected packages: selenium, Appium-Python-Client\n  Running setup.py install for Appium-Python-Client ... done\nSuccessfully installed Appium-Python-Client-0.26 selenium-3.11.0<\/code><\/pre>\n<h2>\u8fd0\u884c\u7b2c\u4e00\u4e2aAppium\u6d4b\u8bd5<\/h2>\n<h3>\u542f\u52a8Android\u6a21\u62df\u5668\u6216\u8fde\u63a5Android\u771f\u673a<\/h3>\n<p>\u672c\u6587\u4ee5\u8fde\u63a5\u7ea2\u7c73Note 4X\u4e3a\u4f8b\uff0c\u6d4b\u8bd5\u5c0f\u7c73\u8ba1\u7b97\u5668<\/p>\n<h3>\u542f\u52a8 Appium<\/h3>\n<ul>\n<li>\u82e5\u901a\u8fc7 Node.js\u5b89\u88c5 Appium<\/li>\n<\/ul>\n<pre><code>> appium<\/code><\/pre>\n<ul>\n<li>\u82e5\u5b89\u88c5 Appium-Desktop<\/li>\n<\/ul>\n<p>\u70b9\u51fb <code>Start Server v1.7.2<\/code> \u6309\u94ae\u542f\u52a8\u670d\u52a1<\/p>\n<ul>\n<li>\u82e5\u5b89\u88c5 Appium Server<\/li>\n<\/ul>\n<p>\u70b9\u51fb\u53f3\u4e0a\u89d2\u4e09\u89d2\u6309\u94ae\uff0c\u6ce8\u610fAppium\u7684\u542f\u52a8\u65e5\u5fd7<\/p>\n<p>Appium\u5728\u542f\u52a8\u65f6\u9ed8\u8ba4\u5360\u7528\u672c\u673a\u76844723\u7aef\u53e3\uff0c\u5373\uff1a127.0.0.1:4723<\/p>\n<h2>\u7f16\u5199\u7b2c\u4e00\u4e2aAppium\u6d4b\u8bd5\u811a\u672c<\/h2>\n<pre><code class=\"language-python\">#coding=utf-8\nfrom appium import webdriver\n\ndesired_caps = {}\ndesired_caps[&#039;platformName&#039;] = &#039;Android&#039;\ndesired_caps[&#039;platformVersion&#039;] = &#039;7.0&#039;\ndesired_caps[&#039;deviceName&#039;] = &#039;Redmi Note 4X&#039;\ndesired_caps[&#039;appPackage&#039;] = &#039;com.miui.calculator&#039;\ndesired_caps[&#039;appActivity&#039;] = &#039;.cal.CalculatorActivity&#039;\n\ndriver = webdriver.Remote(&#039;http:\/\/localhost:4723\/wd\/hub&#039;, desired_caps)\n\ndriver.find_element_by_name(&quot;1&quot;).click()\ndriver.find_element_by_name(&quot;5&quot;).click()\ndriver.find_element_by_xpath(&quot;\/\/android.widget.Button[contains(@text, 9)]&quot;).click()\ndriver.find_element_by_id(&quot;btn_del_s&quot;).click()\ndriver.find_element_by_name(&quot;8&quot;).click()\ndriver.find_element_by_id(&quot;btn_plus_s&quot;).click()\ndriver.find_element_by_name(&quot;8&quot;).click()\ndriver.find_element_by_id(&quot;btn_equal_s&quot;).click()\n\nresult = driver.find_element_by_id(&quot;com.miui.calculator:id\/btn_0_s&quot;).text\nprint(&quot;result: &quot; + result)\n\ndriver.quit()<\/code><\/pre>\n<p>\u8fd0\u884cPython\u811a\u672c\uff0c\u5c06\u4f1a\u770b\u5230 \u7ea2\u7c73Note 4X \u7684\u5c0f\u7c73\u8ba1\u7b97\u5668\u8fd0\u884c\u754c\u9762\u5982\u4e0b\uff1a<\/p>\n<p>![Appium\u6d4b\u8bd5 &#8211; \u5c0f\u7c73\u8ba1\u7b97\u5668](<a target=\"_blank\" rel=\"noopener\" href=\"http:\/\/www.yezhou.me\/AppBlog\/images\/\u6d4b\u8bd5\/Appium\u6d4b\u8bd5\">http:\/\/www.yezhou.me\/AppBlog\/images\/\u6d4b\u8bd5\/Appium\u6d4b\u8bd5<\/a> &#8211; \u5c0f\u7c73\u8ba1\u7b97\u5668.png)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u7f6e\u6761\u4ef6 \u4f7f\u7528 Python \u8bed\u8a00\u7f16\u5199 appium \u81ea\u52a8\u5316\u6d4b\u8bd5\u811a\u672c\uff0c\u9700\u8981\u5b89\u88c5\uff1a Python Python  [&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-790","post","type-post","status-publish","format-standard","hentry","category-appium"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/790","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=790"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/790\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=790"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=790"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=790"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}