Best JavaScript code snippet using appium-xcuitest-driver
test.js
Source:test.js
1// This file is distributed under the MIT license.2// See LICENSE file in the project root for details.3'use strict';4const chai = require('chai');5const moment = require('moment');6const path = require('path');7const sinon = require('sinon');8const util = require('util');9const webdriver = require('selenium-webdriver');10const expect = chai.expect;11chai.use(require('sinon-chai'));12describe('logging', () => {13 const logging = require('..').logging;14 describe('setFilters', () => {15 let logger = null;16 beforeEach(() => {17 logger = sinon.createStubInstance(webdriver.logging.Logger);18 sinon.stub(webdriver.logging, 'getLogger').callsFake((name) => {19 return logger;20 });21 });22 afterEach(() => {23 webdriver.logging.getLogger.restore();24 });25 context('when level is a non-empty string', () => {26 it('should call Logger.setLevel with a specified level', () => {27 logging.setFilters([{ logger: 'test', level: 'DEBUG' }]);28 expect(logger.setLevel).to.have.been.calledOnce;29 expect(logger.setLevel)30 .to.have.been.calledWith(webdriver.logging.Level.DEBUG);31 });32 });33 context('when level is an empty string', () => {34 it('should call Logger.setLevel with null', () => {35 logging.setFilters([{ logger: 'test', level: '' }]);36 expect(logger.setLevel).to.have.been.calledOnce;37 expect(logger.setLevel).to.have.been.calledWith(null);38 });39 });40 });41 describe('enable/disable', () => {42 let clock = null;43 let sink = null;44 beforeEach(() => {45 clock = sinon.useFakeTimers();46 sink = sinon.spy();47 logging.setSink(sink);48 logging.setFilters([{ logger: 'test', level: 'DEBUG' }]);49 });50 afterEach(() => {51 logging.setFilters([{ logger: 'test', level: '' }]);52 logging.setSink(null);53 sink = null;54 clock.restore();55 clock = null;56 });57 it('should call a log sink function for logging', () => {58 const logger = webdriver.logging.getLogger('test');59 logger.debug('debug1');60 logger.fine('fine1');61 logging.enable();62 logger.debug('debug2');63 logger.fine('fine2');64 logging.disable();65 expect(sink).to.have.been.calledOnce;66 expect(sink).to.have.been.calledWith(util.format(67 '[%s][%s] [test] debug2',68 moment(0).format(), webdriver.logging.Level.DEBUG));69 });70 });71});72describe('ScriptRunner', () => {73 const ScriptRunner = require('..').ScriptRunner;74 let timeoutsStub, optionsStub, driverStub, capsStub, builderStub;75 beforeEach(() => {76 optionsStub = {};77 optionsStub.setTimeouts = sinon.stub();78 driverStub = Promise.resolve();79 driverStub.get = sinon.stub();80 driverStub.getTitle = sinon.stub().returns(Promise.resolve('title'));81 driverStub.executeScript = sinon.stub();82 driverStub.executeAsyncScript = sinon.stub();83 driverStub.manage = sinon.stub().returns(optionsStub);84 driverStub.quit = sinon.stub();85 capsStub = new webdriver.Capabilities;86 builderStub = sinon.createStubInstance(webdriver.Builder);87 builderStub.forBrowser.returns(builderStub);88 builderStub.usingServer.returns(builderStub);89 builderStub.getCapabilities.returns(capsStub);90 builderStub.build.returns(driverStub);91 sinon.stub(webdriver, 'Builder').returns(builderStub);92 });93 afterEach(() => {94 webdriver.Builder.restore();95 builderStub = null;96 capsStub = null;97 driverStub = null;98 optionsStub = null;99 timeoutsStub = null;100 });101 describe('#run', () => {102 context('when multiple targets are specified', () => {103 const options = {104 async: false,105 browser: 'browser',106 browserOptioins: {},107 scriptArgs: [],108 scriptTimeout: 10,109 server: 'server'110 };111 const targets = ['uri:uri1', 'uri:uri2', 'uri:uri3', 'uri:uri4'];112 beforeEach(() => {113 driverStub.executeScript.returns(Promise.resolve(1));114 });115 it('should get results as many as targets', async () => {116 const results = await new ScriptRunner(options).run('script', targets);117 expect(results).to.have.lengthOf(targets.length);118 });119 });120 context('when driver.executeScript() returns a result', () => {121 const options = {122 async: false,123 browser: 'browser',124 browserOptioins: {},125 scriptArgs: [],126 scriptTimeout: 10,127 server: 'server'128 };129 const targets = ['uri:uri'];130 beforeEach(() => {131 driverStub.executeScript.returns(Promise.resolve(1));132 });133 it('should call driver.quit()', async () => {134 await new ScriptRunner(options).run('script', targets);135 expect(driverStub.quit).to.have.been.calledOnce;136 });137 it('should set the title and the result', async () => {138 const results = await new ScriptRunner(options).run('script', targets);139 expect(results[0].title).to.exist;140 expect(results[0].result).to.exist;141 expect(results[0].error).to.not.exist;142 });143 });144 context('when driver.executeScript() throws an error', () => {145 const options = {146 async: false,147 browser: 'browser',148 browserOptioins: {},149 scriptArgs: [],150 scriptTimeout: 10,151 server: 'server'152 };153 const targets = ['uri:uri'];154 beforeEach(() => {155 driverStub.executeScript.throws(new Error);156 });157 it('should call driver.quit()', async () => {158 await new ScriptRunner(options).run('script', targets);159 expect(driverStub.quit).to.have.been.calledOnce;160 });161 it('should set the error', async () => {162 const results = await new ScriptRunner(options).run('script', targets);163 expect(results[0].result).to.not.exist;164 expect(results[0].error).to.exist;165 });166 });167 context('when driver.get() throws an error', () => {168 const options = {169 async: false,170 browser: 'browser',171 browserOptioins: {},172 scriptArgs: [],173 scriptTimeout: 10,174 server: 'server'175 };176 const targets = ['uri:uri'];177 beforeEach(() => {178 driverStub.get.throws(new Error);179 });180 it('should call driver.quit()', async () => {181 await new ScriptRunner(options).run('script', targets);182 expect(driverStub.quit).to.have.been.calledOnce;183 });184 it('should not call driver.executeScript()', async () => {185 await new ScriptRunner(options).run('script', targets);186 expect(driverStub.executeScript).to.have.not.been.called;187 });188 it('should set the error', async () => {189 const results = await new ScriptRunner(options).run('script', targets);190 expect(results[0].result).to.not.exist;191 expect(results[0].error).to.exist;192 });193 });194 context('when a navigation script is used', () => {195 const options = {196 async: false,197 browser: 'browser',198 browserOptioins: {},199 scriptArgs: [],200 scriptTimeout: 10,201 server: 'server'202 };203 const targets = [path.join(__dirname, 'navigation.js')];204 it('should not call driver.get()', async () => {205 await new ScriptRunner(options).run('script', targets);206 expect(driverStub.get).to.have.not.been.called;207 });208 it('should call driver.executeScript()', async () => {209 await new ScriptRunner(options).run('script', targets);210 expect(driverStub.executeScript).to.have.been.calledOnce;211 });212 it('should call driver.quit()', async () => {213 await new ScriptRunner(options).run('script', targets);214 expect(driverStub.quit).to.have.been.calledOnce;215 });216 });217 context('when a window index is specified', () => {218 const options = {219 async: false,220 browser: 'browser',221 browserOptioins: {},222 scriptArgs: [],223 scriptTimeout: 10,224 server: false225 };226 const targets = ['@current'];227 it('should not call driver.get()', async () => {228 await new ScriptRunner(options).run('script', targets);229 expect(driverStub.get).to.have.not.been.called;230 });231 it('should call driver.executeScript()', async () => {232 await new ScriptRunner(options).run('script', targets);233 expect(driverStub.executeScript).to.have.been.calledOnce;234 });235 it('should call driver.quit()', async () => {236 await new ScriptRunner(options).run('script', targets);237 expect(driverStub.quit).to.have.been.calledOnce;238 });239 });240 context('when an unsupported window index is specified', () => {241 const options = {242 async: false,243 browser: 'browser',244 browserOptioins: {},245 scriptArgs: [],246 scriptTimeout: 10,247 server: false248 };249 const targets = ['@unsupported'];250 it('should not call driver.executeScript()', async () => {251 await new ScriptRunner(options).run('script', targets);252 expect(driverStub.executeScript).to.have.not.been.calledOnce;253 });254 it('should call driver.quit()', async () => {255 await new ScriptRunner(options).run('script', targets);256 expect(driverStub.quit).to.have.been.calledOnce;257 });258 it('should set the error', async () => {259 const results = await new ScriptRunner(options).run('script', targets);260 expect(results[0].result).to.not.exist;261 expect(results[0].error).to.exist;262 });263 });264 context('when the ChromeDriver is used with Chrome-specific options', () => {265 const options = {266 async: false,267 browser: 'chrome',268 browserOptioins: {key: 'value'},269 scriptArgs: [],270 scriptTimeout: 10,271 server: false272 };273 const targets = ['@current'];274 it('should set chromeOptions', async () => {275 await new ScriptRunner(options).run('script', targets);276 expect(capsStub.has('chromeOptions')).to.be.true;277 expect(capsStub.get('chromeOptions')).to.eql(options.browserOptions);278 });279 it('should call driver.quit()', async () => {280 await new ScriptRunner(options).run('script', targets);281 expect(driverStub.quit).to.have.been.calledOnce;282 });283 });284 context('when the async option is specifed', () => {285 const options = {286 async: true,287 browser: 'browser',288 browserOptioins: {},289 scriptArgs: [],290 scriptTimeout: 10,291 server: 'server'292 };293 const targets = ['uri:uri'];294 beforeEach(() => {295 driverStub.executeAsyncScript.returns(Promise.resolve(1));296 });297 it('should call setTimeouts', async () => {298 await new ScriptRunner(options).run('script', targets);299 expect(optionsStub.setTimeouts).to.have.been.calledOnce;300 expect(optionsStub.setTimeouts).to.have.been.calledWith({301 script: options.scriptTimeout * 1000302 });303 });304 it('should call executeAsyncScript', async () => {305 await new ScriptRunner(options).run('script', targets);306 expect(driverStub.executeAsyncScript).to.have.been.calledOnce;307 });308 });309 context('when scrint arguments are specifed', () => {310 const options = {311 async: false,312 browser: 'browser',313 browserOptioins: {},314 scriptArgs: [1, 2],315 scriptTimeout: 10,316 server: 'server'317 };318 const targets = ['uri:uri'];319 beforeEach(() => {320 driverStub.executeAsyncScript.returns(Promise.resolve(1));321 });322 it('should call setScriptTimeout with the script arguments', async () => {323 await new ScriptRunner(options).run('script', targets);324 expect(driverStub.executeScript).to.have.been.calledOnce;325 expect(driverStub.executeScript).to.have.been.calledWith(326 'const ARGS = arguments;\nscript', ...options.scriptArgs);327 });328 });329 });330 describe('#abort', () => {331 const options = {332 async: false,333 browser: 'browser',334 browserOptioins: {},335 scriptArgs: [],336 scriptTimeout: 10,337 server: 'server'338 };339 const targets = ['uri:uri1', 'uri:uri2'];340 context('when it is called before running script', () => {341 it('should abort the all promises', async () => {342 const runner = new ScriptRunner(options);343 const promise = runner.run('script', targets);344 runner.abort();345 const results = await promise;346 results.forEach((result) => {347 expect(result).to.not.have.property('result');348 expect(result).to.have.property('error');349 });350 });351 });352 context('when it is called after running script', () => {353 it('should abort the remaining promises', async () => {354 const runner = new ScriptRunner(options);355 driverStub.executeScript = () => runner.abort();356 const results = await runner.run('script', targets);357 expect(results[0]).to.have.property('result');358 expect(results[0]).to.not.have.property('error');359 expect(results[1]).to.not.have.property('result');360 expect(results[1]).to.have.property('error');361 });362 });363 });...
webdriver-environments.js
Source:webdriver-environments.js
1const { WebDriver, Builder, By, Key, until, logging, Capabilities, Capability } = require('selenium-webdriver');2const chromeOptions = require('selenium-webdriver/chrome').Options;3const firefoxOptions = require('selenium-webdriver/firefox').Options;4const path = require('path');5const fs = require('fs');6const os = require('os');7const ExtendedWebDriver = require('./ExtendedWebDriver');8const browserStackEnvironments = require('./browserstack-environments');9const helpers = require('./helpers');10const config = require('./config');11function getLoggingPrefs() {12 const prefs = new logging.Preferences();13 prefs.setLevel(logging.Type.BROWSER, logging.Level.ALL);14 return prefs;15};16/**17 * @typedef {Object} TestEnvironment18 * @property {string} description Human-readable name of the operating system & web browser.19 * @property {string} browserName Lowercase name of web browser (for mobile this can be 'android' or 'iphone').20 * @property {Promise<ExtendedWebDriver>} createDriver Promise that resolves to a ready-to-use WebDriver instance.21 */22/**23 * @generator24 * @param {string} user BrowserStack user credential.25 * @param {string} key BrowserStack key credential.26 * @yields {TestEnvironment}27 */28function* getBrowserstackEnvironments(user, key) {29 for (const env of browserStackEnvironments) {30 const caps = new Capabilities(env).merge({31 'browserstack.user': user,32 'browserstack.key': key,33 'browserstack.console': 'verbose'34 });35 // Increase the `driver.executeAsyncScript(...)` timeout from zero to something usable.36 // https://stackoverflow.com/a/31121340/79496237 const scriptTimeout = 60000;38 caps.merge({'timeouts': { script: scriptTimeout }}).set(Capability.TIMEOUTS, { script: scriptTimeout });39 if (config.browserStack.localEnabled) {40 caps.merge({41 'browserstack.local': 'true',42 'browserstack.localIdentifier': config.browserStack.localIdentifier43 });44 }45 yield {46 description: env.desc,47 browserName: env.browserName.toLowerCase(),48 createDriver: async () => {49 const driver = await new Builder()50 .usingServer(config.browserStack.hubUrl)51 .withCapabilities(caps)52 .setLoggingPrefs(getLoggingPrefs())53 .build();54 // iOS on BrowserStack seems to ignore script timeouts specified in 55 // the Capabilities so explicitly set them here. 56 await driver.manage().setTimeouts({ script: scriptTimeout });57 return new ExtendedWebDriver(driver);58 }59 };60 }61}62/**63 * Generates test environments for the local machine. Always includes 'chrome' and 'firefox'.64 * If on macOS then also includes 'safari'. If on Windows then also includes 'edge'. 65 * @generator66 * @yields {TestEnvironment}67 */68function* getLocalSystemBrowserEnvironments() {69 const browsers = ['firefox', 'chrome'];70 // Ensure the browser webdriver binaries are added to env path71 require('chromedriver');72 require('geckodriver');73 if (process.platform === 'darwin') {74 browsers.push('safari');75 } else if (process.platform === 'win32') {76 browsers.push('edge');77 }78 // Disable Chrome's protocol handler for `blockstack:` in case the native browser is installed on this machine79 // https://stackoverflow.com/a/41299296/79496280 // Note: This ability has since been disabled by Chrome, there is no way to hide the prompt.81 // https://github.com/chromium/chromium/blob/5f0fb8c9021d25d1fadc1ae3706b4790dbcded5a/chrome/browser/external_protocol/external_protocol_handler.cc#L19482 const chromeOpts = new chromeOptions()83 .setUserPreferences({protocol_handler: { excluded_schemes: { 'blockstack': true } } });84 // Disable Firefox's protocol handler for `blockstack:` in case the native browser is installed on this machine85 // https://stackoverflow.com/a/53154527/79496286 const firefoxOpts = (() => {87 const handlers = '{"defaultHandlersVersion":{"en-US":4},"schemes":{"blockstack":{"action":2,"handlers":[{"name":"None","uriTemplate":"#"}]}}}';88 const tempDir = path.resolve(os.tmpdir(), helpers.getRandomString());89 fs.mkdirSync(tempDir);90 fs.writeFileSync(path.resolve(tempDir, 'handlers.json'), handlers);91 return new firefoxOptions().setProfile(tempDir);92 })();93 const caps = new Capabilities().setLoggingPrefs(getLoggingPrefs());94 // Increase the `driver.executeAsyncScript(...)` timeout from zero to something usable.95 // https://stackoverflow.com/a/31121340/79496296 const scriptTimeout = 60000;97 caps.merge({ 'timeouts': { script: scriptTimeout } }).set(Capability.TIMEOUTS, { script: scriptTimeout });98 for (let browser of new Set(browsers)) {99 yield {100 description: `${process.platform} ${browser}`,101 browserName: browser.toLowerCase(),102 createDriver: async () => { 103 const driver = await new Builder()104 .withCapabilities(caps)105 .forBrowser(browser)106 .setChromeOptions(chromeOpts)107 .setFirefoxOptions(firefoxOpts)108 .build();109 return new ExtendedWebDriver(driver);110 }111 };112 }113}114module.exports.getTestEnvironments = function () {115 if (config.browserStack.enabled) {116 return getBrowserstackEnvironments(config.browserStack.user, config.browserStack.key);117 } else {118 return getLocalSystemBrowserEnvironments();119 }...
cucumber-webdriver.js
Source:cucumber-webdriver.js
...41 var reuseOrCreateSession = function (sessions, webBrowser, scriptTimeout, implicitlyWait, callback) {42 var browser;43 if (sessions.length === 0) {44 browser = require(rtdSeleniumServer)(webdriver, { browserName: webBrowser });45 browser.manage().timeouts().setScriptTimeout(scriptTimeout);46 browser.manage().timeouts().implicitlyWait(implicitlyWait);47 callback(browser);48 } else {49 var tempDriver = require(rtdSeleniumServer)(webdriver, { browserName: webBrowser }, sessions[0].id);50 getWebdriverSessionStatus(sessions[0].id, function (status) {51 if (status !== 200) {52 deleteWebdriverSessions(sessions);53 tempDriver = require(rtdSeleniumServer)(webdriver, { browserName: webBrowser });54 }55 tempDriver.manage().timeouts().setScriptTimeout(scriptTimeout);56 tempDriver.manage().timeouts().implicitlyWait(implicitlyWait);57 browser = tempDriver;58 callback(browser);59 });60 }61 };62 Webdriver = function (webBrowser, scriptTimeout, implicitlyWait) {63 return {64 driver: webdriver,65 getBrowser: function (callback) {66 getWebdriverSessions(function (sessions) {67 reuseOrCreateSession(sessions, webBrowser, scriptTimeout, implicitlyWait, callback);68 });69 }...
Common.js
Source:Common.js
1/* æ¤èçJavaScriptå°å¨ææç¨æ¶è¼å
¥æ¯åé é¢æ使ç¨ã */2/*Webfont from Adobe*/3 (function(d) {4 var config = {5 kitId: 'obo3aov',6 scriptTimeout: 3000,7 async: true8 },9 h=d.documentElement,t=setTimeout(function(){h.className=h.className.replace(/\bwf-loading\b/g,"")+" wf-inactive";},config.scriptTimeout),tk=d.createElement("script"),f=false,s=d.getElementsByTagName("script")[0],a;h.className+=" wf-loading";tk.src='https://use.typekit.net/'+config.kitId+'.js';tk.async=true;tk.onload=tk.onreadystatechange=function(){a=this.readyState;if(f||a&&a!="complete"&&a!="loaded")return;f=true;clearTimeout(t);try{Typekit.load(config)}catch(e){}};s.parentNode.insertBefore(tk,s)10 })(document);11 12 (function(d) {13 var config = {14 kitId: 'jgu5nxk',15 scriptTimeout: 3000,16 async: true17 },18 h=d.documentElement,t=setTimeout(function(){h.className=h.className.replace(/\bwf-loading\b/g,"")+" wf-inactive";},config.scriptTimeout),tk=d.createElement("script"),f=false,s=d.getElementsByTagName("script")[0],a;h.className+=" wf-loading";tk.src='https://use.typekit.net/'+config.kitId+'.js';tk.async=true;tk.onload=tk.onreadystatechange=function(){a=this.readyState;if(f||a&&a!="complete"&&a!="loaded")return;f=true;clearTimeout(t);try{Typekit.load(config)}catch(e){}};s.parentNode.insertBefore(tk,s)19 })(document);20 21 (function(d) {22 var config = {23 kitId: 'gzm0pxb',24 scriptTimeout: 3000,25 async: true26 },27 h=d.documentElement,t=setTimeout(function(){h.className=h.className.replace(/\bwf-loading\b/g,"")+" wf-inactive";},config.scriptTimeout),tk=d.createElement("script"),f=false,s=d.getElementsByTagName("script")[0],a;h.className+=" wf-loading";tk.src='https://use.typekit.net/'+config.kitId+'.js';tk.async=true;tk.onload=tk.onreadystatechange=function(){a=this.readyState;if(f||a&&a!="complete"&&a!="loaded")return;f=true;clearTimeout(t);try{Typekit.load(config)}catch(e){}};s.parentNode.insertBefore(tk,s)...
Fandomdesktop.js
Source:Fandomdesktop.js
1/*Webfont from Adobe*/2/* Source Han Sans CJK Traditional Chinese family */3 (function(d) {4 var config = {5 kitId: 'obo3aov',6 scriptTimeout: 3000,7 async: true8 },9 h=d.documentElement,t=setTimeout(function(){h.className=h.className.replace(/\bwf-loading\b/g,"")+" wf-inactive";},config.scriptTimeout),tk=d.createElement("script"),f=false,s=d.getElementsByTagName("script")[0],a;h.className+=" wf-loading";tk.src='https://use.typekit.net/'+config.kitId+'.js';tk.async=true;tk.onload=tk.onreadystatechange=function(){a=this.readyState;if(f||a&&a!="complete"&&a!="loaded")return;f=true;clearTimeout(t);try{Typekit.load(config)}catch(e){}};s.parentNode.insertBefore(tk,s)10 })(document);11/* Source Han Sans CJK Japanese family */ 12 (function(d) {13 var config = {14 kitId: 'jgu5nxk',15 scriptTimeout: 3000,16 async: true17 },18 h=d.documentElement,t=setTimeout(function(){h.className=h.className.replace(/\bwf-loading\b/g,"")+" wf-inactive";},config.scriptTimeout),tk=d.createElement("script"),f=false,s=d.getElementsByTagName("script")[0],a;h.className+=" wf-loading";tk.src='https://use.typekit.net/'+config.kitId+'.js';tk.async=true;tk.onload=tk.onreadystatechange=function(){a=this.readyState;if(f||a&&a!="complete"&&a!="loaded")return;f=true;clearTimeout(t);try{Typekit.load(config)}catch(e){}};s.parentNode.insertBefore(tk,s)19 })(document);20/* Source Han Sans CJK Korean family */ 21 (function(d) {22 var config = {23 kitId: 'gzm0pxb',24 scriptTimeout: 3000,25 async: true26 },27 h=d.documentElement,t=setTimeout(function(){h.className=h.className.replace(/\bwf-loading\b/g,"")+" wf-inactive";},config.scriptTimeout),tk=d.createElement("script"),f=false,s=d.getElementsByTagName("script")[0],a;h.className+=" wf-loading";tk.src='https://use.typekit.net/'+config.kitId+'.js';tk.async=true;tk.onload=tk.onreadystatechange=function(){a=this.readyState;if(f||a&&a!="complete"&&a!="loaded")return;f=true;clearTimeout(t);try{Typekit.load(config)}catch(e){}};s.parentNode.insertBefore(tk,s)...
test-marionette.js
Source:test-marionette.js
1'use strict';2let assert = require('chai').assert;3let Marionette = require('../lib/marionette');4const OPTIONS = {5 marionetteHost: 'localhost',6 marionettePort: 2828,7 connectionTimeout: 10000,8 scriptTimeout: 300009};10// marionette unit tests11describe('marionette', () => {12 let marionette = new Marionette(OPTIONS);13 describe('constructor', () => {14 it('marionette', () => {15 assert.isObject(marionette);16 assert.instanceOf(marionette, Marionette);17 });18 // host19 it('host', () => {20 assert.property(marionette, 'host');21 assert.strictEqual(marionette.host, OPTIONS.marionetteHost);22 });23 // port24 it('port', () => {25 assert.property(marionette, 'port');26 assert.strictEqual(marionette.port, OPTIONS.marionettePort);27 });28 // timeout29 it('timeout', () => {30 assert.property(marionette, 'timeout');31 assert.strictEqual(marionette.timeout, OPTIONS.connectionTimeout);32 });33 // scriptTimeout34 it('scriptTimeout', () => {35 assert.property(marionette, 'scriptTimeout');36 assert.strictEqual(marionette.scriptTimeout, OPTIONS.scriptTimeout);37 });38 // start session39 it('start session', () => {40 assert.isFunction(marionette.startSession);41 });42 // switchToHomescreen43 it('switchToHomescreen', () => {44 assert.isFunction(marionette.switchToHomescreen);45 });46 // clearPerformanceBuffer47 it('clearPerformanceBuffer', () => {48 assert.isFunction(marionette.clearPerformanceBuffer);49 });50 // deleteSession51 it('deleteSession', () => {52 assert.isFunction(marionette.deleteSession);53 });54 });55 describe('switchToHomescreen', () => {56 it('error thrown when have no marionette session', () => {57 assert.throw(marionette.switchToHomescreen.bind(marionette), 'Cannot read property');58 });59 });...
font.js
Source:font.js
1import preload from "./preload"2export default function() {3 (function(d) {4 let config = {5 kitId: "pof7yrz",6 scriptTimeout: 3000,7 async: true,8 },9 h = d.documentElement, t = setTimeout(function() {10 h.className = h.className.replace(/\bwf-loading\b/g, "") +11 " wf-inactive"12 }, config.scriptTimeout), tk = d.createElement("script"), f = false,13 s = d.getElementsByTagName("script")[0], a14 h.className += " wf-loading"15 tk.src = "https://use.typekit.net/" + config.kitId + ".js"16 tk.async = true17 tk.onload = tk.onreadystatechange = function() {18 a = this.readyState19 if (f || a && a !== "complete" && a !== "loaded") return20 f = true21 clearTimeout(t)22 try {23 Typekit.load(24 {25 kitId: "pof7yrz",26 scriptTimeout: 3000,27 async: true,28 loading: function() {29 console.log("loading")30 },31 active: function() {32 console.log("active")33 preload()34 },35 inactive: function() {36 console.log("inactive")37 preload()38 },39 },40 )41 } catch (e) {}42 }43 s.parentNode.insertBefore(tk, s)44 })(document)...
typekit.js
Source:typekit.js
1(function(d) {2 var config = {3 kitId: 'nkl4ucl',4 scriptTimeout: 3000,5 async: true6 },7 h=d.documentElement,t=setTimeout(function(){h.className=h.className.replace(/\bwf-loading\b/g,"")+" wf-inactive";},config.scriptTimeout),tk=d.createElement("script"),f=false,s=d.getElementsByTagName("script")[0],a;h.className+=" wf-loading";tk.src='//use.typekit.net/'+config.kitId+'.js';tk.async=true;tk.onload=tk.onreadystatechange=function(){a=this.readyState;if(f||a&&a!="complete"&&a!="loaded")return;f=true;clearTimeout(t);try{Typekit.load(config)}catch(e){}};s.parentNode.insertBefore(tk,s)...
Using AI Code Generation
1const wdio = require("webdriverio");2const opts = {3 capabilities: {4 }5};6async function main() {7 let client = await wdio.remote(opts);8 await client.setTimeouts({ "script": 5000 });9 await client.deleteSession();10}11main();12client.setTimeouts({ "implicit": 5000 });13const wdio = require("webdriverio");14const opts = {15 capabilities: {16 }17};18async function main() {19 let client = await wdio.remote(opts);20 await client.setTimeouts({ "implicit": 5000 });21 await client.deleteSession();22}23main();
Using AI Code Generation
1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder().forBrowser('safari').build();3driver.manage().timeouts().setScriptTimeout(10000);4driver.executeScript('mobile: scroll', {direction: 'down'});5driver.quit();6var webdriver = require('selenium-webdriver');7var driver = new webdriver.Builder().forBrowser('safari').build();8driver.manage().timeouts().implicitlyWait(10000);9driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');10driver.quit();11var webdriver = require('selenium-webdriver');12var driver = new webdriver.Builder().forBrowser('safari').build();13driver.manage().timeouts().pageLoadTimeout(10000);14driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');15driver.quit();16var webdriver = require('selenium-webdriver');17var driver = new webdriver.Builder().forBrowser('safari').build();18driver.manage().timeouts().setAsyncScriptTimeout(10000);19driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');20driver.quit();21var webdriver = require('selenium-webdriver');22var driver = new webdriver.Builder().forBrowser('safari').build();23driver.manage().timeouts().setImplicitWaitTimeout(10000);24driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');25driver.quit();26var webdriver = require('selenium-webdriver');27var driver = new webdriver.Builder().forBrowser('safari').build();28driver.manage().timeouts().setPageLoadTimeout(10000);29driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');30driver.quit();
Using AI Code Generation
1const wdio = require("webdriverio");2(async () => {3 const opts = {4 capabilities: {5 }6 };7 const client = await wdio.remote(opts);8 const scriptTimeout = await client.execute("mobile: setScriptTimeout", {9 });10 console.log(scriptTimeout);11 await client.deleteSession();12})();13await driver.execute('mobile: setScriptTimeout', { scriptTimeout: 30000 });14{ message: 'The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource.',15 type: 'NoSuchDriverError' }16await driver.execute('mobile: setImplicitWaitTimeout', { implicitWaitTimeout: 30000 });17{ message: 'The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource.',18 type: 'NoSuchDriverError' }19await driver.execute('mobile: setImplicitWaitTimeout', { implicitWaitTimeout:
Using AI Code Generation
1describe('Appium XCUITest Driver', function() {2 it('should set the timeout', function () {3 browser.timeouts('script', 10000);4 });5});6describe('Appium XCUITest Driver', function() {7 it('should set the timeout', function () {8 browser.timeouts('implicit', 10000);9 });10});11describe('Appium XCUITest Driver', function() {12 it('should set the timeout', function () {13 browser.timeouts('page load', 10000);14 });15});16describe('Appium XCUITest Driver', function() {17 it('should get the page source', function () {18 browser.getPageSource();19 });20});21describe('Appium XCUITest Driver', function() {22 it('should get the source', function () {23 browser.getSource();24 });25});26describe('Appium XCUITest Driver', function() {27 it('should get the window handles', function () {28 browser.getWindowHandles();29 });30});31describe('Appium XCUITest Driver', function() {32 it('should get the window handle', function () {33 browser.getWindowHandle();34 });35});36describe('Appium XCUITest Driver', function() {37 it('should set the window', function () {38 browser.setWindow('name');39 });40});41describe('Appium XCUITest Driver', function() {42 it('should get the window size', function () {43 browser.getWindowSize();44 });45});46describe('Appium XCUITest Driver', function() {47 it('should set the window size', function () {48 browser.setWindowSize(100, 100);49 });50});
Using AI Code Generation
1const wdio = require("webdriverio");2const opts = {3 capabilities: {4 }5};6(async () => {7 const client = await wdio.remote(opts);8 await client.setScriptTimeout(5000);9 await client.execute("mobile: scroll", {direction: "down"});10 await client.deleteSession();11})();12{13 "scripts": {14 },15 "dependencies": {16 }17}18{19 "dependencies": {20 "@wdio/logger": {21 "requires": {
Using AI Code Generation
1describe('XCUITest Driver', function() {2 it('should be able to set script timeout', async function() {3 await driver.setScriptTimeout(10000);4 });5});6{"ms": 10000}
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!