appnium定位+操作方式(python)

來源:互聯網
上載者:User

標籤:driver   height   活動   res   base64   ase   auto   script   classname   

 

1.定位:
A.利用 Android UIAutomator定位:
例: driver.find_element_by_android_uiautomator(‘new 
UiSelector().description("Animation")‘)

B.利用Accessibility ID定位
例:
driver.find_element_by_accessibility_id(‘Animation‘)

C. 利用 id定位:
例: driver.find_element_by_id(‘login’)

D 利用 Xpath定位
例: driver.find_element_by_xpath(xpath)

E:利用name定位
例: driver.find_element_by_name(‘Touch Paint‘)

F:利用 classname 定位
例: driver.find_elements_by_class_name(‘listView‘)

2.鎖定螢幕 driver.lock(5)
3.把當前應用放到後台去 driver.background_app(5)
4. 長按住鍵盤 driver.long_press_keycode(keycode)

5.檢查應用是否已經安裝 driver.is_app_installed(‘com.example.android.apis‘)

6.安裝應用到裝置中去 driver.install_app(‘path/to/my.apk‘)

7.從裝置中刪除一個應 driver.remove_app(‘com.example.android.apis‘)

8.類比裝置搖晃 driver.shake()
9.關閉應用 driver.close_app()
10.啟動應用 driver.launch_app()
11.應用重設 driver.reset()
12.列出所有的可用上下文 driver.contexts
13.列出當前上下文 driver.current_context

14.將環境切換到預設上下文 driver.switch_to.context(None)

15. driver.get_screenshot_as_file(filename)

16.發送一個按鍵事件給裝置 driver.keyevent(176)

17.Android only 得到當前 activity driver.current_activity

19.類比使用者滑動 driver.swipe(75, 500, 75, 0, 1000)

20.在 0% 到 100% 內雙指縮放屏 driver.pinch(element=el)

21.放大螢幕 在 100% 以上放大屏 driver.zoom(element=el)

22.從裝置中拉出檔案 driver.pull_file(‘Library/AddressBook/AddressBook.sqlitedb‘)

23.推送檔案到裝置中去data = "some data for the file"  

path = "/data/local/tmp/file.txt"

 driver.push_file(path,  data.encode(‘base64‘))

24.隱藏鍵盤 driver.hide_keyboard()
25.安裝 appdriver.install_app(path)
26.卸載 appdriver.remove_app(app_id)
27.列印當前 activitydriver.current_activity
28.震動 driver.shake()
29.開啟通知欄(api 18 以上)driver.open_notifications()
30.擷取網路 driver.network_connection
31.擷取手機螢幕解析度 driver.get_window_size()
32.設定螢幕解析度 driver.set_window_size(width,height)
33.擷取當前座標位置 driver.get_window_position()
34.開關定位服務 driver.toggle_location_services()
35.開關定位服務 driver.toggle_location_services()
36. 關閉 close
37.退出關閉所有串連 quit

38. 擷取當前頁面源 page_source
39.擷取當前頁面網頁 current_url
4.擷取元素左上方座標 location
41 擷取元素大小 size
42. 元素是否可用 is_enabled()返回 True of False
43.元素是否可選擇 is_selected()
44.清除 clear
45.點擊 click

46.設定經緯度 用法 driver.set_location(緯度,經度,高度)
47.返回當前IME包名 active_ime_engine
48.關閉當前IME deactivate_ime_engine
49.啟用IME activate_ime_engine
用法
driver.activate_ime_engine(“com.android.inputmethod.latin/
.LatinIME”)

50. s_ime_active

檢查裝置是否有IME服務活動。返回真/假。 安卓 用法
print(driver.is_ime_active())

appnium定位+操作方式(python)

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.