{"id":785,"date":"2023-02-28T11:12:37","date_gmt":"2023-02-28T03:12:37","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=785"},"modified":"2023-04-05T17:45:23","modified_gmt":"2023-04-05T09:45:23","slug":"let-the-new-version-of-appium-support-byname-positioning","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/28\/let-the-new-version-of-appium-support-byname-positioning\/","title":{"rendered":"\u8ba9\u65b0\u7248Appium\u652f\u6301ByName\u5b9a\u4f4d"},"content":{"rendered":"<h2>\u95ee\u9898\u63cf\u8ff0<\/h2>\n<p>Appium\u57281.5\u7248\u672c\u4ee5\u540e\u5c31\u4e0d\u518d\u652f\u6301ByName\u5b9a\u4f4d\uff0c\u4f7f\u7528ByName\u62a5\u5f02\u5e38\uff1a<\/p>\n<pre><code>org.openqa.selenium.InvalidSelectorException: Locator Strategy &#039;name&#039; is not supported for this session<\/code><\/pre>\n<p><!-- more --><\/p>\n<p>\u89e3\u51b3\u65b9\u6848\uff1a<\/p>\n<ul>\n<li>1.\u6362\u5176\u4ed6\u5b9a\u4f4d\u65b9\u5f0f\uff0c\u6bd4\u5982\u4f7f\u7528xpath\u4ee3\u66ff<\/li>\n<li>2.\u4e0d\u7528\u6362\u5b9a\u4f4d\u65b9\u5f0f\uff0cByName\u5b9a\u4f4d\u65b9\u5f0f\u65e0\u7f1d\u517c\u5bb9Appium\u65b0\u7248<\/li>\n<\/ul>\n<h2>\u517c\u5bb9ByName\u5b9a\u4f4d<\/h2>\n<h3>\u4fee\u6539\u6587\u4ef6\uff1adriver.js<\/h3>\n<ul>\n<li>\u82e5\u901a\u8fc7 Node.js\u5b89\u88c5 Appium<\/li>\n<\/ul>\n<pre><code>C:\\Users\\yezhou\\AppData\\Roaming\\npm\\node_modules\\appium\\node_modules\\appium-android-driver\\build\\lib\\driver.js<\/code><\/pre>\n<ul>\n<li>\u82e5\u5b89\u88c5 Appium-Desktop<\/li>\n<\/ul>\n<pre><code>C:\\Users\\yezhou\\AppData\\Local\\appium-desktop\\app-1.5.0\\resources\\app\\node_modules\\appium\\node_modules\\appium-android-driver\\build\\lib\\driver.js<\/code><\/pre>\n<h3>\u4fee\u6539\u5185\u5bb9\uff1athis.locatorStrategies<\/h3>\n<pre><code>this.locatorStrategies = [&#039;xpath&#039;, &#039;id&#039;, &#039;class name&#039;, &#039;accessibility id&#039;, &#039;-android uiautomator&#039;];<\/code><\/pre>\n<p>\u6539\u4e3a\uff1a<\/p>\n<pre><code>this.locatorStrategies = [&#039;xpath&#039;, &#039;id&#039;, &#039;class name&#039;, &#039;accessibility id&#039;, &#039;-android uiautomator&#039;, &#039;name&#039;];<\/code><\/pre>\n<p>\u4fee\u6539\u5b8c\u6210\u4e4b\u540e\uff0c\u4fdd\u5b58\u6587\u4ef6\uff0c\u518d\u6b21\u91cd\u542fAppium\u670d\u52a1(\u91cd\u65b0\u9000\u51fa\u5e76\u542f\u52a8Appium)\uff0c\u5373\u53ef\u7ee7\u7eed\u4f7f\u7528ByName\u5b9a\u4f4d<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u95ee\u9898\u63cf\u8ff0 Appium\u57281.5\u7248\u672c\u4ee5\u540e\u5c31\u4e0d\u518d\u652f\u6301ByName\u5b9a\u4f4d\uff0c\u4f7f\u7528ByName\u62a5\u5f02\u5e38\uff1a org.openq [&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-785","post","type-post","status-publish","format-standard","hentry","category-appium"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/785","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=785"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/785\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=785"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=785"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=785"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}