Files
appium/docs/en/appium-bindings.md
T
2014-05-01 14:02:52 -07:00

7.9 KiB

Appium Client Libraries

Appium has libraries for:

Language | Source :--|--: Ruby | GitHub Python | GitHub Java | GitHub JavaScript | GitHub PHP | GitHub C# | GitHub

Note that some methods such as endTestCoverage() and complexFind() are not generally useful. Proper coverage support will be added once this issue is resolved. complexFind() will be removed once this issue is resolved. If you want to use them anyway, consult the documentation for the bindings on GitHub.

Lock

Lock the screen.

lock 5
driver.lock(5)
driver.lockScreen(3);
todo: javascript
todo: php
driver.LockDevice(3);

Background app

Send the currently active app to the background.

background_app 5
driver.background_app(5)
driver.runAppInBackground(5);
todo: javascript
todo: php
driver.BackgroundApp(5);

Hide Keyboard (iOS only)

Hide the keyboard on iOS

hide_keyboard
driver.hide_keyboard()
driver.hideKeyboard();
todo: javascript
todo: php
driver.HideKeyboard("Done");

Is installed

Check if an app is installed

is_installed? "com.example.android.apis"
driver.is_app_installed('com.example.android.apis')
driver.isAppInstalled("com.example.android.apis")
todo: javascript
todo: php
driver.IsAppInstalled("com.example.android.apis-");

Install App

Install an app to the device.

install 'path/to/my.apk'
driver.install_app('path/to/my.apk')
driver.installApp("path/to/my.apk")
todo: javascript
todo: php
driver.InstallApp("path/to/my.apk");

Remove App

Remove an app from the device.

remove 'com.example.android.apis'
driver.remove_app('com.example.android.apis')
driver.removeApp("com.example.android.apis")
todo: javascript
todo: php
driver.RemoveApp("com.example.android.apis");

Shake

Simulate the device shaking.

shake
driver.shake()
driver.shake()
todo: javascript
todo: php
driver.ShakeDevice();

Close app

Close the app

close_app
driver.close_app();
driver.closeApp()
todo: javascript
todo: php
driver.CloseApp();

Launch

Launch the app

launch
driver.launch_app()
driver.launchApp()
todo: javascript
todo: php
driver.LaunchApp();

Reset

Reset the app.

reset
driver.reset()
driver.resetApp()
todo: javascript
todo: php
driver.ResetApp();

Available Contexts

List all available contexts

context_array = available_contexts
driver.contexts
driver.getContextHandles()
todo: javascript
todo: php
driver.GetContexts()

Current context

List the current context

context = current_context
driver.current_context
driver.getContext()
todo: javascript
todo: php
driver.GetContext()

Switch to default context

Change the context to the default.

switch_to_default_context
driver.switch_to.context(None)
driver.context();
todo: javascript
todo: php
driver.SetContext();

App Strings

Get the app's strings.

strings = app_strings
driver.app_strings
driver.getAppString();
todo: javascript
todo: php
driver.GetAppStrings();

Key Event

Send a key event to the device.

key_event 176
driver.keyevent(176)
driver.sendKeyEvent(AndroidKeyCode.HOME);
todo: javascript
todo: php
driver.KeyEvent("176");

Current Activity

Android only. Get the current activity.

current_activity
driver.current_activity
driver.currentActivity();
todo: javascript
todo: php
driver.GetCurrentActivity();

TouchAction / MultiTouchAction

An API for generating touch actions. This section of the documentation will be expanded upon soon.

touch_action = Appium::TouchAction.new
element  = find_element :name, 'Buttons, Various uses of UIButton'
touch_action.press(element: element, x: 10, y: 10).perform
action = TouchAction(driver)
action.press(element=el, x=10, y=10).release().perform()
TouchAction action = new TouchAction(driver)
.press(mapview, 10, 10)
.release().
perform();
todo: javascript
todo: php
var touchAction1 = new TouchActions(this);
touchAction1.Down(10, 10).Up(10, 10);

var multiTouchAction = new MultiTouchAction(this);
multiTouchAction.Add(touchAction1);

PerformMultiTouchAction(multiTouchAction);

Swipe

Simulate a user swipe.

swipe start_x: 75, start_y: 500, end_x: 75, end_y: 0, duration: 0.8
driver.swipe(75, 500, 75, 0, 0.8)
driver.swipe(startx=75, starty=500, endx=75, endy=0, duration=800)
todo: javascript
todo: php
todo: c#

Pinch

Pinch the screen.

pinch 75
driver.pinch(element=el)
driver.pinch(element);
todo: javascript
todo: php
driver.Pinch(25, 25)

Zoom

Zoom the screen.

zoom 200
driver.zoom(element=el)
driver.zoom(element);
todo: javascript
todo: php
driver.Zoom(100, 200);

Pull file

Pulls a file from the device.

pull_file 'Library/AddressBook/AddressBook.sqlitedb'
driver.pull_file('Library/AddressBook/AddressBook.sqlitedb')
driver.pullFile("Library/AddressBook/AddressBook.sqlitedb");
todo: javascript
todo: php
driver.PullFile("Library/AddressBook/AddressBook.sqlitedb");

Push File

Pushes a file to the device.

data = "some data for the file"
path = "/data/local/tmp/file.txt"
push_file path, data
data = "some data for the file"
path = "/data/local/tmp/file.txt"
driver.push_file(path, data.encode('base64'))
byte[] data = Base64.encodeBase64("some data for the file".getBytes());
String path = "/data/local/tmp/file.txt";
driver.pushFile(path, data)
todo: javascript
todo: php
driver.PushFile("/data/local/tmp/file.txt", "some data for the file");

Appium Desktop Apps

Appium's desktop app supports OS X and Windows.