How to use fs.rimraf method in Appium Base Driver

Best JavaScript code snippet using appium-base-driver

fs-specs.js

Source:fs-specs.js Github

copy

Full Screen

...28 });29 describe('mkdir', function () {30 let dirName = path.resolve(__dirname, 'tmp');31 it('should make a directory that does not exist', async function () {32 await fs.rimraf(dirName);33 await fs.mkdir(dirName);34 let exists = await fs.hasAccess(dirName);35 exists.should.be.true;36 });37 it('should not complain if the dir already exists', async function () {38 let exists = await fs.hasAccess(dirName);39 exists.should.be.true;40 await fs.mkdir(dirName);41 });42 it('should still throw an error if something else goes wrong', async function () {43 await fs.mkdir('/bin/foo').should.be.rejected;44 });45 });46 it('hasAccess', async function () {47 (await fs.exists(existingPath)).should.be.ok;48 let nonExistingPath = path.resolve(__dirname, 'wrong-specs.js');49 (await fs.hasAccess(nonExistingPath)).should.not.be.ok;50 });51 it('exists', async function () {52 (await fs.exists(existingPath)).should.be.ok;53 let nonExistingPath = path.resolve(__dirname, 'wrong-specs.js');54 (await fs.exists(nonExistingPath)).should.not.be.ok;55 });56 it('readFile', async function () {57 (await fs.readFile(existingPath, 'utf8')).should.contain('readFile');58 });59 describe('copyFile', function () {60 it('should be able to copy a file', async function () {61 let newPath = path.resolve(await tempDir.openDir(), 'fs-specs.js');62 await fs.copyFile(existingPath, newPath);63 (await fs.readFile(newPath, 'utf8')).should.contain('readFile');64 });65 it('should throw an error if the source does not exist', async function () {66 await fs.copyFile('/sdfsdfsdfsdf', '/tmp/bla').should.eventually.be.rejected;67 });68 });69 it('rimraf', async function () {70 let newPath = path.resolve(await tempDir.openDir(), 'fs-specs.js');71 await fs.copyFile(existingPath, newPath);72 (await fs.exists(newPath)).should.be.true;73 await fs.rimraf(newPath);74 (await fs.exists(newPath)).should.be.false;75 });76 it('sanitizeName', function () {77 fs.sanitizeName(':file?.txt', {78 replacement: '-',79 }).should.eql('-file-.txt');80 });81 it('rimrafSync', async function () {82 let newPath = path.resolve(await tempDir.openDir(), 'fs-specs.js');83 await fs.copyFile(existingPath, newPath);84 (await fs.exists(newPath)).should.be.true;85 fs.rimrafSync(newPath);86 (await fs.exists(newPath)).should.be.false;87 });...

Full Screen

Full Screen

basics-e2e-specs.js

Source:basics-e2e-specs.js Github

copy

Full Screen

...58 // travis can't write to /tmp, so let's create a tmp directory59 try {60 await fs.mkdir(TEMP_DIR);61 } catch (e) {}62 await fs.rimraf(altTmpDir);63 });64 after(async function () {65 await fs.rimraf(TEMP_DIR);66 });67 test(" (1)", {68 launchTimeout: {global: 60000, afterSimLaunch: 10000},69 tmpDir: altTmpDir70 }, {71 afterCreate: (instruments) => { instruments.tmpDir.should.equal(altTmpDir); },72 afterLaunch: async () => {73 (await fs.exists(altTmpDir)).should.be.ok;74 (await fs.exists(path.resolve(altTmpDir, 'instrumentscli0.trace'))).should.be.ok;75 }76 });77 // test(" (2)", {78 // launchTimeout: {global: 60000, afterSimLaunch: 10000},79 // tmpDir: altTmpDir80 // }, {81 // afterCreate: function (instruments) { instruments.tmpDir.should.equal(altTmpDir); },82 // afterLaunch: async function () {83 // (await fs.exists(altTmpDir)).should.be.ok;84 // // tmp dir is deleted at startup so trace file is not incremented85 // (await fs.exists(path.resolve(altTmpDir, 'instrumentscli0.trace'))).should.be.ok;86 // }87 // });88 });89 describe.skip("using different trace dir", function () {90 let altTraceDir = path.resolve(TEMP_DIR, 'abcd');91 before(async function () {92 // travis can't write to /tmp, so let's create a tmp directory93 try {94 await fs.mkdir(TEMP_DIR);95 } catch (e) {}96 await fs.rimraf(altTraceDir);97 });98 after(async function () {99 await fs.rimraf(TEMP_DIR);100 });101 test(" (1)", {102 launchTimeout: {global: 60000, afterSimLaunch: 10000},103 traceDir: altTraceDir104 }, {105 afterCreate: (instruments) => {106 instruments.tmpDir.should.equal('/tmp/appium-instruments');107 },108 afterLaunch: async () => {109 (await fs.exists(altTraceDir)).should.be.ok;110 (await fs.exists(path.resolve(altTraceDir, 'instrumentscli0.trace')))111 .should.be.ok;112 }113 });...

Full Screen

Full Screen

screenshots.js

Source:screenshots.js Github

copy

Full Screen

...6import { fs, tempDir, util } from 'appium-support';7let commands = {};8async function getScreenshotWithIdevicelib (udid, isLandscape) {9 const pathToScreenshotTiff = await tempDir.path({prefix: `screenshot-${udid}`, suffix: '.tiff'});10 await fs.rimraf(pathToScreenshotTiff);11 const pathToResultPng = await tempDir.path({prefix: `screenshot-${udid}`, suffix: '.png'});12 await fs.rimraf(pathToResultPng);13 try {14 try {15 await exec('idevicescreenshot', ['-u', udid, pathToScreenshotTiff]);16 } catch (e) {17 throw new Error(`Cannot take a screenshot from the device '${udid}' using ` +18 `idevicescreenshot. Original error: ${e.message}`);19 }20 let sipsArgs = ['-s', 'format', 'png', pathToScreenshotTiff, '--out', pathToResultPng];21 if (isLandscape) {22 sipsArgs = ['-r', '-90', ...sipsArgs];23 }24 try {25 // The sips tool is only present on Mac OS26 await exec('sips', sipsArgs);27 } catch (e) {28 throw new Error(`Cannot convert a screenshot from TIFF to PNG using sips tool. ` +29 `Original error: ${e.message}`);30 }31 if (!await fs.exists(pathToResultPng)) {32 throw new Error(`Cannot convert a screenshot from TIFF to PNG. The conversion ` +33 `result does not exist at '${pathToResultPng}'`);34 }35 return (await fs.readFile(pathToResultPng)).toString('base64');36 } finally {37 await fs.rimraf(pathToScreenshotTiff);38 await fs.rimraf(pathToResultPng);39 }40}41async function isIdevicescreenshotAvailable () {42 return !!(await fs.which('idevicescreenshot'));43}44commands.getScreenshot = async function () {45 const getScreenshotFromWDA = async () => {46 const data = await this.proxyCommand('/screenshot', 'GET');47 if (!_.isString(data)) {48 throw new Error(`Unable to take screenshot. WDA returned '${JSON.stringify(data)}'`);49 }50 return data;51 };52 try {...

Full Screen

Full Screen

simulator-common-specs.js

Source:simulator-common-specs.js Github

copy

Full Screen

1// transpile:mocha2import SimulatorXcode6 from '../../lib/simulator-xcode-6';3import SimulatorXcode7 from '../../lib/simulator-xcode-7';4import chai from 'chai';5import chaiAsPromised from 'chai-as-promised';6import _ from 'lodash';7import sinon from 'sinon';8import { fs } from '@appium/support';9import B from 'bluebird';10chai.should();11chai.use(chaiAsPromised);12let simulatorClasses = {13 SimulatorXcode6,14 SimulatorXcode715};16for (let [name, simClass] of _.toPairs(simulatorClasses)) {17 describe(`common methods - ${name}`, function () {18 let sim;19 beforeEach(function () {20 sim = new simClass('123', '6.0.0');21 });22 it('should exist', function () {23 simClass.should.exist;24 });25 it('should return a path for getDir()', function () {26 sim.getDir().should.exist;27 });28 it('should return an array for getAppDirs()', async function () {29 let stub = sinon.stub(sim, 'getAppDir').returns(B.resolve(['/App/Path/']));30 sim._platformVersion = 9.1;31 let dirs = await sim.getAppDirs('test');32 dirs.should.have.length(2);33 dirs.should.be.a('array');34 stub.restore();35 });36 describe('cleanCustomApp', function () {37 let sandbox;38 let appBundleId = 'com.some.app';39 beforeEach(function () {40 sandbox = sinon.createSandbox();41 sandbox.spy(fs, 'rimraf');42 });43 afterEach(function () {44 sandbox.restore();45 });46 it('should not delete anything if no directories are found', async function () {47 sandbox.stub(sim, 'getPlatformVersion').returns(B.resolve(7.1));48 sandbox.stub(sim, 'getAppDir').returns(B.resolve());49 await sim.cleanCustomApp('someApp', 'com.some.app');50 sinon.assert.notCalled(fs.rimraf);51 });52 it('should delete app directories', async function () {53 sandbox.stub(sim, 'getPlatformVersion').returns(B.resolve(7.1));54 sandbox.stub(sim, 'getAppDirs').returns(B.resolve(['/some/path', '/another/path']));55 await sim.cleanCustomApp('someApp', 'com.some.app');56 sinon.assert.called(fs.rimraf);57 });58 it('should delete plist file for iOS8+', async function () {59 sandbox.stub(sim, 'getPlatformVersion').returns(B.resolve(9));60 sandbox.stub(sim, 'getAppDirs').returns(B.resolve(['/some/path', '/another/path']));61 await sim.cleanCustomApp('someApp', appBundleId);62 sinon.assert.calledWithMatch(fs.rimraf, /plist/);63 });64 it('should not delete plist file for iOS7.1', async function () {65 sandbox.stub(sim, 'getPlatformVersion').returns(B.resolve(7.1));66 sandbox.stub(sim, 'getAppDirs').returns(B.resolve(['/some/path', '/another/path']));67 await sim.cleanCustomApp('someApp', appBundleId);68 sinon.assert.neverCalledWithMatch(fs.rimraf, /plist/);69 });70 });71 it('should return a path for getLogDir', function () {72 const home = process.env.HOME;73 process.env.HOME = __dirname;74 let logDir = sim.getLogDir();75 logDir.should.equal(`${__dirname}/Library/Logs/CoreSimulator/123`);76 process.env.HOME = home;77 });78 describe('getPlatformVersion', function () {79 let statStub;80 let platformVersion = 8.9;81 beforeEach(function () {82 statStub = sinon.stub(sim, 'stat').returns({sdk: platformVersion});83 });84 afterEach(function () {85 statStub.restore();86 });87 it('should get the correct platform version', async function () {88 let pv = await sim.getPlatformVersion();89 pv.should.equal(platformVersion);90 });91 it('should only call stat once', async function () {92 let pv = await sim.getPlatformVersion();93 pv.should.equal(platformVersion);94 statStub.calledOnce.should.be.true;95 });96 });97 });...

Full Screen

Full Screen

build-webdriveragent.js

Source:build-webdriveragent.js Github

copy

Full Screen

...17 for (const wdaPath of18 await fs.glob('WebDriverAgent-*', {cwd: derivedDataPath, absolute: true})19 ) {20 log.info(`Deleting existing WDA: '${wdaPath}'`);21 await fs.rimraf(wdaPath);22 }23 // Clean and build24 await exec('npx', ['gulp', 'clean:carthage']);25 log.info('Running ./Scripts/build.sh');26 let env = {TARGET: 'runner', SDK: 'sim'};27 try {28 await exec('/bin/bash', ['./Scripts/build.sh'], {env, cwd: rootDir});29 } catch (e) {30 log.error(`===FAILED TO BUILD FOR ${xcodeVersion}`);31 log.error(e.stdout);32 log.error(e.stderr);33 log.error(e.message);34 throw e;35 }36 // Create bundles folder37 const pathToBundles = path.resolve(rootDir, 'bundles');38 await mkdirp(pathToBundles);39 // Start creating zip40 const uncompressedDir = path.resolve(rootDir, 'uncompressed');41 await fs.rimraf(uncompressedDir);42 await mkdirp(uncompressedDir);43 log.info('Creating zip');44 // Move contents of the root to folder called "uncompressed"45 await exec('rsync', [46 '-av', '.', uncompressedDir,47 '--exclude', 'node_modules',48 '--exclude', 'build',49 '--exclude', 'ci-jobs',50 '--exclude', 'lib',51 '--exclude', 'test',52 '--exclude', 'bundles',53 '--exclude', 'azure-templates',54 ], {cwd: rootDir});55 // Move DerivedData/WebDriverAgent-* from Library to "uncompressed" folder56 const wdaPath = (await fs.glob(`${derivedDataPath}/WebDriverAgent-*`))[0];57 await mkdirp(path.resolve(uncompressedDir, 'DerivedData'));58 await fs.rename(wdaPath, path.resolve(uncompressedDir, 'DerivedData', 'WebDriverAgent'));59 // Compress the "uncompressed" bundle as a Zip60 const pathToZip = path.resolve(pathToBundles, `webdriveragent-xcode_${xcodeVersion}.zip`);61 await zip.toArchive(62 pathToZip, {cwd: path.join(rootDir, 'uncompressed')}63 );64 log.info(`Zip bundled at "${pathToZip}"`);65 // Now just zip the .app and place it in the root directory66 // This zip file will be published to NPM67 const wdaAppBundle = 'WebDriverAgentRunner-Runner.app';68 const appBundlePath = path.join(uncompressedDir, 'DerivedData', 'WebDriverAgent',69 'Build', 'Products', 'Debug-iphonesimulator', wdaAppBundle);70 const appBundleZipPath = path.join(rootDir, `${wdaAppBundle}.zip`);71 await fs.rimraf(appBundleZipPath);72 log.info(`Created './${wdaAppBundle}.zip'`);73 await zip.toArchive(appBundleZipPath, {cwd: appBundlePath});74 log.info(`Zip bundled at "${appBundleZipPath}"`);75 // Clean up the uncompressed directory76 await fs.rimraf(uncompressedDir);77}78if (require.main === module) {79 asyncify(buildWebDriverAgent);80}...

Full Screen

Full Screen

crowdin-sync-translations.js

Source:crowdin-sync-translations.js Github

copy

Full Screen

...71 continue;72 }73 const dstPath = path.resolve(RESOURCES_ROOT, name);74 if (await fs.exists(dstPath)) {75 await fs.rimraf(dstPath);76 }77 await fs.mv(currentPath, path.resolve(RESOURCES_ROOT, name), {78 mkdirp: true79 });80 log.info(`Successfully updated resources for the '${name}' language`);81 }82 } finally {83 await fs.rimraf(tmpRoot);84 }85 } finally {86 await fs.rimraf(zipPath);87 }88}...

Full Screen

Full Screen

storage-client-e2e-specs.js

Source:storage-client-e2e-specs.js Github

copy

Full Screen

...23 versions: ['2.35', '2.34'],24 })).length.should.be.greaterThan(0);25 (await fs.readdir(tmpRoot)).length.should.be.eql(2);26 } finally {27 await fs.rimraf(tmpRoot);28 }29 });30 it('should retrieve chromedrivers by minBrowserVersion (non exact match)', async function () {31 const tmpRoot = await tempDir.openDir();32 const client = new ChromedriverStorageClient({33 chromedriverDir: tmpRoot,34 });35 try {36 (await client.syncDrivers({37 minBrowserVersion: '44',38 })).length.should.be.greaterThan(0);39 (await fs.readdir(tmpRoot)).length.should.be.greaterThan(0);40 } finally {41 await fs.rimraf(tmpRoot);42 }43 });44 it('should retrieve chromedrivers by minBrowserVersion (exact match)', async function () {45 const tmpRoot = await tempDir.openDir();46 const client = new ChromedriverStorageClient({47 chromedriverDir: tmpRoot,48 });49 try {50 (await client.syncDrivers({51 minBrowserVersion: '74',52 })).length.should.be.greaterThan(0);53 (await fs.readdir(tmpRoot)).length.should.be.greaterThan(0);54 } finally {55 await fs.rimraf(tmpRoot);56 }57 });...

Full Screen

Full Screen

files.js

Source:files.js Github

copy

Full Screen

1var copy, fs, rimraf, rm;2fs = require("fs");3rimraf = require("rimraf");4copy = function(path, sourcePath, targetPath, cb) {5 var readStream, writeStream;6 targetPath = path.replace(sourcePath, targetPath);7 readStream = fs.createReadStream(path);8 writeStream = fs.createWriteStream(targetPath);9 readStream.on("error", cb);10 writeStream.on("error", cb);11 writeStream.on("finish", cb);12 return readStream.pipe(writeStream);13};14rm = function(path, sourcePath, targetPath, cb) {15 targetPath = path.replace(sourcePath, targetPath);16 return rimraf(targetPath, cb);17};18module.exports = {19 rm: rm,20 copy: copy...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var rimraf = require('rimraf');2rimraf('./path/to/directory', function () { console.log('done'); });3var rimraf = require('rimraf');4rimraf('./path/to/directory', function () { console.log('done'); });5var rimraf = require('rimraf');6rimraf('./path/to/directory', function () { console.log('done'); });7var rimraf = require('rimraf');8rimraf('./path/to/directory', function () { console.log('done'); });9var rimraf = require('rimraf');10rimraf('./path/to/directory', function () { console.log('done'); });11var rimraf = require('rimraf');12rimraf('./path/to/directory', function () { console.log('done'); });13var rimraf = require('rimraf');14rimraf('./path/to/directory', function () { console.log('done'); });15var rimraf = require('rimraf');16rimraf('./path/to/directory', function () { console.log('done'); });17var rimraf = require('rimraf');18rimraf('./path/to/directory', function () { console.log('done'); });19var rimraf = require('rimraf');20rimraf('./path/to/directory', function () { console.log('done'); });21var rimraf = require('rimraf');22rimraf('./path/to/directory', function () { console.log('done'); });23var rimraf = require('rimraf');24rimraf('./path/to/directory', function () { console.log('done'); });25var rimraf = require('

Full Screen

Using AI Code Generation

copy

Full Screen

1var rimraf = require('rimraf');2rimraf('./appium/node_modules/appium-base-driver/node_modules/appium-support/build/lib/fs.js', function () { console.log('done'); });3var rimraf = require('rimraf');4rimraf('./appium/node_modules/appium-support/build/lib/fs.js', function () { console.log('done'); });5const rimraf = require('appium-support').fs.rimraf;6rimraf('./appium/node_modules/appium-base-driver/node_modules/appium-support/build/lib/fs.js', function () { console.log('done'); });7const rimraf = require('appium-support').fs.rimraf;8rimraf('./appium/node_modules/appium-support/build/lib/fs.js', function () { console.log('done'); });9[HTTP] {"id":"0.17056121150598073-1"}10[W3C (9e2b8fd8)] Driver proxy active, passing request on via HTTP proxy

Full Screen

Using AI Code Generation

copy

Full Screen

1const rimraf = require('rimraf');2const rimrafAsync = require('rimraf-async');3const path = require('path');4const testDir = path.resolve(__dirname, 'testDir');5rimrafAsync(testDir)6 .then(function () {7 console.log('done');8 })9 .catch(function (err) {10 console.log(err);11 });12const rimraf = require('rimraf');13const rimrafAsync = require('rimraf-async');14const path = require('path');15const testDir = path.resolve(__dirname, 'testDir');16rimrafAsync(testDir)17 .then(function () {18 console.log('done');19 })20 .catch(function (err) {21 console.log(err);22 });23const rimraf = require('rimraf');24const rimrafAsync = require('rimraf-async');25const path = require('path');26const testDir = path.resolve(__dirname, 'testDir');27rimrafAsync(testDir)28 .then(function () {29 console.log('done');30 })31 .catch(function (err) {32 console.log(err);33 });34const rimraf = require('rimraf');35const rimrafAsync = require('rimraf-async');36const path = require('path');37const testDir = path.resolve(__dirname, 'testDir');38rimrafAsync(testDir)39 .then(function () {40 console.log('done');41 })42 .catch(function (err) {43 console.log(err);44 });45const rimraf = require('rimraf');46const rimrafAsync = require('rimraf-async');47const path = require('path');

Full Screen

Using AI Code Generation

copy

Full Screen

1var rimraf = require('rimraf');2var path = require('path');3rimraf(path.join('/Users/username/Desktop/AppiumTest'), function (err) {4 if (err) throw err;5 console.log('done');6});7rimraf('/Users/username/Desktop/AppiumTest', function (err) {8 if (err) throw err;9 console.log('done');10});11rimraf('/Users/username/Desktop/AppiumTest', function (err) {12 if (err) throw err;13 console.log('done');14});15rimraf('/Users/username/Desktop/AppiumTest', function (err) {16 if (err) throw err;17 console.log('done');18});19rimraf('/Users/username/Desktop/AppiumTest', function (err) {20 if (err) throw err;21 console.log('done');22});23rimraf('/Users/username/Desktop/AppiumTest', function (err) {24 if (err) throw err;25 console.log('done');26});27rimraf('/Users/username/Desktop/AppiumTest', function (err) {28 if (err) throw err;29 console.log('done');30});31rimraf('/Users/username/Desktop/AppiumTest', function (err) {32 if (err) throw err;33 console.log('done');34});35rimraf('/Users/username/Desktop/AppiumTest', function (err) {36 if (err) throw err;37 console.log('done');38});39rimraf('/Users/username/Desktop/AppiumTest', function (err) {40 if (err) throw err;41 console.log('done');42});43rimraf('/Users/username/Desktop/AppiumTest', function (err) {44 if (err) throw err;45 console.log('done');46});47rimraf('/Users/username/Desktop/AppiumTest', function (err) {48 if (err) throw err;49 console.log('done');50});51rimraf('/Users/username/Desktop/AppiumTest', function (err) {52 if (err) throw err;53 console.log('done');54});55rimraf('/Users/username

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