How to use this.onSettingsUpdate method in Appium Base Driver

Best JavaScript code snippet using appium-base-driver

index.js

Source:index.js Github

copy

Full Screen

1import React, { Component } from 'react';2import PropTypes from 'prop-types';3import { connect } from 'react-redux';4import { bindActionCreators } from 'redux';5import Matrix from 'matrix-slicer';6import {7    activatePopup,8    setMatrix,9    setVictoryChainsLength,10} from '../../../actions/';11import Button from '../Button';12import InputNumber from '../InputNumber';13import Popup from '../Popup';14import './styles.css';15import '../Hidden/styles.css';16/**17 * @class18 * @extends Component19 */20class Settings extends Component {21    static propTypes = {22        game: PropTypes.shape({23            matrix: PropTypes.array,24            victoryChainsLength: PropTypes.number,25        }).isRequired,26        activatePopup: PropTypes.func.isRequired,27        setMatrix: PropTypes.func.isRequired,28        setVictoryChainsLength: PropTypes.func.isRequired,29        startNewGame: PropTypes.func.isRequired,30    };31    constructor() {32        super();33        this.defaultTitle = 'Main Menu';34        this.state = {35            maxVictoryChainsLength: 3,36            title: this.defaultTitle,37            wasChanged: false,38        };39        this.onSettingsUpdate = this.onSettingsUpdate.bind(this);40        this.handleStartNewGame = this.handleStartNewGame.bind(this);41        this.handleOpenSettings = this.handleOpenSettings.bind(this);42        this.handleResume = this.handleResume.bind(this);43        this.handleApply = this.handleApply.bind(this);44        this.handleOpenAbout = this.handleOpenAbout.bind(this);45        this.backToMenu = this.backToMenu.bind(this);46    }47    componentWillMount() {48        this.ghButtonScript = document.createElement('script'); // eslint-disable-line no-undef49        this.ghButtonScript.src = 'https://buttons.github.io/buttons.js';50        document.body.appendChild(this.ghButtonScript); // eslint-disable-line no-undef51    }52    componentWillUnmount() {53        document.body.removeChild(this.ghButtonScript); // eslint-disable-line no-undef54    }55    /**56     * Callback function for inputs update.57     */58    onSettingsUpdate() {59        if (60            this.$inputWidth.state.value !== this.props.game.matrix[0].length ||61            this.$inputHeight.state.value !== this.props.game.matrix.length ||62            this.$inputVictoryChainsLength.state.value !== this.props.game.victoryChainsLength63        ) {64            this.setState({65                wasChanged: true,66            });67        } else {68            this.setState({69                wasChanged: false,70            });71        }72        this.setState({73            maxVictoryChainsLength: Math.min(this.$inputWidth.state.value, this.$inputHeight.state.value),74        });75    }76    /**77     * Start a new game.78     */79    handleStartNewGame() {80        this.props.startNewGame();81        this.props.activatePopup(false);82    }83    /**84     * Display settings form85     */86    handleOpenSettings() {87        this.setState({88            title: 'Game settings',89        });90        this.$items.classList.add('hidden');91        this.$settingsForm.classList.remove('hidden');92    }93    /**94     * Resume a game.95     */96    handleResume() {97        this.props.activatePopup(false);98    }99    /**100     * Apply new settings and start a new game.101     *102     * @param {object} e103     */104    handleApply(event) {105        event.preventDefault();106        const matrix = new Matrix(this.$inputWidth.state.value, this.$inputHeight.state.value);107        this.props.setMatrix(matrix.get());108        this.props.setVictoryChainsLength(this.$inputVictoryChainsLength.state.value);109        this.props.startNewGame();110        this.props.activatePopup(false);111    }112    /**113     * Display information about the game.114     */115    handleOpenAbout() {116        this.setState({117            title: 'About the Game',118        });119        this.$items.classList.add('hidden');120        this.$about.classList.remove('hidden');121    }122    /**123     * Back to menu.124     */125    backToMenu() {126        this.setState({127            title: this.defaultTitle,128        });129        this.$about.classList.add('hidden');130        this.$items.classList.remove('hidden');131    }132    render() {133        const width = this.props.game.matrix[0].length;134        const height = this.props.game.matrix.length;135        const victoryChainsLength = this.props.game.victoryChainsLength;136        return (137            <Popup title={this.state.title}>138                <ul className="settings__items" ref={(c) => (this.$items = c)}>139                    <li className="settings__item">140                        <button141                            className="settings__item-button"142                            type="button"143                            onClick={this.handleStartNewGame}144                        >145                            Start a New Game146                        </button>147                    </li>148                    <li className="settings__item">149                        <button150                            className="settings__item-button"151                            type="button"152                            onClick={this.handleOpenSettings}153                        >154                            Settings for a New Game155                        </button>156                    </li>157                    <li className="settings__item">158                        <button159                            className="settings__item-button"160                            type="button"161                            onClick={this.handleOpenAbout}162                        >163                            About the Game164                        </button>165                    </li>166                    <li className="settings__item">167                        <button168                            className="settings__item-button"169                            type="button"170                            onClick={this.handleResume}171                        >172                            Resume Game173                        </button>174                    </li>175                </ul>176                <form className="settings__form hidden" ref={(c) => (this.$settingsForm = c)}>177                    <div className="settings__field">178                        <label htmlFor="boardWidth" className="settings__label">Width:</label>179                        <InputNumber180                            id="boardWidth"181                            maxValue={10}182                            minValue={3}183                            name="width"184                            onChange={this.onSettingsUpdate}185                            ref={(c) => (this.$inputWidth = c)}186                            value={width}187                        />188                    </div>189                    <div className="settings__field">190                        <label htmlFor="boardHeight" className="settings__label">Height:</label>191                        <InputNumber192                            id="boardHeight"193                            maxValue={10}194                            minValue={3}195                            name="height"196                            ref={(c) => (this.$inputHeight = c)}197                            value={height}198                            onChange={this.onSettingsUpdate}199                        />200                    </div>201                    <div className="settings__field">202                        <label htmlFor="chainToWin" className="settings__label">203                            Length<span className="settings__sub-label"> of Chain to win</span>:204                        </label>205                        <InputNumber206                            id="chainToWin"207                            maxValue={this.state.maxVictoryChainsLength}208                            minValue={3}209                            name="victoryChainsLength"210                            ref={(c) => (this.$inputVictoryChainsLength = c)}211                            value={victoryChainsLength}212                            onChange={this.onSettingsUpdate}213                        />214                    </div>215                    <div className="settings__controls-field">216                        <Button217                            type="reset"218                            onClick={this.handleResume}219                        >220                            Resume221                        </Button>222                        <Button223                            disabled={!this.state.wasChanged}224                            type="submit"225                            onClick={this.handleApply}226                        >227                            Apply228                        </Button>229                    </div>230                </form>231                <div232                    className="settings__about hidden"233                    ref={(c) => (this.$about = c)}234                >235                    <p>The Game was created using React+Redux.</p>236                    <p>Please create an issue on GitHub<br /> to report a bug.</p>237                    <p>238                        <a239                            aria-label="@ahtohbi4 on GitHub"240                            className="github-button"241                            data-style="mega"242                            href="https://github.com/ahtohbi4/tic-tac-toe"243                        >244                            @ahtohbi4245                        </a>246                    </p>247                    <Button248                        type="button"249                        onClick={this.backToMenu}250                    >251                        Back252                    </Button>253                </div>254            </Popup>255        );256    }257}258export default connect(259    (state) => ({260        game: state.game,261    }),262    (dispatch) => ({263        activatePopup: bindActionCreators(activatePopup, dispatch),264        setMatrix: bindActionCreators(setMatrix, dispatch),265        setVictoryChainsLength: bindActionCreators(setVictoryChainsLength, dispatch),266    }),...

Full Screen

Full Screen

MachineTaskStreamSheetMonitor.js

Source:MachineTaskStreamSheetMonitor.js Github

copy

Full Screen

1/********************************************************************************2 * Copyright (c) 2020 Cedalo AG3 *4 * This program and the accompanying materials are made available under the5 * terms of the Eclipse Public License 2.0 which is available at6 * http://www.eclipse.org/legal/epl-2.0.7 *8 * SPDX-License-Identifier: EPL-2.09 *10 ********************************************************************************/11const MachineEvents = require('@cedalo/protocols').MachineServerMessagingProtocol.EVENTS;12const MachineTaskMessagingClient = require('./MachineTaskMessagingClient');13const RedisInboxAdapter = require('./RedisInboxAdapter');14const {15	cellDescriptor,16	cellDescriptorAsObject,17	getSheetCellsAsList,18	isNotRunning,19	publishIf,20	reduceSheetCells21} = require('./utils');22class MachineTaskStreamSheetMonitor {23	constructor(streamsheet) {24		this.streamsheet = streamsheet;25		this.inboxAdapter = new RedisInboxAdapter(streamsheet.inbox, this.streamsheet.machine.scope.id);26		// update interval:27		this.stepUpdateInterval = -1;28		this._steps = 0;29		// event callbacks:30		this.onClear = this.onClear.bind(this);31		this.onEvent = this.onEvent.bind(this);32		this.onMessagePut = this.onMessagePut.bind(this);33		this.onMessagePop = this.onMessagePop.bind(this);34		this.onMessageAttached = this.onMessageAttached.bind(this);35		this.onMessageDetached = this.onMessageDetached.bind(this);36		this.onStreamSheetStep = this.onStreamSheetStep.bind(this);37		this.onSheetUpdate = this.onSheetUpdate.bind(this);38		this.onSheetCellRangeChange = this.onSheetCellRangeChange.bind(this);39		this.onSettingsUpdate = this.onSettingsUpdate.bind(this);40		this.onSheetCellsUpdate = this.onSheetCellsUpdate.bind(this);41		this.streamsheet.inbox.on('clear', this.onClear);42		this.streamsheet.inbox.on('message_put', this.onMessagePut);43		this.streamsheet.inbox.on('message_pop', this.onMessagePop);44		this.streamsheet.on('event', this.onEvent);45		this.streamsheet.on('sheet_update', this.onSheetUpdate);46		this.streamsheet.on('sheet_cellrange_change', this.onSheetCellRangeChange);47		this.streamsheet.on('sheet_cells_update', this.onSheetCellsUpdate);48		this.streamsheet.on('settings_update', this.onSettingsUpdate);49		this.streamsheet.on('message_attached', this.onMessageAttached);50		this.streamsheet.on('message_detached', this.onMessageDetached);51		this.streamsheet.inbox.on('subscribe', this.inboxAdapter.subscribe);52		this.streamsheet.inbox.on('unsubscribe', this.inboxAdapter.unsubscribe);53		this.streamsheet.inbox.on('clear', this.inboxAdapter.clear);54		this.streamsheet.inbox.on('message_put', this.inboxAdapter.put);55		this.streamsheet.inbox.on('message_pop', this.inboxAdapter.pop);56		// DL-2293: only publish if machine is stopped or paused...57		this.publishEvent = publishIf(isNotRunning(streamsheet.machine));58	}59	dispose() {60		const { streamsheet, inboxAdapter } = this;61		this.streamsheet.inbox.off('subscribe', this.inboxAdapter.subscribe);62		this.streamsheet.inbox.off('unsubscribe', this.inboxAdapter.unsubscribe);63		this.streamsheet.inbox.off('clear', this.inboxAdapter.clear);64		this.streamsheet.inbox.off('message_put', this.inboxAdapter.put);65		this.streamsheet.inbox.off('message_pop', this.inboxAdapter.pop);66		inboxAdapter.dispose();67		streamsheet.inbox.off('clear', this.onClear);68		streamsheet.inbox.off('message_put', this.onMessagePut);69		streamsheet.inbox.off('message_pop', this.onMessagePop);70		streamsheet.off('event', this.onEvent);71		streamsheet.off('sheet_update', this.onSheetUpdate);72		streamsheet.off('sheet_cellrange_change', this.onSheetCellRangeChange);73		streamsheet.off('sheet_cells_update', this.onSheetCellsUpdate);74		streamsheet.off('settings_update', this.onSettingsUpdate);75		streamsheet.off('message_attached', this.onMessageAttached);76		streamsheet.off('message_detached', this.onMessageDetached);77	}78	update(props = {}) {79		this.stepUpdateInterval = props.stepUpdateInterval || this.stepUpdateInterval;80	}81	onClear() {82		const { streamsheet } = this;83		const event = {84			type: MachineEvents.MESSAGE_BOX_CLEAR,85			src: 'inbox',86			srcId: streamsheet.inbox.id,87			machineId: streamsheet.machine.id,88			streamsheetId: streamsheet.id89		};90		this.publishEvent(event);91	}92	onEvent(ev) {93		const { streamsheet } = this;94		const event = {95			...ev,96			type: ev.type,97			src: 'streamsheet',98			srcId: streamsheet.id,99			srcName: streamsheet.name,100			machineId: streamsheet.machine.id101		};102		MachineTaskMessagingClient.publishEvent(event);103	}104	onMessagePut(message) {105		const { streamsheet } = this;106		const messageInInbox = message && streamsheet.inbox.messages.filter((m) => message.id === m.id)[0];107		const event = {108			type: MachineEvents.MESSAGE_PUT,109			src: 'inbox',110			srcId: streamsheet.inbox.id,111			machineId: streamsheet.machine.id,112			machineState: streamsheet.machine.state,113			streamsheetId: streamsheet.id,114			totalSize: this.inboxAdapter.totalSize,115			message: messageInInbox116		};117		this.publishEvent(event);118	}119	onMessagePop(message) {120		const { streamsheet } = this;121		const event = {122			type: MachineEvents.MESSAGE_POP,123			src: 'inbox',124			srcId: streamsheet.inbox.id,125			machineId: streamsheet.machine.id,126			machineState: streamsheet.machine.state,127			streamsheetId: streamsheet.id,128			totalSize: this.inboxAdapter.totalSize,129			message130		};131		this.publishEvent(event);132	}133	onMessageAttached(messageId) {134		const { streamsheet } = this;135		const event = {136			type: MachineEvents.STREAMSHEET_MESSAGE_ATTACHED,137			src: 'streamsheet',138			srcId: streamsheet.id,139			machineId: streamsheet.machine.id,140			machineState: streamsheet.machine.state,141			messageId142		};143		this.publishEvent(event);144	}145	onMessageDetached(messageId) {146		const { streamsheet } = this;147		const event = {148			type: MachineEvents.STREAMSHEET_MESSAGE_DETACHED,149			src: 'streamsheet',150			srcId: streamsheet.id,151			machineId: streamsheet.machine.id,152			machineState: streamsheet.machine.state,153			messageId154		};155		this.publishEvent(event);156	}157	onSheetCellsUpdate(cells) {158		const { streamsheet } = this;159		const event = {160			type: MachineEvents.SHEET_CELLS_UPDATE_EVENT,161			src: 'streamsheet',162			srcId: streamsheet.id,163			machineId: streamsheet.machine.id,164			cells: cells165				.map(({ cell, col, row }) => cellDescriptorAsObject(cell, row, col))166				.reduce((acc, descrObj) => ({ ...acc, ...descrObj }))167		};168		MachineTaskMessagingClient.publishEvent(event);169	}170	onSheetUpdate(cell, index) {171		const { streamsheet } = this;172		const { sheet } = streamsheet;173		const event = {174			name: streamsheet.name,175			type: MachineEvents.SHEET_UPDATE_EVENT,176			src: 'streamsheet',177			srcId: streamsheet.id,178			machineId: streamsheet.machine.id,179			cell: cell && index ? cellDescriptor(cell, index) : undefined,180			sheet: {181				cells: getSheetCellsAsList(sheet),182				// serverside-formats:183				properties: sheet.properties.toJSON(),184				namedCells: sheet.namedCells.getDescriptors(),185				shapes: sheet.getShapes().toJSON(),186			}187		};188		MachineTaskMessagingClient.publishEvent(event);189	}190	onSheetCellRangeChange() {191		const { streamsheet } = this;192		const cells = reduceSheetCells(streamsheet.sheet, (allCells, cell) => {193			const { value, formula, type } = cell;194			allCells[cell.reference] = { value, type, formula };195			return allCells;196		},{});197		const event = {198			type: MachineEvents.SHEET_CELLRANGE_CHANGE_EVENT,199			src: 'streamsheet',200			srcId: streamsheet.id,201			machineId: streamsheet.machine.id,202			cells,203			shapes: streamsheet.sheet.getShapes().toJSON(),204		};205		MachineTaskMessagingClient.publishEvent(event);206	}207	onSettingsUpdate(settings) {208		const { streamsheet } = this;209		const event = {210			type: MachineEvents.STREAMSHEET_STREAM_UPDATED,211			src: 'streamsheet',212			srcId: streamsheet.id,213			machineId: streamsheet.machine.id,214			settings215		};216		MachineTaskMessagingClient.publishEvent(event);217	}218	onStreamSheetStep() {219		this._steps += 1;220		if (this.stepUpdateInterval < 0 || this._steps >= this.stepUpdateInterval) {221			const { streamsheet } = this;222			const event = {223				type: MachineEvents.STREAMSHEET_STEP,224				src: 'streamsheet',225				srcId: streamsheet.id,226				machineId: streamsheet.machine.id,227				stats: streamsheet.stats,228				result: getSheetCellsAsList(streamsheet.sheet),229				// jsonpath: streamsheet.getCurrentLoopPath(),230				loop: {231					// index: streamsheet.getLoopIndexKey(),232					currentPath: streamsheet.getCurrentLoopPath()233				},234				inbox: {235					totalSize: this.inboxAdapter.totalSize,236					messages: streamsheet.inbox.messages.slice(0)237				},238				outbox: {239					totalSize: streamsheet.machine.outbox.size,240					messages: streamsheet.machine.outbox.getFirstMessages()241				},242				shapes: streamsheet.sheet.getShapes().toJSON(),243			};244			this._steps = 0;245			MachineTaskMessagingClient.publishEvent(event);246		}247	}248	getStreamSheetStepData() {249		const { streamsheet } = this;250		const currmsg = streamsheet.getCurrentMessage();251		return {252			id: streamsheet.id,253			name: streamsheet.name,254			cells: getSheetCellsAsList(streamsheet.sheet),255			namedCells: streamsheet.sheet.namedCells.getDescriptors(),256			shapes: streamsheet.sheet.getShapes().toJSON(),257			inbox: {258				totalSize: this.inboxAdapter.totalSize,259				messages: streamsheet.inbox.messages.slice(0),260				currentMessage: {261					id: currmsg ? currmsg.id : null,262					isProcessed: streamsheet.isMessageProcessed()263				}264			},265			loop: {266				// index: streamsheet.getLoopIndexKey(),267				currentPath: streamsheet.getCurrentLoopPath()268			},269			stats: streamsheet.stats270		};271	}272}...

Full Screen

Full Screen

device-settings.js

Source:device-settings.js Github

copy

Full Screen

...70      }71      if (this._settings[prop] !== newSettings[prop]) {72        // update setting only when there is updateSettings defined.73        if (this.onSettingsUpdate) {74          await this.onSettingsUpdate(prop, newSettings[prop], this._settings[prop]);75          this._settings[prop] = newSettings[prop];76        } else {77          log.errorAndThrow('Unable to update settings; onSettingsUpdate method not found');78        }79      }80    }81  }82  getSettings () {83    return this._settings;84  }85}86export default DeviceSettings;...

Full Screen

Full Screen

GeckoViewChildModule.jsm

Source:GeckoViewChildModule.jsm Github

copy

Full Screen

...39    }40    this.eventDispatcher = aGlobal._gvEventDispatcher;41    this.messageManager.addMessageListener("GeckoView:UpdateSettings", aMsg => {42      Object.assign(this.settings, aMsg.data);43      this.onSettingsUpdate();44    });45    this.messageManager.addMessageListener(46      "GeckoView:UpdateModuleState",47      aMsg => {48        if (aMsg.data.module !== this.moduleName) {49          return;50        }51        const { enabled, settings } = aMsg.data;52        if (settings) {53          Object.assign(this.settings, settings);54        }55        if (enabled !== this.enabled) {56          if (!enabled) {57            this.onDisable();58          }59          this.enabled = enabled;60          if (enabled) {61            this.onEnable();62          }63        }64        if (settings) {65          this.onSettingsUpdate();66        }67      }68    );69    this.onInit();70    this.messageManager.sendAsyncMessage("GeckoView:ContentModuleLoaded", {71      module: this.moduleName,72    });73  }74  // Override to initialize module.75  onInit() {}76  // Override to detect settings change. Access settings via this.settings.77  onSettingsUpdate() {}78  // Override to enable module after setting a Java delegate.79  onEnable() {}...

Full Screen

Full Screen

GeckoViewContentModule.jsm

Source:GeckoViewContentModule.jsm Github

copy

Full Screen

...34    this.messageManager.addMessageListener(35      "GeckoView:UpdateSettings",36      aMsg => {37        Object.assign(this.settings, aMsg.data);38        this.onSettingsUpdate();39      }40    );41    this.messageManager.addMessageListener(42      "GeckoView:UpdateModuleState",43      aMsg => {44        if (aMsg.data.module !== this.moduleName) {45          return;46        }47        const {enabled, settings} = aMsg.data;48        if (settings) {49          Object.assign(this.settings, settings);50        }51        if (enabled !== this.enabled) {52          if (!enabled) {53            this.onDisable();54          }55          this.enabled = enabled;56          if (enabled) {57            this.onEnable();58          }59        }60        if (settings) {61          this.onSettingsUpdate();62        }63      }64    );65    this.onInit();66    this.messageManager.sendAsyncMessage("GeckoView:ContentModuleLoaded", {67      module: this.moduleName,68    });69  }70  // Override to initialize module.71  onInit() {}72  // Override to detect settings change. Access settings via this.settings.73  onSettingsUpdate() {}74  // Override to enable module after setting a Java delegate.75  onEnable() {}...

Full Screen

Full Screen

setLightColorAction.js

Source:setLightColorAction.js Github

copy

Full Screen

1// Prototype which represents a set light color action2function SetLightColorAction(inContext, inSettings) {3    var instance = this;4    // Inherit from Action5    Action.call(this, inContext, inSettings);6    var actiononSettingsUpdate = this.onSettingsUpdate;7    this.onSettingsUpdate = function(inUpdatedSettings) {8        actiononSettingsUpdate.call(this, inUpdatedSettings);9        var mainCanvas = document.getElementById("mainCanvas");10        var mainCanvasContext = mainCanvas.getContext("2d");11        if (inUpdatedSettings.colorType == "RGB") {12            mainCanvasContext.fillStyle = inUpdatedSettings.color;13            logMessage(`Changing background to ${inUpdatedSettings.color}`);14        } else if (inUpdatedSettings.colorType == "Temperature") {15            var hex = miredToHex(inUpdatedSettings.temperature);16            mainCanvasContext.fillStyle = hex;17            logMessage(`Changing background to ${hex}`);18        }19        mainCanvasContext.fillRect(0, 0, mainCanvas.width, mainCanvas.height);20        setImage(inContext, mainCanvas.toDataURL());21    };22    // Public function called on keyDown event23    var actionOnKeyUp = this.onKeyDown;24    this.onKeyDown = function (inData) {25        actionOnKeyUp.call(this, inData);26        sendTurnOnCommand(inData.settings);27    };28    function sendTurnOnCommand(settings) {29        logMessage(`Sending turn on command to HA for light entity ${settings.entityId}`);30        brightnessPayload = "";31        if (settings.brightness != undefined) {32            brightnessPayload = `,"brightness_pct": ${settings.brightness}`;33        }34        colorPayload = "";35        if (settings.colorType == "RGB") {36            const components = hexToRgb(settings.color);37            const red = components.r;38            const green = components.g;39            const blue = components.b;40            colorPayload = `,"rgb_color": [${red}, ${green}, ${blue}]`;41        } else if (settings.colorType == "Temperature") {42            colorPayload = `,"color_temp": ${settings.temperature}`;43        }44        const setLightColorMessage = `{45          "id": ${++homeAssistantMessageId},46          "type": "call_service",47          "domain": "light",48          "service": "turn_on",49          "service_data": {50            "entity_id": "${settings.entityId}"51            ${brightnessPayload}52            ${colorPayload}53          }54        }`;55        logMessage(setLightColorMessage);56        homeAssistantWebsocket.send(setLightColorMessage);57    }...

Full Screen

Full Screen

GeckoViewModule.jsm

Source:GeckoViewModule.jsm Github

copy

Full Screen

...14    this.window = aWindow;15    this.browser = aBrowser;16    this.eventDispatcher = aEventDispatcher;17    this.eventDispatcher.registerListener(18      () => this.onSettingsUpdate(),19      "GeckoView:UpdateSettings");20    this.init();21    this.onSettingsUpdate();22  }23  // Override this with module initialization.24  init() {}25  // Called when settings have changed. Access settings via this.settings.26  onSettingsUpdate() {}27  get settings() {28    let view = this.window.arguments[0].QueryInterface(Ci.nsIAndroidView);29    return Object.freeze(view.settings);30  }31  get messageManager() {32    return this.browser.messageManager;33  }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { AppiumDriver } = require('appium-base-driver');2class TestDriver extends AppiumDriver {3  constructor (opts = {}, shouldValidateCaps = true) {4    super(opts, shouldValidateCaps);5  }6  async createSession (caps) {7    this.onSettingsUpdate = async function (settings) {8      console.log('Setting update called');9    };10  }11}12module.exports = TestDriver;13const { AppiumDriver } = require('appium-base-driver');14class TestDriver extends AppiumDriver {15  constructor (opts = {}, shouldValidateCaps = true) {16    super(opts, shouldValidateCaps);17  }18  async createSession (caps) {19    this.onSettingsUpdate = async function (settings) {20      console.log('Setting update called');21    };22  }23}24module.exports = TestDriver;25const { AppiumDriver } = require('appium-base-driver');26class TestDriver extends AppiumDriver {27  constructor (opts = {}, shouldValidateCaps = true) {28    super(opts, shouldValidateCaps);29  }30  async createSession (caps) {31    this.onSettingsUpdate = async function (settings) {32      console.log('Setting update called');33    };34  }35}36module.exports = TestDriver;37const { AppiumDriver } = require('appium-base-driver');38class TestDriver extends AppiumDriver {39  constructor (opts = {}, shouldValidateCaps = true) {40    super(opts, shouldValidateCaps);41  }42  async createSession (caps) {43    this.onSettingsUpdate = async function (settings) {44      console.log('Setting update called');45    };46  }47}48module.exports = TestDriver;

Full Screen

Using AI Code Generation

copy

Full Screen

1const AppiumBaseDriver = require('appium-base-driver');2const _ = require('lodash');3const logger = require('appium-support').logger.getLogger('test');4const path = require('path');5const B = require('bluebird');6class TestDriver extends AppiumBaseDriver {7    constructor(opts = {}, shouldValidateCaps = true) {8        super(opts, shouldValidateCaps);9        this.desiredCapConstraints = {10            platformName: {11            },12            platformVersion: {13            },14            deviceName: {15            }16        };17        this.settings = {};18    }19    async createSession(caps) {20        this.settings = _.cloneDeep(this.defaultSettings);21        return super.createSession(caps);22    }23    async onSettingsUpdate(update) {24        logger.info('onSettingsUpdate');25        logger.info(update);26        this.settings = update;27    }28    get defaultSettings() {29        return {30        };31    }32    async setSetting1(setting1) {33        this.settings.setting1 = setting1;34    }35    async setSetting2(setting2) {36        this.settings.setting2 = setting2;37    }38    async setSetting3(setting3) {39        this.settings.setting3 = setting3;40    }41}42module.exports = TestDriver;43const TestDriver = require('./test.js');44const {server, routeConfiguringFunction} = require('appium-base-driver');45const logger = require('appium-support').logger.getLogger('test');46const path = require('path');47async function main() {48    let appium = new server({49        serverArgs: {50            logFile: path.resolve(__dirname, 'appium.log'),51        }52    });53    await appium.start();54    appium.addPlugin(TestDriver);55}56main();572020-02-24 20:55:39:847 - [HTTP] {"desiredCapabilities

Full Screen

Using AI Code Generation

copy

Full Screen

1var appium = require('appium-base-driver');2var AppiumDriver = appium.AppiumDriver;3var _ = require('lodash');4var log = require('./logger.js').get('appium');5var logger = require('./logger.js');6var driver = new AppiumDriver();7var fakeDriver = {8  opts: {9  },10  settings: {11    getSettings: function() {12      return {13      };14    }15  }16};17var appiumDriver = new AppiumDriver();18var fakeAppiumDriver = {19  opts: {20  },21  settings: {22    getSettings: function() {23      return {24      };25    }26  }27};28var appiumDriver = new AppiumDriver();29var fakeAppiumDriver = {30  opts: {31  },32  settings: {33    getSettings: function() {34      return {35      };36    }37  }38};39var appiumDriver = new AppiumDriver();40var fakeAppiumDriver = {41  opts: {42  },43  settings: {44    getSettings: function() {45      return {46      };47    }48  }49};50var appiumDriver = new AppiumDriver();51var fakeAppiumDriver = {52  opts: {53  },54  settings: {55    getSettings: function() {56      return {

Full Screen

Using AI Code Generation

copy

Full Screen

1const chai = require('chai');2const chaiAsPromised = require('chai-as-promised');3const path = require('path');4const { fs } = require('appium-support');5const { createSession, closeSession, startWebDriver, stopWebDriver } = require('./helpers/session');6const { MOCHA_TIMEOUT } = require('./helpers/mocha-timeout');7chai.should();8chai.use(chaiAsPromised);9describe('settings', function () {10  this.timeout(MOCHA_TIMEOUT);11  let driver;12  before(async function () {13    driver = await startWebDriver();14  });15  after(async function () {16    await stopWebDriver(driver);17  });18  it('should update settings', async function () {19    const caps = {app: path.resolve(__dirname, '..', '..', '..', 'test', 'assets', 'TestApp.app.zip')};20    const sessionId = await createSession(driver, caps);21    const settings = {22      'ignoreUnimportantViews': true,

Full Screen

Using AI Code Generation

copy

Full Screen

1var BaseDriver = require('appium-base-driver');2var driver = new BaseDriver();3driver.onSettingsUpdate = function (data) {4  console.log("Settings received: " + data);5  return true;6};7driver.start();8var http = require('http');9var options = {10  headers: {11  }12};13var req = http.request(options, function (res) {14  console.log('Status: ' + res.statusCode);15  console.log('Headers: ' + JSON.stringify(res.headers));16  res.setEncoding('utf8');17  res.on('data', function (body) {18    console.log('Body: ' + body);19  });20});21req.on('error', function (e) {22  console.log('problem with request: ' + e.message);23});24req.write('{"setting1": "value1"}');25req.end();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { AppiumDriver } = require('..');2class TestDriver extends AppiumDriver {3  async createSession (caps) {4    let sessionId = super.createSession(caps);5    return sessionId;6  }7}8const { TestDriver } = require('..');9const { startServer } = require('..');10startServer(TestDriver, {11});12const { TestDriver } = require('..');13const { startServer } = require('..');14startServer(TestDriver, {15});16const { TestDriver } = require('..');17const { startServer } = require('..');18startServer(TestDriver, {19});20const { TestDriver } = require('..');21const { startServer } = require('..');22startServer(TestDriver, {23});24const { TestDriver } = require('..');25const { startServer } = require('..');26startServer(TestDriver, {27});28const { TestDriver } = require('..');29const { startServer } = require('..');30startServer(TestDriver, {31});32const { TestDriver } = require('..');33const { startServer } = require('..');34startServer(TestDriver, {

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 Base Driver automation tests on LambdaTest cloud grid

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

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful