Appium Common API functions

Source: Internet
Author: User
Tags appium

Before you learn to apply a framework, you should look at the overall structure of the framework or the corresponding API functions. This article is not bad: http://blog.sina.com.cn/s/blog_68f262210102vzf9.html, copy it over.

Common API functions get the information class API

(1) Gets the data in the Strings.xml file corresponding to the default system language.

Get_app_string ()

(2) Find a locale corresponding to the string file Strings.xml within the data.

Get_app_string (String language)

(3) Get the current activity, e.g. (. Apidemos)

Current_activity ()

App install and Uninstall Class API

(1) According to Bundleid to determine whether the application has been installed

Is_app_installed (String Bundleid)

(2) Install App,apppath as the application's local path

Install_app (String AppPath)

(3) Uninstalling App.bundleid on Android represents the package name, and there is a dedicated Bundleid number in iOS.

Remove_app (String Bundleid)

(4) Close the application, in fact, just press the home button to put the app in the background

Close_app ()

(5) Start the application

Launch_app ()

(6) Closeapp first and then in Launchapp

Reset_app ()

File Operations Class API

(1) writes a character array to a file in a remote directory in 64-bit format. It can also be understood to push local files to the device.

Push_file (String RemotePath, byte[] base64data)

(2) Pull the files on the device to the local hard drive

Pull_file (String RemotePath)

(3) Pull the folder on the device to the local hard drive, the remote file is the file under/data/local/tmp.

Pull_folder (String RemotePath)

Setting the related class API

(1) Set the phone 's network connection status, you can switch Bluetooth, WiFi, data traffic. The status of each network connection is set through the properties in networkconnectionsetting.

Set_network_connect (networkconnectionsetting connection)

(2) Get the status of the current network

Get_network_connection ()

User Action Class API

(1) iOS hidden keyboard

Hide_keyboard ()

(2) Hide keyboard, can only be used on iOS.

Hide_keyboard (String strategy, String keyName)

(3) Press a key, which key is determined by the key value, the key value is defined in the Androidkeycode class

send_key_event (int key)

(4) Perform a touch action, which is encapsulated by the touchaction.

Perform_touchaction (touchaction touchaction)

(5) Click the center point of the element control, duration*5 seconds after the release, so repeat fingers times.

Tap (int fingers, webelement element, int duration)

(6) Click (x, y) Tap, duration*5 milliseconds after release, so repeat fingers times.

Tap (int fingers, int x, int y, int duration)

(7) slide from (Startx,starty) to (Endx,endy), duration step slip, each step is 5 milliseconds.

Swipe (int startx, int starty, int endx, int endy, int duration)

(8) 2 finger-operated controls, sliding from the diagonal to the center point.

Pinch (webelement el)

(9) with (x, y) as the benchmark, calculated (x,y-100), (x,y+100) two points, and then 2 fingers hold the two points while sliding to (x, y)

pinch (int x, int y)

(10) The exact opposite of the pinch (EL) action. Two fingers the center point of the control slowly slides to the right bottom after the left vertex of the control.

Zoom (Webelement el)

(11) The opposite of pinch (x, y). Two fingers slide from (x, Y) point to (x,y-100) and (x,y+100).

Zoom (int x, int y)

(12) Lock screen after how many seconds to unlock

Lock_screen (int seconds)

(13) Simulate shaking the phone

Shake ()

(14) Scroll to a text property for the specified string of controls

Scroll_to (String text)

(15) Scroll direction from element1 to Element2

Scroll (ELEMENT1,ELEMENT2)

(16) Scroll to a Text property containing the passed-in string control

Scroll_to_exact (String text)

(17) Setting the context

Context (String name)

(18) Available contexts

Get_context_handles ()

(19) Current context

Get_context ()

(20) Set screen horizontal screen or vertical screen

Rotate (screenorientation orientation)

(21) Get the current screen orientation

Get_orientation ()

Get Control class API

(1) Use the properties in UIAutomation in iOS to get controls

Find_element_by_ios_uiautomation (String using)

(2) Same as above, but get multiple controls

Find_elements_by_ios_uiautomation (String using)

(3) Use the properties in Android's Uiautoamtor to get a single control.

Find_element_by_android_uiautomator (String using)

(4) Same as above, but the method gets multiple controls

Find_elements_by_android_uiautomator (String using)

(5) using the accessibility ID to get a single control

Find_element_by_accessibilityid (String using)

(6) Use Accessibility ID to get multiple controls

Find_elements_by_accessibilityid (String using)

Auxiliary classes of Appiumdriver

Mainly for gesture manipulation, such as sliding, long-press, drag and so on. The principle of touchaction is to put a series of actions in a chain, and then pass the chain to the server. After the server accepts the chain, it parses each action and executes it one by one.

Touchaction ()

(1) performing a press operation on the control

Press (Webelement el)

(2) Press operation at a point at coordinates (x, y)

Press (int x, int y)

(3) A press operation is performed on the x-coordinate offset X-units of the upper-left corner of the control El, and y offset Y-units on the left.

Press (webelement el, int x, int y)

(4) Release action, which represents an end sign of the series action.

Release ()

(5) Target El, move from another point to the target

Move_to (Webelement el)

(6) Target at (x, y) point, move from another point to the target

move_to (int x, int y)

(7) Tap on the center of the control

Tap (Webelement el)

(8) Tap at (x, y)

Tap (int x, int y)

(9) with the upper-left corner of the control El as the Datum, the x-axis moves to the right x units, and the y-axis moves down the Y-units. Tap on this point.

Tap (webelement el, int x, int y)

(10) Represents an empty operation, waiting for a period of time

Wait_action ()

(11) Wait ms seconds

wait_action (int ms)

(12) Control long Press

Long_press (Webelement el)

(13) Tap long Press

long_press (int x, int y)

(14) Offset Point Long press

Long_press (webelement el, int x, int y)

(15) Cancel execution of the action

Cancel ()

Appium Common API functions

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.