async launch (sessionId) {
    if (this.webDriverAgentUrl) {
      log.info(`Using provided WebdriverAgent at '${this.webDriverAgentUrl}'`);
      this.url = this.webDriverAgentUrl;
      this.setupProxies(sessionId);
      return await this.getStatus();
    }

    log.info('Launching WebDriverAgent on the device');

    this.setupProxies(sessionId);

    if (!this.useXctestrunFile && !await fs.exists(this.agentPath)) {
      throw new Error(`Trying to use WebDriverAgent project at '${this.agentPath}' but the ` +
                      'file does not exist');
    }

    // useXctestrunFile and usePrebuiltWDA use existing dependencies
    // It depends on user side
    if (this.idb || this.useXctestrunFile || (this.derivedDataPath && this.usePrebuiltWDA)) {
      log.info('Skipped WDA project cleanup according to the provided capabilities');
    } else {
      const synchronizationKey = path.normalize(this.bootstrapPath);
      await SHARED_RESOURCES_GUARD.acquire(synchronizationKey,
        async () => await this._cleanupProjectIfFresh());
    }

    // We need to provide WDA local port, because it might be occupied
    await resetTestProcesses(this.device.udid, !this.isRealDevice);

    if (this.idb) {
      return await this.startWithIDB();
    }

    await this.xcodebuild.init(this.noSessionProxy);

    // Start the xcodebuild process
    if (this.prebuildWDA) {
      await this.xcodebuild.prebuild();
    }
    return await this.xcodebuild.start();
  }
/**
   * Return current running WDA's status like below after launching WDA
   * {
   *   "state": "success",
   *   "os": {
   *     "name": "iOS",
   *     "version": "11.4",
   *     "sdkVersion": "11.3"
   *   },
   *   "ios": {
   *     "simulatorVersion": "11.4",
   *     "ip": "172.254.99.34"
   *   },
   *   "build": {
   *     "time": "Jun 24 2018 17:08:21",
   *     "productBundleIdentifier": "com.facebook.WebDriverAgentRunner"
   *   }
   * }
   *
   * @param {string} sessionId Launch WDA and establish the session with this sessionId
   * @return {?object} State Object
   * @throws {Error} If there was invalid response code or body
   */


@param {string} sessionId Launch WDA and establish the session with this sessionId
@return {?object} State Object
@throws {Error} If there was invalid response code or body
@param { string } sessionId Launch WDA and establish the session with this sessionId @return { ?object } State Object @throws { Error } If there was invalid response code or body
async launch (sessionId) {
    if (this.webDriverAgentUrl) {
      log.info(`Using provided WebdriverAgent at '${this.webDriverAgentUrl}'`);
      this.url = this.webDriverAgentUrl;
      this.setupProxies(sessionId);
      return await this.getStatus();
    }
    log.info('Launching WebDriverAgent on the device');
    this.setupProxies(sessionId);
    if (!this.useXctestrunFile && !await fs.exists(this.agentPath)) {
      throw new Error(`Trying to use WebDriverAgent project at '${this.agentPath}' but the ` +
                      'file does not exist');
    }
    if (this.idb || this.useXctestrunFile || (this.derivedDataPath && this.usePrebuiltWDA)) {
      log.info('Skipped WDA project cleanup according to the provided capabilities');
    } else {
      const synchronizationKey = path.normalize(this.bootstrapPath);
      await SHARED_RESOURCES_GUARD.acquire(synchronizationKey,
        async () => await this._cleanupProjectIfFresh());
    }
    await resetTestProcesses(this.device.udid, !this.isRealDevice);
    if (this.idb) {
      return await this.startWithIDB();
    }
    await this.xcodebuild.init(this.noSessionProxy);
    if (this.prebuildWDA) {
      await this.xcodebuild.prebuild();
    }
    return await this.xcodebuild.start();
  }
async launch ( sessionId ) { if ( this . webDriverAgentUrl ) { log . info ( ` ${ this . webDriverAgentUrl } ` ) ; this . url = this . webDriverAgentUrl ; this . setupProxies ( sessionId ) ; return await this . getStatus ( ) ; } log . info ( 'Launching WebDriverAgent on the device' ) ; this . setupProxies ( sessionId ) ; if ( ! this . useXctestrunFile && ! await fs . exists ( this . agentPath ) ) { throw new Error ( ` ${ this . agentPath } ` + 'file does not exist' ) ; } if ( this . idb || this . useXctestrunFile || ( this . derivedDataPath && this . usePrebuiltWDA ) ) { log . info ( 'Skipped WDA project cleanup according to the provided capabilities' ) ; } else { const synchronizationKey = path . normalize ( this . bootstrapPath ) ; await SHARED_RESOURCES_GUARD . acquire ( synchronizationKey , async ( ) => await this . _cleanupProjectIfFresh ( ) ) ; } await resetTestProcesses ( this . device . udid , ! this . isRealDevice ) ; if ( this . idb ) { return await this . startWithIDB ( ) ; } await this . xcodebuild . init ( this . noSessionProxy ) ; if ( this . prebuildWDA ) { await this . xcodebuild . prebuild ( ) ; } return await this . xcodebuild . start ( ) ; }
Return current running WDA's status like below after launching WDA
 {
   "state": "success",
   "os": {
     "name": "iOS",
     "version": "11.4",
     "sdkVersion": "11.3"
   },
   "ios": {
     "simulatorVersion": "11.4",
     "ip": "172.254.99.34"
   },
   "build": {
     "time": "Jun 24 2018 17:08:21",
     "productBundleIdentifier": "com.facebook.WebDriverAgentRunner"
   }
 }
Return current running WDA ' s status like below after launching WDA { " state " : " success " " os " : { " name " : " iOS " " version " : " 11 . 4 " " sdkVersion " : " 11 . 3 " } " ios " : { " simulatorVersion " : " 11 . 4 " " ip " : " 172 . 254 . 99 . 34 " } " build " : { " time " : " Jun 24 2018 17 : 08 : 21 " " productBundleIdentifier " : " com . facebook . WebDriverAgentRunner " } }
// useXctestrunFile and usePrebuiltWDA use existing dependencies // It depends on user side // We need to provide WDA local port, because it might be occupied // Start the xcodebuild process