How to use the appium-support.system.isWindows function in appium-support

To help you get started, we’ve selected a few appium-support examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github appium / node-teen_process / test / subproc-specs.js View on Github external
// transpile:mocha

import B from 'bluebird';
import path from 'path';
import { exec, SubProcess } from '..';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import { getFixture } from './helpers';
import { system } from 'appium-support';


const should = chai.should();
chai.use(chaiAsPromised);

// Windows doesn't understand SIGHUP
const stopSignal = system.isWindows() ? 'SIGTERM' : 'SIGHUP';

describe('SubProcess', function () {
  it('should throw an error if initialized without a command', function () {
    should.throw(() => {
      new SubProcess();
    });
  });
  it('should throw an error if initialized with a bad command', function () {
    should.throw(() => {
      new SubProcess({lol: true});
    });
    should.throw(() => {
      new SubProcess(1);
    });
  });
  it('should throw an error if initialized with bad args', function () {
github appium / appium-xcuitest-driver / lib / commands / file-movement.js View on Github external
commands.getSimFileFullPath = async function getSimFileFullPath (remotePath) {
  let basePath = this.opts.device.getDir();
  let appName = null;

  if (this.opts.app) {
    let appNameRegex = new RegExp(`\\${path.sep}([\\w-]+\\.app)`);
    let appNameMatches = appNameRegex.exec(this.opts.app);
    if (appNameMatches) {
      appName = appNameMatches[1];
    }
  }
  // de-absolutize the path
  if (system.isWindows()) {
    if (remotePath.indexof('://') === 1) {
      remotePath = remotePath.slice(4);
    }
  } else {
    if (remotePath.indexOf('/') === 0) {
      remotePath = remotePath.slice(1);
    }
  }

  if (remotePath.startsWith(appName)) {
    let findPath = basePath;
    if (!this.opts.platformVersion || util.compareVersions(this.opts.platformVersion, '>=', '8.0')) {
      // the .app file appears in /Containers/Data and /Containers/Bundle both. We only want /Bundle
      findPath = path.resolve(basePath, 'Containers', 'Bundle');
    }
    findPath = findPath.replace(/\s/g, '\\ ');
github appium / appium-android-driver / lib / commands / streamscreen.js View on Github external
import { exec, SubProcess } from 'teen_process';
import { checkPortStatus } from 'portscanner';
import http from 'http';
import net from 'net';
import B from 'bluebird';
import { waitForCondition } from 'asyncbox';
import { spawn } from 'child_process';
import { quote } from 'shell-quote';
import url from 'url';

const commands = {};

const RECORDING_INTERVAL_SEC = 5;
const STREAMING_STARTUP_TIMEOUT_MS = 5000;
const GSTREAMER_BINARY = `gst-launch-1.0${system.isWindows() ? '.exe' : ''}`;
const GST_INSPECT_BINARY = `gst-inspect-1.0${system.isWindows() ? '.exe' : ''}`;
const REQUIRED_GST_PLUGINS = {
  avdec_h264: 'gst-libav',
  h264parse: 'gst-plugins-bad',
  jpegenc: 'gst-plugins-good',
  tcpserversink: 'gst-plugins-base',
  multipartmux: 'gst-plugins-good',
};
const SCREENRECORD_BINARY = 'screenrecord';
const GST_TUTORIAL_URL = 'https://gstreamer.freedesktop.org/documentation/installing/index.html';
const DEFAULT_HOST = '127.0.0.1';
const TCP_HOST = '127.0.0.1';
const DEFAULT_PORT = 8093;
const DEFAULT_QUALITY = 70;
const DEFAULT_BITRATE = 4000000; // Mbps
const BOUNDARY_STRING = '--2ae9746887f170b8cf7c271047ce314c';
github appium / appium-uiautomator2-driver / lib / helpers.js View on Github external
helpers.isWriteable = async function isWriteable (filePath) {
  try {
    await fs.access(filePath, fs.W_OK);
    if (system.isWindows()) {
      // On operating systems, where access-control policies may
      // limit access to the file system, `fs.access` does not work
      // as expected. See https://groups.google.com/forum/#!topic/nodejs/qmZtIwDRSYo
      // for more details
      await fs.close(await fs.open(filePath, 'r+'));
    }
    return true;
  } catch (ign) {
    return false;
  }
};
github appium / node-teen_process / test / exec-specs.js View on Github external
it('should respect cwd', async function () {
    let cmd = system.isWindows() ? 'echo.bat' : './echo.sh';
    let echo1 = 'my name is bob';
    let echo2 = 'lol';
    let cwd = path.dirname(getFixture('echo'));
    let {stdout, stderr, code} = await exec(cmd, [echo1, echo2], {cwd});
    stdout.trim().should.equal(echo1);
    stderr.trim().should.equal(echo2);
    code.should.equal(0);
  });
github appium / appium-adb / test / functional / apk-signing-e2e-specs.js View on Github external
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import ADB from '../../lib/adb.js';
import path from 'path';
import { exec } from 'teen_process';
import { system } from 'appium-support';
import { rootDir } from '../../lib/helpers.js';


const selendroidTestApp = path.resolve(rootDir, 'test',
                                       'fixtures', 'selendroid-test-app.apk'),
      contactManagerPath = path.resolve(rootDir, 'test',
                                        'fixtures', 'ContactManager.apk'),
      unsignJar = path.resolve(rootDir, 'jars', 'unsign.jar'),
      tmp = system.isWindows() ? 'C:\\Windows\\Temp' : '/tmp',
      keystorePath = path.resolve(rootDir, 'test',
                                  'fixtures', 'appiumtest.keystore'),
      keyAlias = 'appiumtest';

chai.use(chaiAsPromised);

describe('Apk-signing', function () {
  let adb;
  let unsignApk = async (apk) => { await exec('java', ['-jar', unsignJar, apk]); };

  before(async function () {
    adb = await ADB.createADB();
  });
  it('checkApkCert should return false for unsigned apk', async function () {
    await unsignApk(selendroidTestApp);
    (await adb.checkApkCert(selendroidTestApp, 'io.selendroid.testapp')).should.be.false;
github appium / appium-chromedriver / lib / utils.js View on Github external
function getCurPlatform () {
  return system.isWindows() ? 'win' : (system.isMac() ? 'mac' : 'linux');
}
github appium / appium-adb / lib / tools / apk-signing.js View on Github external
try {
    const args = ['sign',
      '--ks', this.keystorePath,
      '--ks-key-alias', this.keyAlias,
      '--ks-pass', `pass:${this.keystorePassword}`,
      '--key-pass', `pass:${this.keyPassword}`,
      apk];
    await this.executeApksigner(args);
  } catch (err) {
    log.warn(`Cannot use apksigner tool for signing. Defaulting to jarsigner. ` +
      `Original error: ${err.message}`);
    try {
      log.debug('Unsigning apk.');
      await exec(getJavaForOs(), ['-jar', path.resolve(this.helperJarPath, 'unsign.jar'), apk]);
      log.debug('Signing apk.');
      const jarsigner = path.resolve(getJavaHome(), 'bin', `jarsigner${system.isWindows() ? '.exe' : ''}`);
      await exec(jarsigner, ['-sigalg', 'MD5withRSA', '-digestalg', 'SHA1',
        '-keystore', this.keystorePath, '-storepass', this.keystorePassword,
        '-keypass', this.keyPassword, apk, this.keyAlias]);
    } catch (e) {
      throw new Error(`Could not sign with custom certificate. Original error ${e.message}`);
    }
  }
};
github appium / appium-chromedriver / lib / storage-client.js View on Github external
async function getOsInfo () {
  let name = 'linux';
  if (system.isWindows()) {
    name = 'win';
  } else if (system.isMac()) {
    name = 'mac';
  }
  return {
    name,
    arch: await system.arch(),
  };
}