Skip to content

Commit

Permalink
Add examples to commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
garg3133 committed Jan 5, 2023
1 parent d94217d commit 6b1505b
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 13 deletions.
15 changes: 15 additions & 0 deletions lib/api/protocol/appium/getCurrentActivity.js
Expand Up @@ -3,6 +3,21 @@ const ProtocolAction = require('../_base-action.js');
/**
* Get the name of the current Android activity.
*
* @example
* module.exports = {
* 'get current activity name': function (app) {
* app
* .appium.getCurrentActivity(function (result) {
* console.log('current android activity is:', result.value);
* });
* },
*
* 'get current activity name with ES6 async/await': async function (app) {
* const activity = await app.appium.getCurrentActivity();
* console.log('current android activity is:', activity);
* }
* };
*
* @syntax .appium.getCurrentActivity([callback])
* @method getCurrentActivity
* @param {function} [callback] Callback function which is called with the result value.
Expand Down
15 changes: 15 additions & 0 deletions lib/api/protocol/appium/getCurrentPackage.js
Expand Up @@ -3,6 +3,21 @@ const ProtocolAction = require('../_base-action.js');
/**
* Get the name of the current Android package.
*
* @example
* module.exports = {
* 'get current package name': function (app) {
* app
* .appium.getCurrentPackage(function (result) {
* console.log('current android package is:', result.value);
* });
* },
*
* 'get current package name with ES6 async/await': async function (app) {
* const packageName = await app.appium.getCurrentPackage();
* console.log('current android package is:', packageName);
* }
* };
*
* @syntax .appium.getCurrentPackage([callback])
* @method getCurrentPackage
* @param {function} [callback] Callback function which is called with the result value.
Expand Down
15 changes: 15 additions & 0 deletions lib/api/protocol/appium/getGeolocation.js
Expand Up @@ -3,6 +3,21 @@ const ProtocolAction = require('../_base-action.js');
/**
* Get the current geolocation of the mobile device.
*
* @example
* module.exports = {
* 'get device geolocation': function (app) {
* app
* .appium.getGeolocation(function (result) {
* console.log('current device geolocation is:', result.value);
* });
* },
*
* 'get device geolocation with ES6 async/await': async function (app) {
* const location = await app.appium.getGeolocation();
* console.log('current device geolocation is:', location);
* }
* };
*
* @syntax .appium.getGeolocation([callback])
* @method getGeolocation
* @param {function} [callback] Callback function which is called with the result value.
Expand Down
15 changes: 15 additions & 0 deletions lib/api/protocol/appium/getOrientation.js
Expand Up @@ -3,6 +3,21 @@ const ProtocolAction = require('../_base-action.js');
/**
* Get the current device orientation.
*
* @example
* module.exports = {
* 'get current device orientation': function (app) {
* app
* .appium.getOrientation(function (result) {
* console.log('current device orientation is:', result.value);
* });
* },
*
* 'get current device orientation with ES6 async/await': async function (app) {
* const orientation = await app.appium.getOrientation();
* console.log('current device orientation is:', orientation);
* }
* };
*
* @syntax .appium.getOrientation([callback])
* @method getOrientation
* @param {function} callback Callback function which is called with the result value.
Expand Down
12 changes: 12 additions & 0 deletions lib/api/protocol/appium/hideKeyboard.js
Expand Up @@ -3,6 +3,18 @@ const ProtocolAction = require('../_base-action.js');
/**
* Hide soft keyboard.
*
* @example
* module.exports = {
* 'hide device soft keyboard': function (app) {
* app
* .appium.hideKeyboard();
* },
*
* 'hide device soft keyboard with ES6 async/await': async function (app) {
* await app.appium.hideKeyboard();
* }
* };
*
* @syntax .appium.hideKeyboard([callback])
* @method hideKeyboard
* @param {function} [callback] Optional callback function to be called when the command finishes.
Expand Down
15 changes: 15 additions & 0 deletions lib/api/protocol/appium/isKeyboardShown.js
Expand Up @@ -3,6 +3,21 @@ const ProtocolAction = require('../_base-action.js');
/**
* Whether or not the soft keyboard is shown.
*
* @example
* module.exports = {
* 'whether keyboard is shown': function (app) {
* app
* .appium.isKeyboardShown(function (result) {
* console.log('result value of whether keyboard is shown:', result.value);
* });
* },
*
* 'whether keyboard is shown with ES6 async/await': async function (app) {
* const result = await app.appium.isKeyboardShown();
* console.log('result value of whether keyboard is shown:', result);
* }
* };
*
* @syntax .appium.isKeyboardShown([callback])
* @method isKeyboardShown
* @param {function} [callback] Callback function which is called with the result value.
Expand Down
12 changes: 12 additions & 0 deletions lib/api/protocol/appium/setGeolocation.js
Expand Up @@ -3,6 +3,18 @@ const ProtocolAction = require('../_base-action.js');
/**
* Set the current geolocation of the mobile device.
*
* @example
* module.exports = {
* 'set geolocation to Tokyo, Japan': function (app) {
* app
* .appium.setGeolocation({latitude: 35.689487, longitude: 139.691706, altitude: 5});
* },
*
* 'set geolocation to Tokyo, Japan with ES6 async/await': async function (app) {
* await app.appium.setGeolocation({latitude: 35.689487, longitude: 139.691706});
* }
* };
*
* @syntax .appium.setGeolocation({latitude, longitude, altitude}, [callback])
* @method setGeolocation
* @param {object} [coordinates] `latitude` and `longitude` are required; `altitude` is optional. All should be of type `number`.
Expand Down
12 changes: 12 additions & 0 deletions lib/api/protocol/appium/setOrientation.js
Expand Up @@ -3,6 +3,18 @@ const ProtocolAction = require('../_base-action.js');
/**
* Set the current device orientation.
*
* @example
* module.exports = {
* 'set orientation to LANDSCAPE': function (app) {
* app
* .appium.setOrientation('LANDSCAPE');
* },
*
* 'set orientation to PORTRAIT with ES6 async/await': async function (app) {
* await app.appium.setOrientation('PORTRAIT');
* }
* };
*
* @syntax .appium.setOrientation(orientation, [callback])
* @method setOrientation
* @param {string} orientation The new device orientation: `LANDSCAPE` or `PORTRAIT`.
Expand Down
24 changes: 13 additions & 11 deletions lib/api/protocol/appium/startActivity.js
Expand Up @@ -7,19 +7,21 @@ const ProtocolAction = require('../_base-action.js');
*
* @example
* module.exports = {
* 'start an android activity': function (client) {
* client.startActivity({
* appPackage: 'com.android.chrome',
* appActivity: 'com.google.android.apps.chrome.Main'
* });
* 'start an android activity': function (app) {
* app
* .appium.startActivity({
* appPackage: 'com.android.chrome',
* appActivity: 'com.google.android.apps.chrome.Main'
* });
* },
*
* 'start the main Android activity and wait for onboarding activity to start': function (client) {
* client.startActivity({
* appPackage: 'org.wikipedia',
* appActivity: 'org.wikipedia.main.MainActivity',
* appWaitActivity: 'org.wikipedia.onboarding.InitialOnboardingActivity'
* });
* 'start the main Android activity and wait for onboarding activity to start': function (app) {
* app
* .appium.startActivity({
* appPackage: 'org.wikipedia',
* appActivity: 'org.wikipedia.main.MainActivity',
* appWaitActivity: 'org.wikipedia.onboarding.InitialOnboardingActivity'
* });
* }
* };
*
Expand Down
2 changes: 0 additions & 2 deletions test/src/api/protocol/testKeyboardInteraction.js
Expand Up @@ -2,8 +2,6 @@ const assert = require('assert');
const Globals = require('../../../lib/globals.js');

describe('Keyboard interaction commands', function() {
// this.timeout(150000);

before(function() {
Globals.protocolBefore();
});
Expand Down

0 comments on commit 6b1505b

Please sign in to comment.