Appium經常使用API(二)

接前面的經常使用API(一),本文接着介紹以下:html

1.press_keycodeandroid

press_keycode(self, keycode, metastate=None):app

 Sends a keycode to the device. Android only. Possible keycodes can be found in http://developer.android.com/reference/android/view/KeyEvent.htmlcode

    發送按鍵碼(安卓僅有),模擬點擊相應銨鍵,按鍵碼能夠上網址中找到orm

    :Args:htm

     - keycode - the keycode to be sent to the deviceci

     - metastate - meta information about the keycode being sentelement

  Usage:rem

 driver.press_ keycode(‘4’)      #按返回鍵get

2.long_press_keycode

long_press_keycode(self, keycode, metastate=None):

 Sends a long press of keycode to the device. Android only.

    發送一個長按的按鍵碼(長按某鍵)

    :Args:

     - keycode - the keycode to be sent to the device

     - metastate - meta information about the keycode being sent

  Usage:

  driver.long_press_keycode(‘4’)    #長按返回鍵

3.is_app_installed

is_app_installed(self, bundle_id):

 Checks whether the application specified by `bundle_id` is installed on the device.

    檢查app是否有安裝

 返回 True or False

    :Args:

     - bundle_id - the id of the application to query

  Usage:

 driver.is_app_installed(「com.xxxx」)     #app包名

4.install_app

install_app(self, app_path):

 Install the application found at `app_path` on the device.

    安裝app,app_path爲安裝包路徑

    :Args:

    - app_path - the local or remote path to the application to install

  Usage:

 driver.install_app(app_path)

5.remove_app

remove_app(self, app_id):

 Remove the specified application from the device.

    刪除app

    :Args:

    - app_id - the application id to be removed

 Usage:

    driver.remove_app(「com.xxx.」)   #app包名

6.open_notifications

open_notifications(self):

 Open notification shade in Android (API Level 18 and above)

 打系統通知欄(僅支持API 18 以上的安卓系統)

 Usage:

 driver.open_notifications()    ##打開系統通知欄

7.launch_app

launch_app(self):

 Start on the device the application specified in the desired capabilities.

 啓動app

 Usage:

 driver.launch_app()     #啓動應用,通常與close_app配合使用

8.close_app

close_app(self):

 Stop the running application, specified in the desired capabilities, on the device.

 關閉app

 Usage:

 driver.close_app()    #關閉應用,此方法並不是真正的關閉應用,至關於按home鍵將應用置於後臺,能夠經過launch_app()再次啓動

9.is_selected

is_selected(self):

 Returns whether the element is selected.

    Can be used to check if a checkbox or radio button is selected.

 能夠用來檢查一個複選框或單選按鈕被選中,返回元素是否選擇 True of False

 Usage:

 element.is_slected()

10.is_enabled

is_enabled(self):

 Returns whether the element is enabled.

    返回元素是否可用True of False

 Usage:

 element.is_enabled()

11.is_displayed

is_displayed(self):

 Whether the element is visible to a user.   

 判斷此元素用戶是否可見。返回True of False

 Usage:

 driver.element.is_displayed()   #判斷是否顯示

12.close

close(self):

    Closes the current window.

    關閉當前窗口

    Usage:

    driver.close()

相關文章
相關標籤/搜索