How to use pushFile method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

assets.js

Source:assets.js Github

copy

Full Screen

1const _ = require("lodash");2const fs = require("fs");3const path = require("path");4module.exports = function (self, options) {5 self.pushAssets = function () {6 _.each(options.stylesheets.files || [], function (item) {7 if ((/^(.*?)((\/|\\)\*)/g).test(item.name)) {8 var itemRegex = (item.name).match(/^(.*?)(?=(\/|\\)\*)(\\|\/)/g);9 var pathCSS = path.join(__dirname + "/../public/css", itemRegex.toString());10 fs.readdirSync(pathCSS).filter((file) => {11 var acceptFiles = new RegExp(`^(\S*)(?=\.(?=${options.stylesheets.acceptFiles.join("|")}))`);12 if ((file).match(/^(.*)(?=\.)/g) === null || (acceptFiles).test(file)) {13 return;14 } else {15 var pushFile = itemRegex + (file).match(/^(.*)(?=\.)/g);16 self.pushAsset('stylesheet', pushFile, {17 when: item.when18 });19 return;20 }21 });22 } else {23 self.pushAsset('stylesheet', item.name, {24 when: item.when25 });26 }27 })28 _.each(options.scripts.files || [], function (item) {29 if ((/^(.*?)((\/|\\)\*)/g).test(item.name)) {30 var itemRegex = (item.name).match(/^(.*?)(?=(\/|\\)\*)(\\|\/)/g);31 var pathJS = path.join(__dirname + "/../public/js", itemRegex.toString());32 fs.readdirSync(pathJS).filter((file) => {33 var acceptFiles = new RegExp(`^(\S*)(?=\.(?=${options.scripts.acceptFiles.join("|")}))`);34 var allAceModes = new RegExp("(?!^mode-)(\\w+)(?=\.js)", "g");35 var unAcceptedFiles = new RegExp(`^(w*)(?!mode-|theme-|${self.ace.modes.map((elem) => elem.name).join("|")}).*$`, "i");36 var unAcceptedSnippets = new RegExp(`^(?=.*\/ace\/snippets\/(${self.ace.modes.map((elem) => elem.name).join("|")})).*$`, "i");37 var allThemes = new RegExp("(?!^theme-)(\\w+)(?=\.js)", "g");38 if ((file).match(/^(.*)(?=\.)/g) === null || (acceptFiles).test(file)) {39 return;40 } else {41 // Optimized pushAsset to avoid push all unused asset at once42 if (!options.scripts.pushAllAce) {43 for (var i = 0; i < self.ace.modes.length; i++)(function (i) {44 // Only push on acceptable modes45 if ((allAceModes).test(file) && (file).match(allAceModes)[0] === self.ace.modes[i].name) {46 var pushFile = itemRegex + (file).match(/^(.*)(?=\.)/g);47 self.pushAsset('script', pushFile, {48 when: item.when49 });50 return;51 }52 // Only push on acceptable themes53 else if ((allThemes).test(file) && (file).match(allThemes)[0] === self.ace.theme) {54 var pushFile = itemRegex + (file).match(/^(.*)(?=\.)/g);55 self.pushAsset('script', pushFile, {56 when: item.when57 });58 return;59 }60 // If it match snippets directory specifically for ace , run this pushAsset61 else if ((/^(?=.*(snippets)).*$/i).test(itemRegex) && (unAcceptedSnippets).test(pathJS)) {62 var pushFile = itemRegex + (file).match(/^(.*)(?=\.)/g);63 self.pushAsset('script', pushFile, {64 when: item.when65 });66 return;67 }68 // Push the rest of the ace with accepted modes , themes & snippets69 else if ((unAcceptedFiles).test(file) && (itemRegex.toString()).match(/^(?=.*(snippets)).*$/i) === null) {70 var pushFile = itemRegex + (file).match(/^(.*)(?=\.)/g);71 self.pushAsset('script', pushFile, {72 when: item.when73 });74 return;75 }76 })(i);77 return;78 }79 var pushFile = itemRegex + (file).match(/^(.*)(?=\.)/g);80 self.pushAsset('script', pushFile, {81 when: item.when82 });83 return;84 }85 });86 } else {87 self.pushAsset('script', item.name, {88 when: item.when89 });90 }91 })92 }...

Full Screen

Full Screen

new.js

Source:new.js Github

copy

Full Screen

...78 if (result.socket) args.push('--socket');79 if (Number(result.max)) args.push(`--max=${result.max}`);80 if (result.debug) args.push('--debug');81 const addtion = new Addtion(cmd, roll);82 pushFile('babelrc.ejs', path.resolve(projectDir, '.babelrc'));83 pushFile('gitignore.ejs', path.resolve(projectDir, '.gitignore'));84 pushFile('plugin.json.ejs', path.resolve(projectDir, 'config', 'plugin.json'));85 pushFile('plugin.json.ejs', path.resolve(projectDir, 'config', 'plugin.development.json'));86 pushFile('plugin.json.ejs', path.resolve(projectDir, 'config', 'plugin.production.json'));87 pushFile('app.bootstrap.js.ejs', path.resolve(projectDir, 'app.bootstrap.js'));88 pushFile('package.json.ejs', path.resolve(projectDir, 'package.json'), {89 name: result.project,90 args: args.join(' '),91 framework: result.framework92 });93 for (let i = 0; i < files.length; i++) await addtion.render(files[i].template, files[i].where, files[i].data);94 await addtion.controller(projectDir, 'index');95 cmd.debug('开始安装依赖...');96 await addtion.install(projectDir, ...InstallDeps[result.framework]);97 cmd.complete({98 prefix: '[Install]',99 message: `OK, ${addtion.addCount} files has been added. All done!`,100 suffix: '(' + result.framework + ')'101 });102 })).catch(cmd.error);103};104function pushFile(template, where, data) {105 files.push({ template, where, data });...

Full Screen

Full Screen

ls.js

Source:ls.js Github

copy

Full Screen

...50 } else {51 paths = [].slice.call(arguments, 1);52 }53 var list = [];54 function pushFile(abs, relName, stat) {55 if (process.platform === 'win32') {56 relName = relName.replace(/\\/g, '/');57 }58 if (options.long) {59 stat = stat || (options.link ? fs.statSync(abs) : fs.lstatSync(abs));60 list.push(addLsAttributes(relName, stat));61 } else {62 // list.push(path.relative(rel || '.', file));63 list.push(relName);64 }65 }66 paths.forEach(function (p) {67 var stat;68 try {69 stat = options.link ? fs.statSync(p) : fs.lstatSync(p);70 } catch (e) {71 common.error('no such file or directory: ' + p, 2, { continue: true });72 return;73 }74 // If the stat succeeded75 if (stat.isDirectory() && !options.directory) {76 if (options.recursive) {77 // use glob, because it's simple78 glob.sync(p + globPatternRecursive, { dot: options.all, follow: options.link })79 .forEach(function (item) {80 // Glob pattern returns the directory itself and needs to be filtered out.81 if (path.relative(p, item)) {82 pushFile(item, path.relative(p, item));83 }84 });85 } else if (options.all) {86 // use fs.readdirSync, because it's fast87 fs.readdirSync(p).forEach(function (item) {88 pushFile(path.join(p, item), item);89 });90 } else {91 // use fs.readdirSync and then filter out secret files92 fs.readdirSync(p).forEach(function (item) {93 if (item[0] !== '.') {94 pushFile(path.join(p, item), item);95 }96 });97 }98 } else {99 pushFile(p, p, stat);100 }101 });102 // Add methods, to make this more compatible with ShellStrings103 return list;104}105function addLsAttributes(pathName, stats) {106 // Note: this object will contain more information than .toString() returns107 stats.name = pathName;108 stats.toString = function () {109 // Return a string resembling unix's `ls -l` format110 return [this.mode, this.nlink, this.uid, this.gid, this.size, this.mtime, this.name].join(' ');111 };112 return stats;113}...

Full Screen

Full Screen

gulp-sfc.js

Source:gulp-sfc.js Github

copy

Full Screen

...43 parser.write(content)44 parser.end()4546 let { wxml, js, json, style } = parser47 pushFile(wxml, '.wxml')48 pushFile(js, '.js')49 pushFile(json ? JSON.stringify(rfs(json)) : '{}', `.json`)50 if (style.length) {51 style.forEach(({ lang, text }, index) => {52 pushFile(text, `.${lang}`, index, style.length)53 })54 } else {55 pushFile('', '.css')56 }57 } catch (e) {58 return cb(new GulpError(file, e))59 }6061 cb()62 }) ...

Full Screen

Full Screen

find.js

Source:find.js Github

copy

Full Screen

...23 paths = paths; // assume array24 else if (typeof paths === 'string')25 paths = [].slice.call(arguments, 1);26 var list = [];27 function pushFile(file) {28 if (common.platform === 'win')29 file = file.replace(/\\/g, '/');30 list.push(file);31 }32 // why not simply do ls('-R', paths)? because the output wouldn't give the base dirs33 // to get the base dir in the output, we need instead ls('-R', 'dir/*') for every directory34 paths.forEach(function(file) {35 pushFile(file);36 if (fs.statSync(file).isDirectory()) {37 _ls('-RA', file+'/*').forEach(function(subfile) {38 pushFile(subfile);39 });40 }41 });42 return list;43}...

Full Screen

Full Screen

pushFile.js

Source:pushFile.js Github

copy

Full Screen

...3 value: true4});5exports.default = pushFile;6var _ErrorHandler = require('../utils/ErrorHandler');7function pushFile(path, base64Data) {8 if (typeof path !== 'string' || typeof base64Data !== 'string') {9 throw new _ErrorHandler.ProtocolError('pushFile requires two parameters (path, base64Data) from type string');10 }11 return this.requestHandler.create({12 path: '/session/:sessionId/appium/device/push_file',13 method: 'POST'14 }, {15 path: path,16 data: base64Data17 });18} /**19 *20 * Pushes a file to the device.21 *22 * <example>23 :pushFile.js24 var data = new Buffer("Hello World").toString('base64'))25 browser.pushFile('/data/local/tmp/file.txt', data)26 * </example>27 *28 * @param {String} path local path to file29 *30 * @see https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/appium-bindings.md#push-file31 * @type mobile32 * @for ios, android33 *34 */...

Full Screen

Full Screen

3.proxy.js

Source:3.proxy.js Github

copy

Full Screen

1let EventEmitter = require('events');2let util = require('util');3util.inherits(PushFile, EventEmitter);4function PushFile() {5 EventEmitter.call(this);6}7function pushFileListener(id) {8 console.log(`上传文件,id:${id}`);9}10let proxyPushFileListener = (function () {11 let cache = [],timer;12 return function (id) {13 cache.push(id);14 if(timer)15 return;16 timer = setTimeout(function () {17 pushFileListener(cache.join(','));18 clearTimeout(timer);19 timer = null;20 cache.length = 0;21 },1000);22 };23})();24let pushFile = new PushFile();25pushFile.on('push', proxyPushFileListener);26pushFile.emit('push', 1);27pushFile.emit('push', 2);28pushFile.emit('push', 3);29setTimeout(function () {30 pushFile.emit('push', 4);...

Full Screen

Full Screen

keyframe.js

Source:keyframe.js Github

copy

Full Screen

...14 def = def.replace(arrMedias[i],'');15 }16 }17 if(key){18 pushFile('keyframe',key);19 }20 pushFile('cleanAnim',def);21 console.timeEnd();...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const fs = require('fs');2const path = require('path');3const { remote } = require('webdriverio');4(async () => {5 const browser = await remote({6 capabilities: {7 }8 });9 await browser.pause(10000);10 await browser.setImplicitTimeout(5000);11 await browser.pushFile('/var/mobile/Containers/Data/Application/123456-7890-1234-5678-1234567890/Documents/MyApp/Documents/MyFile.txt', fs.readFileSync(path.join(__dirname, 'myFile.txt')));12 await browser.deleteSession();13})();14const fs = require('fs');15const path = require('path');16const { remote } = require('webdriverio');17(async () => {18 const browser = await remote({19 capabilities: {20 }21 });22 await browser.pause(10000);23 await browser.setImplicitTimeout(5000);24 const fileContent = await browser.pullFile('/var/mobile

Full Screen

Using AI Code Generation

copy

Full Screen

1driver.pushFile('/var/mobile/Containers/Data/Application/6E5A1E82-8F5A-4C1F-8B3A-3E8F7C4B9C1E/Library/AddressBook/AddressBook.sqlitedb', 'AddressBook.sqlitedb');2driver.pullFile('/var/mobile/Containers/Data/Application/6E5A1E82-8F5A-4C1F-8B3A-3E8F7C4B9C1E/Library/AddressBook/AddressBook.sqlitedb');3driver.pushFile('/var/mobile/Containers/Data/Application/6E5A1E82-8F5A-4C1F-8B3A-3E8F7C4B9C1E/Library/AddressBook/AddressBook.sqlitedb', 'AddressBook.sqlitedb');4driver.pullFile('/var/mobile/Containers/Data/Application/6E5A1E82-8F5A-4C1F-8B3A-3E8F7C4B9C1E/Library/AddressBook/AddressBook.sqlitedb');5driver.pushFile('/var/mobile/Containers/Data/Application/6E5A1E82-8F5A-4C1F-8B3A-3E8F7C4B9C1E/Library/AddressBook/AddressBook.sqlitedb', 'AddressBook.sqlitedb');6driver.pullFile('/var/mobile/Containers

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd'),2 path = require('path'),3 assert = require('assert'),4 _ = require('underscore'),5 config = require('./config.json');6var desired = {7};8var driver = wd.promiseChainRemote(config.appiumServer, config.appiumPort);9driver.init(desired).then(function() {10 var file = path.resolve(__dirname, 'test.html');11 return driver.pushFile('Library/WebKit/WebsiteData/LocalStorage/http_localhost_8000_0.localstorage', file);12}).then(function() {13 console.log('File pushed');14 return driver.quit();15}).done();

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const assert = require('assert');3const path = require('path');4const desiredCaps = {5};6async function main() {7 await driver.init(desiredCaps);8 await driver.sleep(3000);9 await driver.pushFile('/Documents/test.txt', 'Hello World!');10 await driver.sleep(3000);11 const fileContent = await driver.pullFile('/Documents/test.txt');12 assert.equal(fileContent, 'Hello World!');13}14main();15const wd = require('wd');16const assert = require('assert');17const path = require('path');18const desiredCaps = {19};20async function main() {21 await driver.init(desiredCaps);22 await driver.sleep(3000);23 await driver.pushFile('/Documents/test.txt', 'Hello World!');24 await driver.sleep(3000);25 const fileContent = await driver.pullFile('/Documents/test.txt');26 assert.equal(fileContent, 'Hello World!');27}28main();29const wd = require('wd');30const assert = require('assert');31const path = require('path');

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