Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Android activity appium commands.
- Loading branch information
Showing
4 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const ProtocolAction = require('./_base-action.js'); | ||
|
||
/** | ||
* Get the name of the current Android activity. | ||
* | ||
* More info here: https://appium.io/docs/en/commands/device/activity/current-activity/ | ||
* | ||
* @syntax browser.getCurrentActivity([callback]) | ||
* @method getCurrentActivity | ||
* @param {function} [callback] Callback function which is called with the result value. | ||
* @returns {string} Name of the current activity. | ||
* @see getCurrentPackage | ||
* @see startActivity | ||
* @api protocol.mobile | ||
*/ | ||
module.exports = class Session extends ProtocolAction { | ||
command(callback) { | ||
return this.transportActions.getCurrentActivity(callback); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const ProtocolAction = require('./_base-action.js'); | ||
|
||
/** | ||
* Get the name of the current Android package. | ||
* | ||
* More info here: https://appium.io/docs/en/commands/device/activity/current-package/ | ||
* | ||
* @syntax browser.getCurrentPackage([callback]) | ||
* @method getCurrentPackage | ||
* @param {function} [callback] Callback function which is called with the result value. | ||
* @returns {string} Name of the current package. | ||
* @see getCurrentActivity | ||
* @see startActivity | ||
* @api protocol.mobile | ||
*/ | ||
module.exports = class Session extends ProtocolAction { | ||
command(callback) { | ||
return this.transportActions.getCurrentPackage(callback); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const ProtocolAction = require('./_base-action.js'); | ||
|
||
/** | ||
* Start an Android activity by providing package name, activity name and other optional parameters. | ||
* | ||
* More info here: https://appium.io/docs/en/commands/device/activity/start-activity/ | ||
* | ||
* @example | ||
* module.exports = { | ||
* 'start an android activity': function (browser) { | ||
* browser.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 (browser) { | ||
* browser.startActivity({ | ||
* appPackage: 'org.wikipedia', | ||
* appActivity: 'org.wikipedia.main.MainActivity', | ||
* appWaitActivity: 'org.wikipedia.onboarding.InitialOnboardingActivity' | ||
* }); | ||
* } | ||
* }; | ||
* | ||
* @syntax browser.startActivity(opts, [callback]) | ||
* @method startActivity | ||
* @param {string} opts Options to start the activity with. `appPackage` and `appActivity` are required, [others](https://appium.io/docs/en/commands/device/activity/start-activity/#json-parameters) are optional. | ||
* @param {function} [callback] Optional callback function to be called when the command finishes. | ||
* @see getCurrentActivity | ||
* @see getCurrentPackage | ||
* @api protocol.mobile | ||
*/ | ||
module.exports = class Session extends ProtocolAction { | ||
command(opts, callback) { | ||
if (!('appPackage' in opts && 'appActivity' in opts)) { | ||
throw new Error('Please provide both appPackage and appActivity options while using startActivity.'); | ||
} | ||
|
||
return this.transportActions.startActivity(opts, callback); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters