Best JavaScript code snippet using appium-xcuitest-driver
GitHub.js
Source:GitHub.js
...36 if (!web) {37 this.log.warn(`Environment variable "${tokenRef}" is required for automated GitHub Releases.`);38 this.log.warn('Falling back to web-based GitHub Release.');39 }40 this.setContext({ isWeb: true });41 return;42 }43 if (web && assets) {44 this.log.warn('Assets are not included in web-based releases.');45 }46 if (!skipChecks) {47 // If we're running on GitHub Actions, we can skip the authentication and48 // collaborator checks. Ref: https://bit.ly/2vsyRzu49 if (process.env.GITHUB_ACTIONS) {50 this.setContext({ username: process.env.GITHUB_ACTOR });51 } else {52 if (!(await this.isAuthenticated())) {53 throw e(`Could not authenticate with GitHub using environment variable "${tokenRef}".`, docs);54 }55 if (!(await this.isCollaborator())) {56 const { repository } = this.getContext('repo');57 const { username } = this.getContext();58 throw e(`User ${username} is not a collaborator for ${repository}.`, docs);59 }60 }61 }62 if (update) {63 const { latestTag } = this.config.getContext();64 try {65 const { id, upload_url, tag_name } = await this.getLatestRelease();66 if (latestTag === tag_name) {67 this.setContext({ isUpdate: true, isReleased: true, releaseId: id, upload_url });68 } else {69 this.setContext({ isUpdate: false });70 }71 } catch (error) {72 this.setContext({ isUpdate: false });73 }74 if (!this.getContext('isUpdate')) {75 this.log.warn(`GitHub release for tag ${latestTag} was not found. Creating new release.`);76 }77 }78 }79 async isAuthenticated() {80 if (this.config.isDryRun) return true;81 try {82 this.log.verbose('octokit users#getAuthenticated');83 const { data } = await this.client.users.getAuthenticated();84 this.setContext({ username: data.login });85 return true;86 } catch (error) {87 this.debug(error);88 return false;89 }90 }91 async isCollaborator() {92 if (this.config.isDryRun) return true;93 const { owner, project: repo } = this.getContext('repo');94 const { username } = this.getContext();95 try {96 const options = { owner, repo, username };97 this.log.verbose(`octokit repos#checkCollaborator (${username})`);98 await this.client.repos.checkCollaborator(options);99 return true;100 } catch (error) {101 this.debug(error);102 return false;103 }104 }105 async release() {106 const { assets } = this.options;107 const { isWeb, isUpdate } = this.getContext();108 const { isCI } = this.config;109 const type = isUpdate ? 'update' : 'create';110 const publishMethod = `${type}Release`;111 if (isWeb) {112 const task = () => this.createWebRelease();113 return this.step({ task, label: 'Generating link to GitHub Release web interface', prompt: 'release' });114 } else if (isCI) {115 await this.step({ task: () => this[publishMethod](), label: `GitHub ${type} release` });116 return this.step({ enabled: assets, task: () => this.uploadAssets(), label: 'GitHub upload assets' });117 } else {118 const release = async () => {119 await this[publishMethod]();120 return this.uploadAssets();121 };122 return this.step({ task: release, label: `GitHub ${type} release`, prompt: 'release' });123 }124 }125 handleError(err, bail) {126 const message = parseErrormsg(err);127 const githubError = new Error(message);128 this.log.verbose(err.errors);129 this.debug(err);130 if (!_.includes(RETRY_CODES, err.status)) {131 return bail(githubError);132 }133 throw githubError;134 }135 get client() {136 if (this._client) return this._client;137 const { proxy, timeout } = this.options;138 const host = this.options.host || this.getContext('repo.host');139 const isGitHub = host === 'github.com';140 const baseUrl = `https://${isGitHub ? 'api.github.com' : host}${isGitHub ? '' : '/api/v3'}`;141 const options = {142 baseUrl,143 auth: `token ${this.token}`,144 userAgent: `release-it/${pkg.version}`,145 log: this.config.isDebug ? console : null,146 request: {147 timeout148 }149 };150 if (proxy) {151 options.request.agent = new ProxyAgent(proxy);152 }153 const client = new Octokit(options);154 this._client = client;155 return client;156 }157 async getLatestRelease() {158 const { owner, project: repo } = this.getContext('repo');159 try {160 const options = { owner, repo };161 this.debug(options);162 const response = await this.client.repos.listReleases({ owner, repo, per_page: 1, page: 1 });163 this.debug(response.data[0]);164 return response.data[0];165 } catch (err) {166 return this.handleError(err, () => {});167 }168 }169 getOctokitReleaseOptions(options = {}) {170 const { owner, project: repo } = this.getContext('repo');171 const { releaseName, draft = false, preRelease = false, autoGenerate = false } = this.options;172 const { tagName } = this.config.getContext();173 const { version, releaseNotes, isUpdate } = this.getContext();174 const { isPreRelease } = parseVersion(version);175 const name = format(releaseName, this.config.getContext());176 const body = autoGenerate ? (isUpdate ? null : '') : releaseNotes;177 return Object.assign(options, {178 owner,179 repo,180 tag_name: tagName,181 name,182 body,183 draft,184 prerelease: isPreRelease || preRelease,185 generate_release_notes: autoGenerate186 });187 }188 retry(fn) {189 const { retryMinTimeout } = this.options;190 return retry(fn, {191 retries: 2,192 minTimeout: typeof retryMinTimeout === 'number' ? retryMinTimeout : DEFAULT_RETRY_MIN_TIMEOUT193 });194 }195 async createRelease() {196 const options = this.getOctokitReleaseOptions();197 const { isDryRun } = this.config;198 this.log.exec(`octokit repos.createRelease "${options.name}" (${options.tag_name})`, { isDryRun });199 if (isDryRun) {200 this.setContext({ isReleased: true, releaseUrl: this.getReleaseUrlFallback(options.tag_name) });201 return true;202 }203 return this.retry(async bail => {204 try {205 this.debug(options);206 const response = await this.client.repos.createRelease(options);207 this.debug(response.data);208 const { html_url, upload_url, id } = response.data;209 this.setContext({ isReleased: true, releaseId: id, releaseUrl: html_url, upload_url });210 this.log.verbose(`octokit repos.createRelease: done (${response.headers.location})`);211 return response.data;212 } catch (err) {213 return this.handleError(err, bail);214 }215 });216 }217 uploadAsset(filePath) {218 const url = this.getContext('upload_url');219 const name = path.basename(filePath);220 const contentType = mime.contentType(name) || 'application/octet-stream';221 const contentLength = fs.statSync(filePath).size;222 return this.retry(async bail => {223 try {224 const options = {225 url,226 data: fs.createReadStream(filePath),227 name,228 headers: {229 'content-type': contentType,230 'content-length': contentLength231 }232 };233 this.debug(options);234 const response = await this.client.repos.uploadReleaseAsset(options);235 this.debug(response.data);236 this.log.verbose(`octokit repos.uploadReleaseAsset: done (${response.data.browser_download_url})`);237 return response.data;238 } catch (err) {239 return this.handleError(err, bail);240 }241 });242 }243 uploadAssets() {244 const { assets } = this.options;245 const { isReleased } = this.getContext();246 const context = this.config.getContext();247 const { isDryRun } = this.config;248 this.log.exec('octokit repos.uploadReleaseAssets', assets, { isDryRun });249 if (!assets || !isReleased || isDryRun) {250 return true;251 }252 const patterns = _.castArray(assets).map(pattern => format(pattern, context));253 return globby(patterns).then(files => {254 if (!files.length) {255 this.log.warn(`octokit repos.uploadReleaseAssets: did not find "${assets}" relative to ${process.cwd()}`);256 }257 return Promise.all(files.map(filePath => this.uploadAsset(filePath)));258 });259 }260 getReleaseUrlFallback(tagName) {261 const { host, repository } = this.getContext('repo');262 return `https://${host}/${repository}/releases/tag/${tagName}`;263 }264 generateWebUrl() {265 const host = this.options.host || this.getContext('repo.host');266 const isGitHub = host === 'github.com';267 const options = this.getOctokitReleaseOptions();268 const url = newGithubReleaseUrl({269 user: options.owner,270 repo: options.repo,271 tag: options.tag_name,272 isPrerelease: options.prerelease,273 title: options.name,274 body: options.body275 });276 return isGitHub ? url : url.replace('github.com', host);277 }278 async createWebRelease() {279 const { isCI } = this.config;280 const { tagName } = this.config.getContext();281 const url = this.generateWebUrl();282 if (isCI) {283 this.setContext({ isReleased: true, releaseUrl: url });284 } else {285 await open(url);286 this.setContext({ isReleased: true, releaseUrl: this.getReleaseUrlFallback(tagName) });287 }288 }289 updateRelease() {290 const { isDryRun } = this.config;291 const release_id = this.getContext('releaseId');292 const options = this.getOctokitReleaseOptions({ release_id });293 this.log.exec(`octokit repos.updateRelease (${options.tag_name})`, { isDryRun });294 if (isDryRun) return true;295 return this.retry(async bail => {296 try {297 this.debug(options);298 const response = await this.client.repos.updateRelease(options);299 this.setContext({ releaseUrl: response.data.html_url });300 this.debug(response.data);301 this.log.verbose(`octokit repos.updateRelease: done (${response.headers.location})`);302 return true;303 } catch (err) {304 return this.handleError(err, bail);305 }306 });307 }308}...
synchrotronAdaptorPlugin.js
Source:synchrotronAdaptorPlugin.js
...69SynchrotronAdaptor.prototype.openHost = function(host,context,userParams,callback)70{71//#displayMessage('openHost:'+host);72 this.host = SynchrotronAdaptor.fullHostName(host);73 context = this.setContext(context,userParams,callback);74//#displayMessage('host:'+this.host);75 if(context.callback) {76 context.status = true;77 window.setTimeout(function() {callback(context,userParams);},0);78 }79 return true;80};81SynchrotronAdaptor.prototype.openWorkspace = function(workspace,context,userParams,callback)82{83//#displayMessage('openWorkspace:'+workspace);84 this.workspace = workspace;85 context = this.setContext(context,userParams,callback);86 if(context.callback) {87 context.status = true;88 window.setTimeout(function() {callback(context,userParams);},0);89 }90 return true;91};92SynchrotronAdaptor.prototype.getWorkspaceList = function(context,userParams,callback)93{94 context = this.setContext(context,userParams,callback);95//#displayMessage('getWorkspaceList');96 var list = [];97 list.push({title:'Main',name:'Main'});98 context.workspaces = list;99 if(context.callback) {100 context.status = true;101 window.setTimeout(function() {callback(context,userParams);},0);102 }103 return true;104};105SynchrotronAdaptor.prototype.getTiddlerList = function(context,userParams,callback)106{107//#console.log('SynchrotronAdaptor.getTiddlerList');108 context = this.setContext(context,userParams,callback);109 var path = SynchrotronAdaptor.contentPath();110 var entries = this.dirList(path);111 if(entries) {112 context.status = true;113 var list = [];114 var hash = {};115 for(var i=0; i<entries.length; i++) {116 var title = entries[i].name;117 if(title.match(/\.tiddler$/)) {118 title = title.replace(/\.tiddler$/,'');119 title = title.replace(/_/g,' ').replace(/%09/g,'\t').replace(/%23/g,'#').replace(/%2a/g,'*').replace(/%2c/g,',').replace(/%2f/g,'/').replace(/%3a/g,':').replace(/%3c/g,'<').replace(/%3e/g,'>').replace(/%3f/g,'?').replace(/%25/g,'%');120 var tiddler = new Tiddler(title);121 tiddler.modified = entries[i].modified;122 list.push(tiddler);123 hash[title] = tiddler;124 }125 }126 context.tiddlers = list;127 context.content = hash;128 } else {129 context.status = false;130 context.statusText = SynchrotronAdaptor.errorInFunctionMessage.format(['getTiddlerList']);131 }132 if(context.callback)133 window.setTimeout(function() {callback(context,userParams);},0);134 return context;135};136SynchrotronAdaptor.prototype.getTiddlerRevisionList = function(title,limit,context,userParams,callback)137// get a list of the revisions for a tiddler138{139//#console.log('SynchrotronAdaptor.getTiddlerRevisionList');140 context = this.setContext(context,userParams,callback);141 context.dateFormat = 'YYYY mmm 0DD 0hh:0mm:0ss';142 var tiddler = store.getTiddler(title);143//#console.log(tiddler);144 context.revisions = [];145 context.status = true;146 var uuid = tiddler.fields.uuid;147 var entries = synchrotron.fileRevisionsSorted(uuid);148 if(entries) {149//#console.log('ec:'+entries.length);150//#console.log('uuid:'+tiddler.fields.uuid);151 var list = [];152 for(var i=0; i<entries.length; i++) {153 var body = synchrotron.getBody(entries[i],uuid);154//#console.log('body:',body);155//#console.log('li:'+i);156//#console.log(body.title);157//#console.log(body.text);158 if(body.title) {159 title = body.title;160 tiddler = new Tiddler(title+i);161 tiddler.modified = SynchrotronAdaptor.dateFromTimestamp(entries[i].timestamp);162 tiddler.text = body.text.join('\n');163 tiddler.fields['server.page.revision'] = i;164 list.push(tiddler);165 }166 }167 context.revisions = list;168 } else {169 context.status = false;170 context.statusText = SynchrotronAdaptor.errorInFunctionMessage.format(['getTiddlerList']);171 }172 if(context.callback) {173 //# direct callback doesn't work, not sure why174 //#context.callback(context,context.userParams);175 window.setTimeout(function() {callback(context,userParams);},0);176 }177};178SynchrotronAdaptor.prototype.generateTiddlerInfo = function(tiddler)179{180 var info = {};181 var uriTemplate = '%0#%1';182 var host = SynchrotronAdaptor.fullHostName(this.host);183 info.uri = uriTemplate.format([host,tiddler.title]);184 return info;185};186SynchrotronAdaptor.prototype.getTiddlerRevision = function(title,revision,context,userParams,callback)187{188//#displayMessage('SynchrotronAdaptor.getTiddlerRev:' + context.modified);189 context = this.setContext(context,userParams,callback);190 if(revision)191 context.revision = revision;192 return this.getTiddler(title,context,userParams,callback);193};194SynchrotronAdaptor.prototype.getTiddler = function(title,context,userParams,callback)195{196//#console.log('SynchrotronAdaptor.getTiddler:',context.title,'rev:',context.revision);197 context = this.setContext(context,userParams,callback);198 if(title)199 context.title = title;200 var t = store.getTiddler(title);201 context.status = false;202 context.statusText = SynchrotronAdaptor.errorInFunctionMessage.format(['getTiddler',title]);203 if(context.revision) {204 var uuid = t.fields.uuid;205 var revision = parseInt(context.revision,10);206 var entries = synchrotron.fileRevisionsSorted(uuid);207 if(entries) {208 var body = synchrotron.getBody(entries[revision],uuid);209//#console.log('body:',body);210//#console.log('li:'+i);211//#console.log(body.title);...
RevisionAdaptorPlugin.js
Source:RevisionAdaptorPlugin.js
...29RevisionAdaptor.prototype.openWorkspace = function(workspace,context,userParams,callback)30{31//#displayMessage('openWorkspace:'+workspace);32 this.workspace = workspace;33 context = this.setContext(context,userParams,callback);34 if(context.callback) {35 context.status = true;36 window.setTimeout(function() {callback(context,userParams);},0);37 }38 return true;39};40RevisionAdaptor.prototype.getWorkspaceList = function(context,userParams,callback)41{42 context = this.setContext(context,userParams,callback);43//#displayMessage('getWorkspaceList');44 var list = [];45 list.push({title:'Main',name:'Main'});46 context.workspaces = list;47 if(context.callback) {48 context.status = true;49 window.setTimeout(function() {callback(context,userParams);},0);50 }51 return true;52};53RevisionAdaptor.prototype.getTiddlerList = function(context,userParams,callback)54{55//#console.log('RevisionAdaptor.getTiddlerList');56 context = this.setContext(context,userParams,callback);57 var path = RevisionAdaptor.contentPath();58 var entries = null;//this.dirList(path);59 if(entries) {60 context.status = true;61 var list = [];62 var hash = {};63 for(var i=0; i<entries.length; i++) {64 var title = entries[i].name;65 if(title.match(/\.tiddler$/)) {66 title = title.replace(/\.tiddler$/,'');67 title = title.replace(/_/g,' ').replace(/%09/g,'\t').replace(/%23/g,'#').replace(/%2a/g,'*').replace(/%2c/g,',').replace(/%2f/g,'/').replace(/%3a/g,':').replace(/%3c/g,'<').replace(/%3e/g,'>').replace(/%3f/g,'?').replace(/%25/g,'%');68 var tiddler = new Tiddler(title);69 tiddler.modified = entries[i].modified;70 list.push(tiddler);71 hash[title] = tiddler;72 }73 }74 context.tiddlers = list;75 context.content = hash;76 } else {77 context.status = false;78 context.statusText = RevisionAdaptor.errorInFunctionMessage.format(['getTiddlerList']);79 }80 if(context.callback)81 window.setTimeout(function() {callback(context,userParams);},0);82 return context;83};84RevisionAdaptor.prototype.getTiddlerRevisionList = function(title,limit,context,userParams,callback)85// get a list of the revisions for a tiddler86{87//#console.log('RevisionAdaptor.getTiddlerRevisionList');88 context = this.setContext(context,userParams,callback);89 context.dateFormat = 'YYYY mmm 0DD 0hh:0mm:0ss';90//#console.log(tiddler);91 context.revisions = [];92 context.status = true;93 var t = store.getTiddler(title);94 var uuid = t.fields.uuid;95 var entries = revisionStore.fileRevisionsSorted(uuid,title);96 if(entries) {97//#console.log('ec:'+entries.length);98//#console.log('uuid:'+uuid);99 var list = [];100 for(var i=0; i<entries.length; i++) {101 var tiddler = revisionStore.getTiddler(entries,i,uuid,title);102 if(tiddler)103 list.push(tiddler);104 }105 context.revisions = list;106 } else {107 context.status = false;108 context.statusText = RevisionAdaptor.errorInFunctionMessage.format(['getTiddlerList']);109 }110 if(context.callback) {111 //# direct callback doesn't work, not sure why112 //#context.callback(context,context.userParams);113 window.setTimeout(function() {callback(context,userParams);},0);114 }115};116RevisionAdaptor.prototype.generateTiddlerInfo = function(tiddler)117{118 var info = {};119 var uriTemplate = '%0#%1';120 var host = RevisionAdaptor.fullHostName(this.host);121 info.uri = uriTemplate.format([host,tiddler.title]);122 return info;123};124RevisionAdaptor.prototype.getTiddlerRevision = function(title,revision,context,userParams,callback)125{126//#displayMessage('RevisionAdaptor.getTiddlerRev:' + context.modified);127 context = this.setContext(context,userParams,callback);128 if(revision)129 context.revision = revision;130 return this.getTiddler(title,context,userParams,callback);131};132RevisionAdaptor.prototype.getTiddler = function(title,context,userParams,callback)133{134//#console.log('RevisionAdaptor.getTiddler:',title,'rev:',context.revision);135 context = this.setContext(context,userParams,callback);136 if(title)137 context.title = title;138 var t = store.getTiddler(title);139 context.status = false;140 context.statusText = RevisionAdaptor.errorInFunctionMessage.format(['getTiddler',title]);141 if(context.revision) {142 var uuid = t.fields.uuid;143 var entries = revisionStore.fileRevisionsSorted(uuid,title);144 if(entries) {145 var revisionIndex = parseInt(context.revision,10);146 var tiddler = revisionStore.getTiddler(entries,revisionIndex,uuid,title);147 if(tiddler) {148 context.tiddler = tiddler;149 context.status = true;150 context.statusText = '';151 }152 }153 } else {154 context.tiddler = t;155 context.status = true;156 context.statusText = '';157 }158 if(context.callback)159 window.setTimeout(function() {callback(context,userParams);},0);160 return context.status;161};162RevisionAdaptor.prototype.getTiddlerDiff = function(title,context,userParams,callback)163{164//#console.log('getTiddlerDiff:'+title+' r1:'+context.rev1+' r2:'+context.rev2);165 context = this.setContext(context,userParams,null);166 context.revision = context.rev1;167 this.getTiddler(title,context,userParams);168 var tiddler1 = context.tiddler;169 context.revision = context.rev2;170 this.getTiddler(title,context,userParams);171 var tiddler2 = context.tiddler;172 context.diff = [];173 if(Diff && Diff.diff_patch) {174 var r1 = tiddler1.text.split('\n');175 var r2 = tiddler1.text.split('\n');176 var x = Diff.diff_patch(r1,r2);177 }178 context.status = true;179 if(callback)...
izenda.integrate.js
Source:izenda.integrate.js
...11 };12 IzendaSynergy.setCurrentUserContext(currentUserContext);13 }14 RenderIzenda() {15 this.setContext();16 const dom = document.getElementById('izenda-root');17 IzendaSynergy.render(dom);18 console.log('Rendering Izenda');19 return dom;20 }21 RenderIzendaSettings() {22 this.setContext();23 const dom = document.getElementById('izenda-root');24 IzendaSynergy.renderSettingPage(dom);25 return dom;26 }27 28 RenderReportList() {29 this.setContext();30 const dom = document.getElementById('izenda-root');31 IzendaSynergy.renderReportPage(dom);32 return dom;33 }34 RenderReportParts() {35 this.setContext();36 IzendaSynergy.renderReportPart(document.getElementById('izenda-report-part1'), {37 "id": "[your 1st report part id]",38 });39 IzendaSynergy.renderReportPart(document.getElementById('izenda-report-part2'), {40 "id": "[your 2nd report part id]",41 });42 IzendaSynergy.renderReportPart(document.getElementById('izenda-report-part3'), {43 "id": "[your 3rd report part id]",44 });45 }46 UpdateResultReportPart(reportPartId, overridingFilterValue, containerId) {47 this.setContext();48 IzendaSynergy.renderReportPart(document.getElementById(containerId), {49 "id": reportPartId,50 "overridingFilterValue": overridingFilterValue,51 });52 }53 RenderSingleReportPart(reportPartId, containerId) {54 this.setContext();55 return IzendaSynergy.renderReportPart(document.getElementById(containerId), {56 "id": reportPartId57 });58 }59 RenderReportDesigner() {60 this.setContext();61 const dom = document.getElementById('izenda-root');62 IzendaSynergy.renderReportDesignerPage(dom);63 return dom;64 }65 RenderReportViewer(reportId, filters) {66 this.setContext();67 const dom = document.getElementById('izenda-root');68 IzendaSynergy.renderReportViewerPage(dom, reportId || '[your report id]', filters);69 return dom;70 }71 RenderReportCustomizedFilterViewer() {72 this.setContext();73 let filtersObj = {74 "filters": [],75 "overridingFilterValue":76 { // filter object to pass to api77 p1value: 50, // override filter value at position 1 which is applying on current report, change >30 to >5078 p2value: '30;#40' // override filter value at position 2 which is applying on current report, change beetween (20:50) to (30:40)79 }80 };81 let dom = document.getElementById('izenda-root');82 IzendaSynergy.renderReportViewerPage(dom, '[your report id]', filtersObj);83 return dom;84 }85 RenderDashboard() {86 this.setContext();87 let dom = document.getElementById('izenda-root');88 IzendaSynergy.renderDashboardPage(dom);89 return dom;90 }91 RenderDashboardDesigner() {92 this.setContext();93 let dom = document.getElementById('izenda-root');94 IzendaSynergy.renderNewDashboardPage(dom);95 return dom;96 }97 RenderDashboardViewer() {98 this.setContext();99 let dom = document.getElementById('izenda-root');100 IzendaSynergy.renderDashboardViewerPage(dom, '[your dashboard id]');101 return dom;102 }103 RenderExportViewer(reportPartId) {104 IzendaSynergy.setCurrentUserContext({ token: 'i7di+WoXTvjk47YhJGhictiBOqsUGIkbgd5B8XizEJ56DC4Ark8TO9YWUs50BH+HFnukB2H1pFZfza4psZCDOA==' })105 IzendaSynergy.renderReportPart(document.getElementById('export-root'), {106 "id": reportPartId,107 "useQueryParam": true,108 });109 }110 DestroyDom(dom) {111 this.setContext();112 IzendaSynergy.unmountComponent(dom);113 }...
cashtoxiacai.js
Source:cashtoxiacai.js
...44 update: function() {45 var e = this;46 clearTimeout(this.timeout);47 var i = getApp(), o = i.mainData.role.xiaCaiTime;48 if (o) if (o.length <= 1) this.setContext(1, "ææ æ¯èµ"); else if (i.checkFuncOpen(t.funcType.cash)) {49 for (var s = 60 * o[0], a = n.getServerTimeBaseSecond(), r = 86400 * Math.floor(a / 86400) - 3600 * n.getServerTimezone(), c = !1, h = o.length - 1; h >= 1; h--) {50 var f = r + 3600 * o[h];51 if (a >= f) {52 c = !0;53 var u = h == o.length - 1;54 if (a < f + s) {55 this.setContext(2, "æ¯èµç´æä¸...");56 break;57 }58 if (a >= f + s) {59 if (u) {60 var v = n.formatTime(r + 86400 + 3600 * o[1] - a);61 this.setContext(0, "ä¸ä¸åº " + v);62 } else {63 var m = r + 3600 * o[h + 1], d = n.formatTime(m - a);64 this.setContext(0, "ä¸ä¸åº " + d);65 }66 break;67 }68 }69 }70 if (!c) {71 var p = r + 3600 * o[1], g = n.formatTime(p - a);72 this.setContext(0, "ä¸ä¸åº " + g);73 }74 this.continue && (this.timeout = setTimeout(function() {75 e.update();76 }, 1e3));77 } else this.setContext(1, "ææ æ¯èµ"); else this.setContext(1, "ææ æ¯èµ");78 },79 onTapEntry: function() {80 o.markStatsEx({81 event: t.event_point.click_link,82 keyword1: "è¾ç"83 }), n.log("跳转æç¹ è¾ç");84 }85 }...
TrivialAdaptorPlugin.js
Source:TrivialAdaptorPlugin.js
...7TrivialAdaptor.serverType = 'trivial'; // MUST BE LOWER CASE8TrivialAdaptor.prototype.getWorkspaceList = function(context,userParams,callback)9{10 console.log("Jim1: getWorkspaceList " + context)11 context = this.setContext(context,userParams,callback);12 context.workspaces = [{title:"(default)"}];13 context.status = true;14 if(callback)15 window.setTimeout(function() {callback(context,userParams);},10);16 return true;17};18TrivialAdaptor.prototype.getTiddlerList = function(context,userParams,callback)19{20 console.log("Jim1: getTiddlerList " + context)21 context = this.setContext(context,userParams,callback);22 context.tiddlers = [];23 tiddler1 = new Tiddler("trivial1");24 tiddler1.fields['server.type'] = TrivialAdaptor.serverType;25 tiddler1.fields['server.workspace'] = "default";26 tiddler1.fields['server.page.revision'] = "2";27 context.tiddlers.push(tiddler1);28 tiddler2 = new Tiddler("trivial2");29 tiddler2.fields['server.type'] = TrivialAdaptor.serverType;30 tiddler2.fields['server.workspace'] = "default";31 tiddler2.fields['server.page.revision'] = "1";32 context.tiddlers.push(tiddler2);33 context.status = true;34 if(callback)35 window.setTimeout(function() {callback(context,userParams);},10);36 return true;37};38TrivialAdaptor.prototype.getTiddlerRevision = function(title,revision,context,userParams,callback)39{40 context = this.setContext(context,userParams,callback);41 if(revision) {42 context.revision = revision;43 }44 return this.getTiddler(title,context,userParams,callback);45};46TrivialAdaptor.prototype.generateTiddlerInfo = function(tiddler)47{48 var info = {};49 info.uri = tiddler.fields['server.host'] + "#" + tiddler.title;50 return info;51};52TrivialAdaptor.prototype.getTiddler = function(title,context,userParams,callback)53{54 console.log("Jim getTiddler " + title + " " + context);55 context = this.setContext(context,userParams,callback);56 context.title = title;57 context.complete = TrivialAdaptor.getTiddlerComplete;58 return context.complete(context,context.userParams);59};60TrivialAdaptor.getTiddlerComplete = function(context,userParams)61{62 if(context.title == "trivial1" || context.title == "trivial2") {63 t = new Tiddler(context.title);64 t.fields['server.type'] = TrivialAdaptor.serverType;65 t.fields['server.workspace'] = "default";66 t.fields['server.page.revision'] = "2";67 t.fields['server.host'] = "none";68 t.text = "Fake text for " + context.title69 t.tags = [];70 t.modifier = "modifier";71 t.modified = Date.convertFromYYYYMMDDHHMM("200808191720");72 t.created = Date.convertFromYYYYMMDDHHMM("200808191720");73 context.tiddler = t74 context.status = true;75 } else {76 context.statusText = "unknown tiddler: " + context.title77 context.status = false;78 }79 if(context.allowSynchronous) {80 context.isSynchronous = true;81 context.callback(context,userParams);82 } else {83 window.setTimeout(function() {context.callback(context,userParams);},10);84 }85 return true;86};87TrivialAdaptor.prototype.putTiddler = function(tiddler,context,userParams,callback)88{89 console.log("Jim putTiddler " + tiddler.title);90 context = this.setContext(context,userParams,callback);91 context.title = tiddler.title;92 context.status = true;93 if(callback)94 window.setTimeout(function() {callback(context,userParams);},10);95 return true;96};97config.adaptors[TrivialAdaptor.serverType] = TrivialAdaptor;...
MyTrips.js
Source:MyTrips.js
...47 * @param none48 * @return none49 */50 componentDidMount() {51 this.setContext();52 }53 /**54 * Sets the state of the object's rendered variables.55 *56 * @param none57 * @return none58 */59 componentWillMount() {60 this.setContext();61 }62 /**63 * Sets the state of the object's rendered variables.64 *65 * @param none66 * @return none67 */68 componentDidUpdate() {69 this.setContext();70 }71 /**72 * Renders the component73 *74 * @param none75 * @return HTML {HTML} The HTML of the rendered component76 */77 render() {78 if (!this.state.gotContext) {79 console.log('have not gotten context');80 this.setContext();81 return (82 <div> </div>83 )84 }85 else if (this.state.gotContext && this.state.authUser === null) {86 return (87 <Redirect to = {ROUTES.LANDING}/>88 )89 }90 else {91 return(92 <div id="centered-flex-masthead">93 <TripTabs/>94 </div>...
SecurityManagerGroupContext.js
Source:SecurityManagerGroupContext.js
...18 requestContext: function () {19 if (this._isRetrievingContext === true) {20 return;21 }22 this.setContext('PROF00000001', 'Read/Write Default');23 // var userOptionsService = Sage.Services.getService('UserOptions');24 // if (!userOptionsService) {25 // 26 // }27 //ToDo: call the useroptionsService to get the user option for this...28 },29 setContext: function (id, name) {30 this._currentContext.CurrentGroupID = id;31 this._currentContext.CurrentName = name;32 this._isRetrievingContext = false;33 },34 setCurrentGroup: function (id, name) {35 //ToDo: call useroptions service to set the user option for this...36 this.setContext(id, name);37 this.onCurrentGroupChanged({ current: this._currentContext });38 }39 });40 return grpContext;...
Using AI Code Generation
1const wd = require('wd');2const chai = require('chai');3const chaiAsPromised = require('chai-as-promised');4chai.use(chaiAsPromised);5const should = chai.should();6const assert = chai.assert;7const { exec } = require('child_process');8const driver = wd.promiseChainRemote({9});10const caps = {11};12driver.init(caps)13 .then(() => {14 return driver.setContext('NATIVE_APP');15 })16 .then(() => {17 return driver.elementByAccessibilityId('testElement');18 })19 .then((el) => {20 return el.click();21 })22 .then(() => {23 return driver.setContext('WEBVIEW_1');24 })25 .then(() => {26 return driver.elementByCss('#testElement');27 })28 .then((el) => {29 return el.click();30 })31 .catch((err) => {32 console.log(err);33 });34const wd = require('wd');35const chai = require('chai');36const chaiAsPromised = require('chai-as-promised');37chai.use(chaiAsPromised);38const should = chai.should();39const assert = chai.assert;40const { exec } = require('child_process');41const driver = wd.promiseChainRemote({42});43const caps = {44};45driver.init(caps)46 .then(() => {47 return driver.setContext('NATIVE_APP');48 })49 .then(() => {50 return driver.elementByAccessibilityId('testElement');51 })52 .then((el) => {53 return el.click();54 })55 .then(() => {56 return driver.setContext('WEBVIEW_1');57 })
Using AI Code Generation
1const { AppiumDriver } = require('appium-xcuitest-driver');2let driver = new AppiumDriver();3driver.setContext('NATIVE_APP');4const { XCUITestDriver } = require('appium-xcuitest-driver');5let driver = new XCUITestDriver();6driver.setContext('NATIVE_APP');7const { IOSDriver } = require('appium-ios-driver');8let driver = new IOSDriver();9driver.setContext('NATIVE_APP');10const { BaseDriver } = require('appium-base-driver');11let driver = new BaseDriver();12driver.setContext('NATIVE_APP');13const { Driver } = require('appium-base-driver');14let driver = new Driver();15driver.setContext('NATIVE_APP');16const { Appium } = require('appium');17let driver = new Appium();18driver.setContext('NATIVE_APP');19const { AppiumServer } = require('appium');20let driver = new AppiumServer();21driver.setContext('NATIVE_APP');22const { AppiumDriver } = require('appium');23let driver = new AppiumDriver();24driver.setContext('NATIVE_APP');25const { AppiumBaseDriver } = require('appium');26let driver = new AppiumBaseDriver();27driver.setContext('NATIVE_APP');28const { AppiumIOSDriver } = require('appium');29let driver = new AppiumIOSDriver();30driver.setContext('NATIVE_APP');31const { AppiumXCUITestDriver } = require('appium');32let driver = new AppiumXCUITestDriver();33driver.setContext('NATIVE_APP');34const { AppiumXcuitestDriver } = require('appium');
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!!