Automation QA Testing Course Content

APPIUM DEVICE COMMANDS

 Activity:

Start Activity:

Start an Android activity by providing package name and activity name

Sytax:
driver.startActivity(new Activity("com.example", "ActivityName"));

Get Current Activity:

Get the name of the current Android activity

Syntax:

String activity = driver.currentActivity();

Get Current Packkage :

Get the name of the current Android package

String package = driver.getCurrentPackage();


APP:

Install App:

Install the given app onto the device

driver.installApp("/Users/johndoe/path/to/app.apk");

Is App Installed:

Check whether the specified app is installed on the device

driver.isAppInstalled("com.example.AppName");

Launch App:

Launch the app-under-test on the device

driver.launchApp();

BackGround App:

Send the currently running app for this session to the background

driver.runAppInBackground(Duration.ofSeconds(10));

Close App:

Close an app on device

driver.closeApp();


Reset App:

Reset the currently running app for this session

driver.resetApp();

Remove App:

Remove an app from the device

driver.removeApp("com.example.AppName");

Activiate App:

Activate the given app onto the device

For Android:
driver.activateApp('com.apple.Preferences');
For IOS: driver.activateApp('io.appium.android.apis');

Terminate App:

Terminate the given app on the device

For Android:driver.terminateApp('com.apple.Preferences');For IOS:
driver.terminateApp('io.appium.android.apis');

Get App State:

Get the given app status on the device

For Android:driver.queryAppState('com.apple.Preferences');For IOS:
driver.queryAppState('io.appium.android.apis');

Get app strings

Map<String, String> appStrings = driver.getAppStringMap("en", "/path/to/file");

End Test Coverage:

Get test coverage data

driver.endTestCoverage("Intent", "/path");

Get Clipboard:

Get the content of the system clipboard

driver.getClipboard(ClipboardContentType.PLAINTEXT); // get plaintext
driver.getClipboardText();

Set Clipboard:

Set the content of the system clipboard

// base64Content is Base64-encoded content
driver.setClipboard("label", ClipboardContentType.PLAINTEXT, base64Content);
driver.setClipboardText("happy testing");

Emulate Power State

Emulate power state change on the connected emulator.

driver.setPowerAC(PowerACState.OFF);

Emulate power capacity:

Emulate power capacity change on the connected emulator.

driver.setPowerCapacity(100);

Store Files on Device:

Push File:

Place a file onto the device in a particular place

driver.pushFile("/data/local/tmp/foo.bar", new File("/Users/johndoe/files/foo.bar"));

Pull File:

Retrieve a file from the device's file system

byte[] fileBase64 = driver.pullFile("/path/to/device/foo.bar");

Pull Folder:

Retrieve a folder from the device's file system

byte[] folder = driver.pullFolder("/path/to/device/foo.bar");

Shake:

Perform a shake action on the device

driver.shake();

Lock:

Lock the device

driver.lockDevice();

Unlock:

Unlock the device

driver.unlockDevice();

Is Device Locked:

Check whether the device is locked or not

boolean isLocked = driver.isDeviceLocked();

Rotate:

Rotate the device in three dimensions

driver.rotate(new DeviceRotation(10, 10, 10));

Press keycode

Press a particular key on an Android Device

driver.pressKeyCode(AndroidKeyCode.SPACE, AndroidKeyMetastate.META_SHIFT_ON);

See https://developer.android.com/reference/android/view/KeyEvent.html for reference of available Android key code values


Long Press KeyCode:

Press and hold a particular key code on an Android device

driver.longPressKeyCode(AndroidKeyCode.HOME);

Hide keyboard:

Hide soft keyboard

driver.hideKeyboard();


Is Keyboard Shown:
Check whether soft keyboard is shown or not

boolean isKeyboardShown = driver.isKeyboardShown();

NetWork Commands:

Toggle Airplane Mode:

Toggle airplane mode on device

driver.toggleAirplaneMode();

Toggle Data:

Switch the state of data service

driver.toggleData();
Toggle Wifi:

Switch the state of the WiFi service

driver.toggleWifi();

Toggle Location service:

Switch the state of the location service

driver.toggleLocationServices();

Send SMS:

Simulate an SMS message (Emulator only)

driver.sendSMS("555-123-4567", "Hey lol");

GSM Call:

Make GSM call (Emulator only)

driver.makeGsmCall("5551234567", GsmCallActions.CALL);

GSM Signal:

Set GSM signal strength (Emulator only)

driver.setGsmSignalStrength(GsmSignalStrength.GOOD);

GSM Voice:

Set GSM voice state (Emulator only)

driver.setGsmVoice(GsmVoiceState.HOME);

NetWork Speed:

Set network speed (Emulator only)

driver.setNetworkSpeed(NetworkSpeed.LTE);


Get Performance Data:

Returns the information of the system state which is supported to read as like cpu, memory, network traffic, and battery

List<List<Object>> performanceData = driver.getPerformanceData("my.app.package", "cpuinfo", 5);

Get performance Datatypes:

Returns the information types of the system state which is supported to read as like cpu, memory, network traffic, and battery

List<String> performanceTypes = driver.getSupportedPerformanceDataTypes();

Screen Recording:

Start recording screen

driver.startRecordingScreen();
driver.startRecordingScreen(new BaseStartScreenRecordingOptions(....));

Stop Recording screen:
driver.stopRecordingScreen();
driver.stopRecordingScreen(new BaseStopScreenRecordingOptions(....));

Perform Touch ID:

Simulate a touch id event (iOS Simulator only)

driver.performTouchID(false); // Simulates a failed touch
driver.performTouchID(true); // Simulates a passing touch

Toggle TouchID Enrollment:

Toggle the simulator being enrolled to accept touchId (iOS Simulator only)

driver.toggleTouchIDEnrollment(true);

System Commands:

Open Notification

Open Android notifications (Emulator only)

driver.openNotifications();

Get System Bars:

Retrieve visibility and bounds information of the status and navigation bars

Map<String, String> systemBars = driver.getSystemBars();

Get Display Density:

Retrieve display density(dpi) of the Android device

driver.getDeviceDensity();

Authentication:
Finger Print:

Authenticate users by using their finger print scans on supported emulators.

driver.fingerPrint(1);

For Android emulator. Authenticate users by using their finger print scans.

Touch ID by iOS is here.




































No comments:

Post a Comment

Note: Only a member of this blog may post a comment.