command_definitions.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. const command_definition_1 = require("./command_definition");
  4. exports.getNetworkConnection = new command_definition_1.CommandDefinition('getNetworkConnection', [], 'GET', '/network_connection');
  5. exports.setNetworkConnection = new command_definition_1.CommandDefinition('setNetworkConnection', ['type'], 'POST', '/network_connection', (args) => {
  6. if (typeof args[0] == 'boolean') {
  7. // Transform into bitmask
  8. return [(args[0] ? 1 : 0) + (args[1] ? 2 : 0) + (args[2] ? 4 : 0)];
  9. }
  10. else {
  11. return args;
  12. }
  13. });
  14. exports.toggleAirplaneMode = new command_definition_1.CommandDefinition('toggleAirplaneMode', [], 'POST', 'appium/device/toggle_airplane_mode');
  15. exports.toggleWiFi = new command_definition_1.CommandDefinition('toggleWiFi', [], 'POST', 'appium/device/toggle_wifi');
  16. exports.toggleData = new command_definition_1.CommandDefinition('toggleData', [], 'POST', 'appium/device/toggle_data');
  17. exports.toggleLocationServices = new command_definition_1.CommandDefinition('toggleLocationServices', [], 'POST', 'appium/device/toggle_location_services');
  18. exports.getGeolocation = new command_definition_1.CommandDefinition('getGeolocation', [], 'GET', '/location');
  19. exports.setGeolocation = new command_definition_1.CommandDefinition('setGeolocation', ['location'], 'POST', '/location', (args) => {
  20. return [{ latitude: args[0] || 0, longitude: args[1] || 0, altitude: args[2] || 0 }];
  21. });
  22. exports.getCurrentDeviceActivity = new command_definition_1.CommandDefinition('getCurrentDeviceActivity', [], 'GET', '/appium/device/current_activity');
  23. exports.startDeviceActivity = new command_definition_1.CommandDefinition('startDeviceActivity', ['appPackage', 'appActivity', 'appWaitPackage', 'appWaitActivity'], 'POST', '/appium/device/start_activity', (args) => {
  24. if (args.length == 2) {
  25. // No appWait, default parameters to undefined
  26. args[2] = undefined;
  27. args[3] = undefined;
  28. }
  29. if (args.length == 4) {
  30. return args;
  31. }
  32. else {
  33. throw new RangeError('startDeviceActivity requires 2 or 4 arguments, got ' + args.length);
  34. }
  35. });
  36. exports.getAppiumSettings = new command_definition_1.CommandDefinition('getAppiumSettings', [], 'GET', '/appium/settings');
  37. exports.setAppiumSettings = new command_definition_1.CommandDefinition('setAppiumSettings', ['settings'], 'POST', '/appium/settings');
  38. exports.getCurrentContext = new command_definition_1.CommandDefinition('getCurrentContext', [], 'GET', '/context');
  39. exports.selectContext = new command_definition_1.CommandDefinition('selectContext', ['name'], 'POST', '/context');
  40. exports.getScreenOrientation = new command_definition_1.CommandDefinition('getScreenOrientation', [], 'GET', '/orientation');
  41. exports.setScreenOrientation = new command_definition_1.CommandDefinition('setScreenOrientation', ['orientation'], 'POST', '/orientation', (args) => {
  42. let orientation = (args[0] || '').toUpperCase();
  43. if ((orientation != 'PORTRAIT') && (orientation != 'LANDSCAPE')) {
  44. throw new TypeError('Invalid orientation "' + args[0] + '"');
  45. }
  46. args[0] = orientation;
  47. return args;
  48. });
  49. exports.isDeviceLocked = new command_definition_1.CommandDefinition('isDeviceLocked', [], 'POST', '/appium/device/is_locked');
  50. exports.lockDevice = new command_definition_1.CommandDefinition('lockDevice', ['seconds'], 'POST', '/appium/device/lock', (args) => {
  51. args[0] = args[0] || 0;
  52. return args;
  53. });
  54. exports.unlockDevice = new command_definition_1.CommandDefinition('unlockDevice', [], 'POST', '/appium/device/unlock');
  55. exports.installApp = new command_definition_1.CommandDefinition('installApp', ['appPath'], 'POST', '/appium/device/install_app');
  56. exports.isAppInstalled = new command_definition_1.CommandDefinition('isAppInstalled', ['bundleId'], 'POST', 'appium/device/app_installed');
  57. exports.removeApp = new command_definition_1.CommandDefinition('removeApp', ['appId'], 'POST', '/appium/device/remove_app');
  58. exports.pullFileFromDevice = new command_definition_1.CommandDefinition('pullFileFromDevice', ['path'], 'POST', '/appium/device/pull_file');
  59. exports.pullFolderFromDevice = new command_definition_1.CommandDefinition('pullFolderFromDevice', ['path'], 'POST', '/appium/device/pull_folder');
  60. exports.pushFileToDevice = new command_definition_1.CommandDefinition('pushFileToDevice', ['path', 'data'], 'POST', 'appium/device/push_file');
  61. exports.listContexts = new command_definition_1.CommandDefinition('listContexts', [], 'GET', '/contexts');
  62. exports.uploadFile = new command_definition_1.CommandDefinition('uploadFile', ['file'], 'POST', '/file');
  63. exports.switchToParentFrame = new command_definition_1.CommandDefinition('switchToParentFrame', [], 'POST', '/frame/parent');
  64. exports.fullscreen = new command_definition_1.CommandDefinition('fullscreen', [], 'POST', '/window/fullscreen');
  65. exports.sendAppToBackground = new command_definition_1.CommandDefinition('sendAppToBackground', ['seconds'], 'POST', '/appium/app/background', (args) => {
  66. args[0] = args[0] || 0;
  67. return args;
  68. });
  69. exports.closeApp = new command_definition_1.CommandDefinition('closeApp', [], 'POST', '/appium/app/close');
  70. exports.getAppStrings = new command_definition_1.CommandDefinition('getAppStrings', ['language'], 'POST', 'appium/app/strings', (args) => {
  71. args[0] = args.length ? args[0] : undefined; // Default to `undefined`
  72. return args;
  73. });
  74. exports.launchSession = new command_definition_1.CommandDefinition('launchSession', [], 'POST', '/appium/app/launch');
  75. exports.resetApp = new command_definition_1.CommandDefinition('resetApp', [], 'POST', '/appium/app/reset');
  76. exports.hideSoftKeyboard = new command_definition_1.CommandDefinition('hideSoftKeyboard', ['strategy', 'key'], 'POST', '/appium/device/hide_keyboard', (args) => {
  77. switch (args[0] || 'default') {
  78. case 'default':
  79. args[0] = 'default';
  80. case 'swipeDown':
  81. case 'tapOut':
  82. case 'tapOutside':
  83. if (args.length == 1) {
  84. args[1] = undefined; // Default to `undefined`
  85. }
  86. case 'press':
  87. case 'pressKey':
  88. return args;
  89. default:
  90. throw new RangeError('Invalid keyboard hiding strategy "' + args[0] + '"');
  91. }
  92. });
  93. exports.getDeviceTime = new command_definition_1.CommandDefinition('getDeviceTime', [], 'GET', '/appium/device/system_time');
  94. exports.openDeviceNotifications = new command_definition_1.CommandDefinition('openDeviceNotifications', [], 'POST', '/appium/device/open_notifications');
  95. exports.rotationGesture = new command_definition_1.CommandDefinition('rotationGesture', ['x', 'y', 'duration', 'rotation', 'touchCount'], 'POST', '/appium/device/rotate', (args) => {
  96. args[0] = args[0] || 0;
  97. args[1] = args[1] || 0;
  98. args[2] = args[2] === undefined ? 1 : args[2];
  99. args[3] = args[3] === undefined ? 180 : args[3];
  100. args[4] = args[4] == undefined ? 2 : args[4];
  101. return args;
  102. });
  103. exports.shakeDevice = new command_definition_1.CommandDefinition('shakeDevice', [], 'POST', 'appium/device/shake');
  104. exports.sendChromiumCommand = new command_definition_1.CommandDefinition('sendChromiumCommand', ['cmd', 'params'], 'POST', '/chromium/send_command');
  105. exports.sendChromiumCommandAndGetResult = new command_definition_1.CommandDefinition('sendChromiumCommandAndGetResult', ['cmd', 'params'], 'POST', '/chromium/send_command_and_get_result');
  106. //# sourceMappingURL=command_definitions.js.map