How to use this.settings.getSettings method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

moderator.js

Source:moderator.js Github

copy

Full Screen

...97    // Generate create conference IQ98    var elem = $iq({to: this.getFocusComponent(), type: 'set'});99    // Session Id used for authentication100    var sessionId = localStorage.getItem('sessionId');101    var machineUID = this.settings.getSettings().uid;102    logger.info(103            "Session ID: " + sessionId + " machine UID: " + machineUID);104    elem.c('conference', {105        xmlns: 'http://jitsi.org/protocol/focus',106        room: this.roomName,107        'machine-uid': machineUID108    });109    if (sessionId) {110        elem.attrs({ 'session-id': sessionId});111    }112    if (this.xmppService.options.hosts.bridge !== undefined) {113        elem.c(114            'property', {115                name: 'bridge',116                value: this.xmppService.options.hosts.bridge117            }).up();118    }119    // Tell the focus we have Jigasi configured120    if (this.xmppService.options.hosts.call_control !== undefined) {121        elem.c(122            'property', {123                name: 'call_control',124                value:  this.xmppService.options.hosts.call_control125            }).up();126    }127    if (this.xmppService.options.channelLastN !== undefined) {128        elem.c(129            'property', {130                name: 'channelLastN',131                value: this.xmppService.options.channelLastN132            }).up();133    }134    if (this.xmppService.options.adaptiveLastN !== undefined) {135        elem.c(136            'property', {137                name: 'adaptiveLastN',138                value: this.xmppService.options.adaptiveLastN139            }).up();140    }141    if (this.xmppService.options.adaptiveSimulcast !== undefined) {142        elem.c(143            'property', {144                name: 'adaptiveSimulcast',145                value: this.xmppService.options.adaptiveSimulcast146            }).up();147    }148    if (this.xmppService.options.openSctp !== undefined) {149        elem.c(150            'property', {151                name: 'openSctp',152                value: this.xmppService.options.openSctp153            }).up();154    }155    if (this.xmppService.options.startAudioMuted !== undefined)156    {157        elem.c(158            'property', {159                name: 'startAudioMuted',160                value: this.xmppService.options.startAudioMuted161            }).up();162    }163    if (this.xmppService.options.startVideoMuted !== undefined)164    {165        elem.c(166            'property', {167                name: 'startVideoMuted',168                value: this.xmppService.options.startVideoMuted169            }).up();170    }171    elem.c(172        'property', {173            name: 'simulcastMode',174            value: 'rewriting'175        }).up();176    elem.up();177    return elem;178};179Moderator.prototype.parseSessionId =  function (resultIq) {180    var sessionId = $(resultIq).find('conference').attr('session-id');181    if (sessionId) {182        logger.info('Received sessionId:  ' + sessionId);183        localStorage.setItem('sessionId', sessionId);184    }185};186Moderator.prototype.parseConfigOptions =  function (resultIq) {187    this.setFocusUserJid(188        $(resultIq).find('conference').attr('focusjid'));189    var authenticationEnabled190        = $(resultIq).find(191            '>conference>property' +192            '[name=\'authentication\'][value=\'true\']').length > 0;193    logger.info("Authentication enabled: " + authenticationEnabled);194    this.externalAuthEnabled = $(resultIq).find(195            '>conference>property' +196            '[name=\'externalAuth\'][value=\'true\']').length > 0;197    console.info(198        'External authentication enabled: ' + this.externalAuthEnabled);199    if (!this.externalAuthEnabled) {200        // We expect to receive sessionId in 'internal' authentication mode201        this.parseSessionId(resultIq);202    }203    var authIdentity = $(resultIq).find('>conference').attr('identity');204    this.eventEmitter.emit(AuthenticationEvents.IDENTITY_UPDATED,205        authenticationEnabled, authIdentity);206    // Check if focus has auto-detected Jigasi component(this will be also207    // included if we have passed our host from the config)208    if ($(resultIq).find(209        '>conference>property' +210        '[name=\'sipGatewayEnabled\'][value=\'true\']').length) {211        this.sipGatewayEnabled = true;212    }213    logger.info("Sip gateway enabled:  " + this.sipGatewayEnabled);214};215// FIXME =  we need to show the fact that we're waiting for the focus216// to the user(or that focus is not available)217Moderator.prototype.allocateConferenceFocus =  function (callback) {218    // Try to use focus user JID from the config219    220    this.setFocusUserJid(this.xmppService.options.focusUserJid);221    // Send create conference IQ222    var iq = this.createConferenceIq();223    var self = this;224    this.connection.sendIQ(225        iq,226        function (result) {227            // Setup config options228            self.parseConfigOptions(result);229            if ('true' === $(result).find('conference').attr('ready')) {230                // Reset both timers231                self.getNextTimeout(true);232                self.getNextErrorTimeout(true);233                // Exec callback234                callback();235            } else {236                var waitMs = self.getNextTimeout();237                logger.info("Waiting for the focus... " + waitMs);238                // Reset error timeout239                self.getNextErrorTimeout(true);240                window.setTimeout(241                    function () {242                        self.allocateConferenceFocus(callback);243                    }, waitMs);244            }245        },246        function (error) {247            // Invalid session ? remove and try again248            // without session ID to get a new one249            var invalidSession250                = $(error).find('>error>session-invalid').length;251            if (invalidSession) {252                logger.info("Session expired! - removing");253                localStorage.removeItem("sessionId");254            }255            if ($(error).find('>error>graceful-shutdown').length) {256                self.eventEmitter.emit(XMPPEvents.GRACEFUL_SHUTDOWN);257                return;258            }259            // Check for error returned by the reservation system260            var reservationErr = $(error).find('>error>reservation-error');261            if (reservationErr.length) {262                // Trigger error event263                var errorCode = reservationErr.attr('error-code');264                var errorMsg;265                if ($(error).find('>error>text')) {266                    errorMsg = $(error).find('>error>text').text();267                }268                self.eventEmitter.emit(269                    XMPPEvents.RESERVATION_ERROR, errorCode, errorMsg);270                return;271            }272            // Not authorized to create new room273            if ($(error).find('>error>not-authorized').length) {274                logger.warn("Unauthorized to start the conference", error);275                var toDomain276                    = Strophe.getDomainFromJid(error.getAttribute('to'));277                if (toDomain !==278                    this.xmppService.options.hosts.anonymousdomain) {279                    //FIXME:  "is external" should come either from280                    // the focus or config.js281                    self.externalAuthEnabled = true;282                }283                self.eventEmitter.emit(284                    XMPPEvents.AUTHENTICATION_REQUIRED,285                    function () {286                        self.allocateConferenceFocus(287                            callback);288                    });289                return;290            }291            var waitMs = self.getNextErrorTimeout();292            logger.error("Focus error, retry after " + waitMs, error);293            // Show message294            var focusComponent = self.getFocusComponent();295            var retrySec = waitMs / 1000;296            //FIXME:  message is duplicated ?297            // Do not show in case of session invalid298            // which means just a retry299            if (!invalidSession) {300                self.eventEmitter.emit(XMPPEvents.FOCUS_DISCONNECTED,301                    focusComponent, retrySec);302            }303            // Reset response timeout304            self.getNextTimeout(true);305            window.setTimeout(306                function () {307                    self.allocateConferenceFocus(callback);308                }, waitMs);309        }310    );311};312Moderator.prototype.getLoginUrl =  function (urlCallback) {313    var iq = $iq({to: this.getFocusComponent(), type: 'get'});314    iq.c('login-url', {315        xmlns: 'http://jitsi.org/protocol/focus',316        room: this.roomName,317        'machine-uid': this.settings.getSettings().uid318    });319    this.connection.sendIQ(320        iq,321        function (result) {322            var url = $(result).find('login-url').attr('url');323            url = url = decodeURIComponent(url);324            if (url) {325                logger.info("Got auth url: " + url);326                urlCallback(url);327            } else {328                logger.error(329                    "Failed to get auth url from the focus", result);330            }331        },332        function (error) {333            logger.error("Get auth url error", error);334        }335    );336};337Moderator.prototype.getPopupLoginUrl =  function (urlCallback) {338    var iq = $iq({to: this.getFocusComponent(), type: 'get'});339    iq.c('login-url', {340        xmlns: 'http://jitsi.org/protocol/focus',341        room: this.roomName,342        'machine-uid': this.settings.getSettings().uid,343        popup: true344    });345    this.connection.sendIQ(346        iq,347        function (result) {348            var url = $(result).find('login-url').attr('url');349            url = url = decodeURIComponent(url);350            if (url) {351                logger.info("Got POPUP auth url:  " + url);352                urlCallback(url);353            } else {354                logger.error(355                    "Failed to get POPUP auth url from the focus", result);356            }...

Full Screen

Full Screen

session.js

Source:session.js Github

copy

Full Screen

1import Syncano from '@syncano/core'2import format from 'chalk'3import path from 'path'4import mkdirp from 'mkdirp'5import Promise from 'bluebird'6import logger from './debug'7import pjson from '../../package.json'8import getSettings from '../settings'9import genUniqueName from './unique-instance'10import Socket from './sockets'11import Init from './init'12import Hosting from './hosting'13import Plugins from './plugins'14import { echo } from './print-tools'15const { debug } = logger('utils-session')16export class Session {17  constructor () {18    this.settings = null19    this.projectPath = null20    this.project = null21    this.userId = null22    this.majorVersion = pjson.version.split('.')[0]23    this.location = process.env.SYNCANO_PROJECT_INSTANCE_LOCATION || 'us1' // default location24    this.locations = {25      'us1': 'api.syncano.io',26      'eu1': 'api-eu1.syncano.io'27    }28  }29  getHost () {30    return process.env.SYNCANO_HOST || this.locations[this.location]31  }32  async setLocation (location) {33    if (this.location !== location) {34      this.location = location35      await this.createConnection()36    }37  }38  getLocation () {39    return this.location40  }41  getFullName () {42    return `${this.userFirstName} ${this.userLastName}`43  }44  getSpaceHost () {45    if (this.getHost() === 'api.syncano.rocks') {46      return `${this.project.instance}.syncano.link`47    }48    if (this.project && this.project.instance) {49      return `${this.project.instance}.${this.location}.syncano.space`50    }51  }52  getInitInstance () {53    return new Init(this)54  }55  getPluginsInstance () {56    return new Plugins(this)57  }58  getBaseURL () {59    return `https://${this.getHost()}`60  }61  getDistPath () {62    let distPath = '.dist'63    if (this.projectPath) {64      distPath = path.join(this.projectPath, '.dist')65    }66    mkdirp.sync(distPath)67    return distPath68  }69  getBuildPath () {70    const buildPath = path.join(this.projectPath, '.build')71    mkdirp.sync(buildPath)72    return buildPath73  }74  getAnonymousConnection () {75    return new Syncano({76      meta: {77        'api_host': this.getHost()78      }79    })80  }81  async createConnection () {82    debug('createConnection')83    if (this.settings.account.authenticated()) {84      debug('user is authenticated')85      this.connection = new Syncano({86        accountKey: this.settings.account.getAuthKey(),87        meta: {88          'api_host': this.getHost()89        }90      })91      if (this.project && this.project.instance) {92        this.connection = new Syncano({93          instanceName: this.project.instance,94          accountKey: this.settings.account.getAuthKey(),95          meta: {96            'api_host': this.getHost()97          }98        })99      }100    } else {101      this.connection = this.getAnonymousConnection()102    }103    try {104      debug('get user details')105      const details = await this.connection.account.get(this.settings.account.getAuthKey())106      this.userId = details.id107      this.userEmail = details.email108      this.userFirstName = details.first_name109      this.userLastName = details.last_name110    } catch (err) {}111  }112  async deleteInstance (name) {113    return this.connection.instance.delete(name)114  }115  async createInstance (name = genUniqueName()) {116    return this.connection.instance.create({ name })117  }118  async getInstance (instanceName) {119    const instanceNameToGet = instanceName || (this.project && this.project.instance)120    return this.connection.instance.get(instanceNameToGet)121  }122  async getInstances () {123    return this.connection.instance.list()124  }125  async checkAuth () {126    const userDetails = await this.connection.Account.getUserDetails()127    return new Promise((resolve, reject) => {128      if (userDetails) {129        return resolve(userDetails)130      }131      reject(new Error('No such user!'))132    })133  }134  static findProjectPath () {135    return process.cwd()136  }137  async load () {138    debug('load')139    // Checking all folders up140    try {141      const projectPath = await Session.findProjectPath()142      debug('Searching for syncano.yml', projectPath)143      this.projectPath = projectPath144      this.settings = getSettings(projectPath)145      this.project = this.settings.account.getProject(this.projectPath)146      if (this.project && this.project.location) {147        await this.setLocation(this.project.location)148      }149    } catch (err) {150      this.settings = getSettings()151    }152    await this.createConnection()153    return this154  }155  loadPlugins (program, context) {156    new Plugins(this).load(program, context)157  }158  isAuthenticated () {159    if (!this.settings.account.authenticated()) {160      echo()161      echo(4)('You are not logged in!')162      echo(4)(`Type ${format.cyan('npx s login')} for login to your account.`)163      echo()164      process.exit(1)165    }166  }167  isAuthenticatedToInit () {168    if (!this.settings.account.authenticated()) {169      echo()170      echo(4)(format.red('You have to be a logged in to be able an initialize a new project!'))171      echo()172    }173  }174  async checkConnection (instanceName) {175    let instance176    try {177      instance = await this.getInstance(instanceName)178    } catch (err) {179      debug(err.message)180      if (err.message === 'Not found.') {181        echo()182        echo(4)(`Instance ${format.cyan(instanceName || this.project.instance)} was not found on your account!`)183        echo()184        if (instanceName) return process.exit()185        echo(4)(`Type ${format.cyan('npx s attach')} to choose one of the existing instances.`)186        echo()187      }188      process.exit(1)189    }190    return instance191  }192  hasProject () {193    this.hasProjectPath()194    if (!this.project) {195      echo()196      echo(4)('You have to attach this project to one of your instances.')197      echo(4)(`Try ${format.cyan('npx s attach')}.`)198      echo()199      process.exit()200    }201  }202  hasProjectPath () {203    if (!this.projectPath) {204      echo()205      echo(4)(`I don't see any project here. Try ${format.cyan('npx s init')}.`)206      echo()207      process.exit()208    }209  }210  hasSocket (socketName) { // eslint-disable-line class-methods-use-this211    const socket = new Socket(socketName)212    if (!socket.existLocally) {213      echo()214      echo(4)('File socket.yml was not found in a project directory!')215      echo(4)(`Check your directory or try ${format.cyan('npx s create')} to create a new Socket.`)216      echo()217      process.exit()218    }219  }220  notAlreadyInitialized () {221    if (this.projectPath && this.project) {222      echo()223      echo(4)('Project in this folder is already initiated!')224      echo(4)(`It is attached to ${format.cyan(this.project.instance)} Syncano instance.`)225      echo()226      process.exit()227    }228  }229  async deployProject () { // eslint-disable-line class-methods-use-this230    const hostings = await Hosting.list()231    return Promise.all(hostings.map((hosting) => hosting.deploy()))232  }233}...

Full Screen

Full Screen

ExportSettings.js

Source:ExportSettings.js Github

copy

Full Screen

1/**2 * Wheel, copyright (c) 2020 - present by Arno van der Vegt3 * Distributed under an MIT license: https://arnovandervegt.github.io/wheel/license.txt4**/5const DOMNode    = require('../../../../lib/dom').DOMNode;6const dispatcher = require('../../../../lib/dispatcher').dispatcher;7const TextArea   = require('../../../../lib/components/input/TextArea').TextArea;8const Button     = require('../../../../lib/components/input/Button').Button;9exports.ExportSettings = class extends DOMNode {10    constructor(opts) {11        super(opts);12        this._ui              = opts.ui;13        this._uiId            = opts.uiId;14        this._settings        = opts.settings;15        this._tabIndex        = opts.tabIndex;16        this.initDOM(opts.parentNode);17        this.load();18    }19    initDOM(parentNode) {20        this.create(21            parentNode,22            {23                className: 'text-property-setting',24                children: [25                    {26                        type:      'h3',27                        className: 'no-select flt max-w text-property-row',28                        innerHTML: 'Settings'29                    },30                    {31                        ref:  this.setRef('value'),32                        type: TextArea,33                        ui:   this._ui,34                        uiId: this._uiId35                    },36                    {37                        className: 'flt max-w text-property-row',38                        children: [39                            {40                                type:     Button,41                                color:    'blue',42                                ui:       this._ui,43                                uiId:     this._uiId,44                                tabIndex: 32,45                                value:    'Load settings from text above',46                                onClick:  this.onLoadSettings.bind(this)47                            }48                        ]49                    }50                ]51            }52        );53    }54    load() {55        this._refs.value.setValue(JSON.stringify(this._settings.getSettings(), null, '    '));56    }57    onLoadSettings() {58        try {59            dispatcher.dispatch('Settings.Load.New', JSON.parse(this._refs.value.getValue()));60        } catch (error) {61        }62    }...

Full Screen

Full Screen

shallow-settings_test.js

Source:shallow-settings_test.js Github

copy

Full Screen

...19      }20    });21  });22  it('can retrieve the common settings', function () {23    var actualSettings = this.settings.getSettings({env: 'common'});24    expect(actualSettings).to.deep.equal({25      ENV: 'common',26      hello: 'world',27      nested: {28        key: 'value'29      }30    });31  });32  it('can perform shallow overrides', function () {33    var actualSettings = this.settings.getSettings({env: 'shallow-override'});34    expect(actualSettings).to.deep.equal({35      ENV: 'shallow-override',36      hello: 'moon',37      nested: {38        key: 'value'39      }40    });41  });42  it('can perform deep overrides', function () {43    var actualSettings = this.settings.getSettings({env: 'deep-override'});44    expect(actualSettings).to.deep.equal({45      ENV: 'deep-override',46      hello: 'world',47      nested: {48        hai: 'there'49      }50    });51  });52});53describe('A set of lazy loaded `shallow-settings`', function () {54  before(function () {55    var that = this;56    this.settings = new Settings({57      common: {},58      'lazy-loaded': {59        lazy: Settings.lazy(function () {60          that.loaded = true;61          return 'hey';62        })63      }64    });65  });66  describe('retrieving common settings', function () {67    before(function () {68      this.actualSettings = this.settings.getSettings({env: 'common'});69    });70    it('does not include lazy settings', function () {71      expect(this.actualSettings).to.deep.equal({ENV: 'common'});72    });73    it('does not process lazy settings', function () {74      expect(this.loaded).to.equal(undefined);75    });76  });77  describe('retrieving lazy loaded settings', function () {78    before(function () {79      this.actualSettings = this.settings.getSettings({env: 'lazy-loaded'});80    });81    it('runs lazy settings', function () {82      expect(this.actualSettings).to.deep.equal({83        ENV: 'lazy-loaded',84        lazy: 'hey'85      });86    });87  });...

Full Screen

Full Screen

main.service.js

Source:main.service.js Github

copy

Full Screen

1class MainService {2    constructor($http, $mdDialog, utilService) {3        this.$http = $http;4        this.$mdDialog = $mdDialog;5        this.utilService = utilService6        this.modalUrl = "static/html/modals/";7        this.settings = {};8    }910    getSettings() {11        return this.utilService.httpGet("/users/settings", (data) => {12            this.settings = data;13            return data;14        });15    };1617    getSettingsPromise() {18        return this.$http.get("/users/settings")19    };2021    updateSettings() {22        this.utilService.httpGet("/users/settings", (data) => {23            this.settings = data;24            let storage = window.localStorage;25            storage.setItem('settings', JSON.stringify(this.settings))26            // let userStr = storage.getItem("RssReaderUser");27            // let user = JSON.parse(userStr);28            // user.Settings = response.data;29        });30    };3132    auth(username, password) {33        return this.$http.post('/auth', { username: username, password: password });34    };3536    registration(username, password) {37        return this.$http.post('/registration', { username: username, password: password });38    };3940    openModal(template, ctrl, modalData) {41        return this.$mdDialog.show({42            controller: ctrl,43            templateUrl: this.modalUrl + template,44            parent: angular.element(document.body),45            clickOutsideToClose: true,46            locals: {47                modalData: angular.copy(modalData)48            }49        });50    };5152    setSettings(settings) {53        this.settings = settings54        this.utilService.httpPut('/users/settings', settings);55    };56}5758MainService.$inject = ["$http", "$mdDialog", "utilService"];59
...

Full Screen

Full Screen

SettingsStore.js

Source:SettingsStore.js Github

copy

Full Screen

1import dispatcher from '../dispatcher/appDispatcher.js';2import SettingsActions from  '../actions/SettingsActions';3import SettingsSource from  '../sources/SettingsSource';4class SettingsStore {5  constructor() {6    this.settings = {};7    this.errorMessage = null;8    this.bindListeners({9      handleUpdateSettings: SettingsActions.UPDATE_SETTINGS,10      handleGetAllSettings: SettingsActions.GET_ALL_SETTINGS,11      handleSettingsFailed: SettingsActions.SETTINGS_FAILED12    });13    this.exportPublicMethods({14      getOption: this.getOption,15      getData: this.getSettings16    });17  }18  handleSettingsFailed(errorMessage) {19    this.errorMessage = errorMessage;20  }21  handleUpdateSettings(settings) {22    this.settings = settings;23    this.errorMessage = null;24  }25  handleGetAllSettings() {26    this.settings = {};27  }28  getSettings() {29    var { settings } = this.getState();30    return settings;31  }32  // useless method33  getOption(key) {34    var { settings } = this.getState();35    return settings[key];36  }37}...

Full Screen

Full Screen

settings.js

Source:settings.js Github

copy

Full Screen

...9commands.getSettings = async function getSettings () {10  if (!this.settings) {11    log.errorAndThrow('Cannot get settings; settings object not found');12  }13  return await this.settings.getSettings();14};...

Full Screen

Full Screen

header.controller.js

Source:header.controller.js Github

copy

Full Screen

1angular.module('tf2stadium.controllers')2  .controller('LobbyListHeaderController', LobbyListHeaderController);3/** @ngInject */4function LobbyListHeaderController($scope, Settings) {5  var vm = this;6  Settings.getSettings(function (settings) {7    vm.filtersEnabled = settings.filtersEnabled;8  });9  vm.updateFilters = function () {10    Settings.set('filtersEnabled', vm.filtersEnabled);11  };...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Appium Xcuitest Driver automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Sign up Free
_

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful