中文字幕第五页-中文字幕第页-中文字幕韩国-中文字幕最新-国产尤物二区三区在线观看-国产尤物福利视频一区二区

[content-description]find_element_by_accessibility_id在android中的詳解

出處:http://testerhome.com/topics/1034

創新互聯建站服務項目包括冷水江網站建設、冷水江網站制作、冷水江網頁制作以及冷水江網絡營銷策劃等。多年來,我們專注于互聯網行業,利用自身積累的技術優勢、行業經驗、深度合作伙伴關系等,向廣大中小型企業、政府機構等提供互聯網行業的解決方案,冷水江網站推廣取得了明顯的社會效益與經濟效益。目前,我們服務的客戶以成都為中心已經輻射到冷水江省份的部分城市,未來相信會繼續擴大服務區域并繼續獲得客戶的支持與信任!

最近 Appium 引入了一個新的 find element 方法:python client 為例

def find_element_by_accessibility_id(self, id):         """Finds an element by accessibility id.          :Args:          - id - a string corresponding to a recursive element search using the          Id/Name that the native Accessibility options utilize          :Usage:             driver.find_element_by_accessibility_id()         """         return self.find_element(by=By.ACCESSIBILITY_ID, value=id) 

文檔里是這樣說的:

Allows for elements to be found using the "Accessibility ID". The methods take a
string representing the accessibility id or label attached to a given element, e.g., for iOS the accessibility identifier and for Android the content-description. Adds the methods
driver.find_element_by_accessibility_id and find_elements_by_accessibility_id.

意思就是可以使用 "Accessibility ID" 來定位元素。對于 iOS 而言就是 accessibility identifier。
對于 Android 就是 content-description。

那什么是 content-description 呢?

官方是這樣說的:

http://developer.android.com/training/accessibility/accessible-app.html
Android has several accessibility-focused features baked into the platform, which make it easy to optimize your application for those with visual or physical disabilities. However, it's not always obvious what the correct optimizations are, or the easiest way to leverage the framework toward this purpose. This lesson shows you how to implement the strategies and platform features that make for a great accessibility-enabled Android application.

這個屬性,主要是為了一些有殘障的人士準備的,方便他們使用程序,所以這個警告前面會有一個[Accessbility]。

舉個例子,比如你有個 ImageView 放一張圖片,這個圖片可能包含很多物體和顏色,一些色弱或者色盲的人,他們可能會分不清這個圖到底畫的什么東西,所以這個時候 contentDescription 就會起作用。比如可能 Android 的一些程序可以用聲音告訴使用者這個圖片畫的是什么,他們讀的就是你 contentDescription 的內容。

這其實和 iOS 的 accessibility identifier 是一樣的。

給一些需要加 contentDescription 的控件加 contentDescription 是一個良好的編程習慣,事實上 , ADT 的 Lint 檢測也會提示你:

[Accessibility] Missing contentDescription attribute on image 

所以給你的控件加上 android:contentDescription="@string/desc, 這樣也可以讓 Appium 來定位。

如何判斷是否加了 android:contentDescription?
  • 第一種方法,看控件的 xml 是否加了 android:contentDescription 屬性。
  • 第二種,看代碼,myView.setContentDescription(desc);
  • 第三種,使用 Hierarchy Viewer

[content-description] find_element_by_accessibility_id 在 android 中的詳解

appium sample-code 里面的 android_complex.py 實際上得用 https://github.com/appium/android-apidemos 這個project 來導出 apk 來測試。

    def test_find_elements(self):         # pause a moment, so xml generation can occur         sleep(2)          els = self.driver.find_elements_by_xpath('//android.widget.TextView')         self.assertEqual('API Demos', els[0].text)          el = self.driver.find_element_by_xpath('//android.widget.TextView[contains(@text, "Animat")]')         self.assertEqual('Animation', el.text)          el = self.driver.find_element_by_accessibility_id("App")         el.click()          els = self.driver.find_elements_by_android_uiautomator('new UiSelector().clickable(true)')         # there are more, but at least 10 visible         self.assertLess(10, len(els))         # the list includes 2 before the main visible elements         self.assertEqual('Action Bar', els[2].text)          els = self.driver.find_elements_by_xpath('//android.widget.TextView')         self.assertLess(10, len(els))         self.assertEqual('Action Bar', els[1].text) 
其他

試用了下 genymotion, 非常好用,用來做 Appium 實驗很棒。

使用模擬器的時候遇到了個問題:

java.lang.IllegalArgumentException: eglChooseConfig failed EGL_NOT_INITIALIZED  03-29 13:21:34.556: E/AndroidRuntime(4458): FATAL EXCEPTION: main 03-29 13:21:34.556: E/AndroidRuntime(4458): Process: com.example.news, PID: 4458 03-29 13:21:34.556: E/AndroidRuntime(4458): java.lang.IllegalArgumentException: eglChooseConfig failed EGL_NOT_INITIALIZED 03-29 13:21:34.556: E/AndroidRuntime(4458): at android.view.HardwareRenderer$GlRenderer.chooseEglConfig(HardwareRenderer.java:1173) 03-29 13:21:34.556: E/AndroidRuntime(4458): at android.view.HardwareRenderer$GlRenderer.loadEglConfig(HardwareRenderer.java:1135) 03-29 13:21:34.556: E/AndroidRuntime(4458): at android.view.HardwareRenderer$GlRenderer.initializeEgl(HardwareRenderer.java:1117) 03-29 13:21:34.556: E/AndroidRuntime(4458): at android.view.HardwareRenderer$GlRenderer.initialize(HardwareRenderer.java:1057) 03-29 13:21:34.556: E/AndroidRuntime(4458): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1550) 03-29 13:21:34.556: E/AndroidRuntime(4458): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000) 03-29 13:21:34.556: E/AndroidRuntime(4458): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670) 03-29 13:21:34.556: E/AndroidRuntime(4458): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761) 03-29 13:21:34.556: E/AndroidRuntime(4458): at android.view.Choreographer.doCallbacks(Choreographer.java:574) 03-29 13:21:34.556: E/AndroidRuntime(4458): at android.view.Choreographer.doFrame(Choreographer.java:544) 03-29 13:21:34.556: E/AndroidRuntime(4458): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747) 03-29 13:21:34.556: E/AndroidRuntime(4458): at android.os.Handler.handleCallback(Handler.java:733) 03-29 13:21:34.556: E/AndroidRuntime(4458): at android.os.Handler.dispatchMessage(Handler.java:95) 03-29 13:21:34.556: E/AndroidRuntime(4458): at android.os.Looper.loop(Looper.java:136) 03-29 13:21:34.556: E/AndroidRuntime(4458): at android.app.ActivityThread.main(ActivityThread.java:5017) 03-29 13:21:34.556: E/AndroidRuntime(4458): at java.lang.reflect.Method.invokeNative(Native Method) 03-29 13:21:34.556: E/AndroidRuntime(4458): at java.lang.reflect.Method.invoke(Method.java:515) 03-29 13:21:34.556: E/AndroidRuntime(4458): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 03-29 13:21:34.556: E/AndroidRuntime(4458): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 03-29 13:21:34.556: E/AndroidRuntime(4458): at dalvik.system.NativeStart.main(Native Method) 

Google了一下,關聯到了opengl es,這個了解過,初步懷疑不是我應用的問題,最后查得居然是模擬器的問題,重啟后解決問題。

分享名稱:[content-description]find_element_by_accessibility_id在android中的詳解
鏈接URL:http://www.2m8n56k.cn/article8/psheop.html

成都網站建設公司_創新互聯,為您提供App設計、云服務器、網站設計、網站導航、搜索引擎優化、企業建站

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:[email protected]。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

手機網站建設
主站蜘蛛池模板: 亚洲国产成人九九综合 | 亚洲日本一区二区三区高清在线 | 国产91综合 | 久久精品久久精品久久 | 一区二区三区国模大胆 | 久揄揄鲁一二三四区高清在线 | 日韩视频在线观看一区二区 | 色射网 | 特黄的欧美毛片 | 色视频在线观看视频 | 在线另类 | 激情丝袜美女视频二区 | 在线观看日韩www视频免费 | 久久久久久亚洲精品 | 香蕉久久综合精品首页 | 亚洲高清一区二区三区 | 国产成人免费视频精品一区二区 | 综合久久久久久中文字幕 | 欧美啊啊啊 | 香蕉视频1024 | a级片在线免费观看 | 黄色在线视频网 | 成人18免费网 | 国产在视频线精品视频二代 | 亚洲午夜综合网 | 午夜综合| 麻豆国产 | 九九99久麻豆精品视传媒 | 国产精品偷伦费观看 | 亚洲一区不卡 | 亚洲经典在线观看 | 91亚洲国产成人久久精品网址 | 日韩手机看片福利精品 | 色综合久久加勒比高清88 | 欧美操人 | 欧美亚洲国产精品久久久久 | 日韩在线精品 | 男人天堂网在线 | 欧洲一级鲁丝片免费 | 中文字幕水野优香在线网在线 | 亚洲免费视频观看 |