How to use this.setContext method in Appium Android Driver

Best JavaScript code snippet using appium-android-driver

Run Appium Android Driver automation tests on LambdaTest cloud grid

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

izenda.integrate.js

Source: izenda.integrate.js Github

copy
1import config from './config';
2
3//const IzendaSynergy = require('../../libs/IzendaSynergy/izenda_ui');
4import IzendaSynergy from '../../libs/IzendaSynergy/izenda_ui';
5
6export default class IzendaIntegrate {
7
8  DoIzendaConfig() {
9    IzendaSynergy.config(config);
10  }
11
12  setContext() {
13    const currentUserContext = {
14      token: localStorage.getItem("izendatoken")
15    };
16    IzendaSynergy.setCurrentUserContext(currentUserContext);
17  }
18
19  RenderIzenda() {
20    this.setContext();
21    const dom = document.getElementById('izenda-root');
22    IzendaSynergy.render(dom);
23    console.log('Rendering Izenda');
24    return dom;
25  }
26
27  RenderIzendaSettings() {
28    this.setContext();
29    const dom = document.getElementById('izenda-root');
30    IzendaSynergy.renderSettingPage(dom);
31    return dom;
32  }
33
34  
35
36
37  RenderReportList() {
38    this.setContext();
39    const dom = document.getElementById('izenda-root');
40    IzendaSynergy.renderReportPage(dom);
41    return dom;
42  }
43
44  RenderReportParts() {
45    this.setContext();
46    IzendaSynergy.renderReportPart(document.getElementById('izenda-report-part1'), {
47      "id": "[your 1st report part id]",
48    });
49
50    IzendaSynergy.renderReportPart(document.getElementById('izenda-report-part2'), {
51      "id": "[your 2nd report part id]",
52    });
53
54    IzendaSynergy.renderReportPart(document.getElementById('izenda-report-part3'), {
55      "id": "[your 3rd report part id]",
56    });
57  }
58
59  UpdateResultReportPart(reportPartId, overridingFilterValue, containerId) {
60    this.setContext();
61    IzendaSynergy.renderReportPart(document.getElementById(containerId), {
62      "id": reportPartId,
63      "overridingFilterValue": overridingFilterValue,
64    });
65  }
66
67  RenderSingleReportPart(reportPartId, containerId) {
68    this.setContext();
69    return IzendaSynergy.renderReportPart(document.getElementById(containerId), {
70      "id": reportPartId
71    });
72  }
73
74  RenderReportDesigner() {
75    this.setContext();
76    const dom = document.getElementById('izenda-root');
77    IzendaSynergy.renderReportDesignerPage(dom);
78    return dom;
79  }
80
81  RenderReportViewer(reportId, filters) {
82    this.setContext();
83    const dom = document.getElementById('izenda-root');
84    IzendaSynergy.renderReportViewerPage(dom, reportId || '[your report id]', filters);
85    return dom;
86  }
87
88  RenderReportCustomizedFilterViewer() {
89    this.setContext();
90    let filtersObj = {
91      "filters": [],
92      "overridingFilterValue":
93      {  // filter object to pass to api
94        p1value: 50,            // override filter value at position 1 which is applying on current report, change >30 to >50
95        p2value: '30;#40'       // override filter value at position 2 which is applying on current report, change beetween (20:50) to (30:40)
96      }
97    };
98
99    let dom = document.getElementById('izenda-root');
100    IzendaSynergy.renderReportViewerPage(dom, '[your report id]', filtersObj);
101    return dom;
102  }
103
104  RenderDashboard() {
105    this.setContext();
106    let dom = document.getElementById('izenda-root');
107    IzendaSynergy.renderDashboardPage(dom);
108    return dom;
109  }
110
111  RenderDashboardDesigner() {
112    this.setContext();
113    let dom = document.getElementById('izenda-root');
114    IzendaSynergy.renderNewDashboardPage(dom);
115    return dom;
116  }
117
118  RenderDashboardViewer() {
119    this.setContext();
120    let dom = document.getElementById('izenda-root');
121    IzendaSynergy.renderDashboardViewerPage(dom, '[your dashboard id]');
122    return dom;
123  }
124
125  RenderExportViewer(reportPartId) {
126    IzendaSynergy.setCurrentUserContext({ token: 'i7di+WoXTvjk47YhJGhictiBOqsUGIkbgd5B8XizEJ56DC4Ark8TO9YWUs50BH+HFnukB2H1pFZfza4psZCDOA==' })
127    IzendaSynergy.renderReportPart(document.getElementById('export-root'), {
128      "id": reportPartId,
129      "useQueryParam": true,
130    });
131  }
132
133  DestroyDom(dom) {
134    this.setContext();
135    IzendaSynergy.unmountComponent(dom);
136  }
137}
Full Screen

cashtoxiacai.js

Source: cashtoxiacai.js Github

copy
1var t = require("../../../const/consts.js"), e = require("../../../const/notifyConsts.js"), n = require("../../../util/util.js"), i = require("../../../net/connectNotify.js"), o = require("../../../net/messageNet.js");
2
3Component({
4    properties: {
5        visible: {
6            type: Boolean,
7            value: !0,
8            observer: function(t, e) {}
9        }
10    },
11    data: {
12        status: 1,
13        context: "暂无比赛",
14        contextColor: "#06e1ff"
15    },
16    created: function() {},
17    attached: function() {
18        var t = getApp();
19        t.eventDispatcher.addEventListener("onPageShow", this.onPageShow, this), t.eventDispatcher.addEventListener("onPageHide", this.onPageHide, this), 
20        i.register(e.ActionGameConf, this.onActionGameConf, this);
21    },
22    ready: function() {},
23    moved: function() {},
24    detached: function() {
25        var t = getApp();
26        t.eventDispatcher.removeEventListener("onPageShow", this.onPageShow, this), t.eventDispatcher.removeEventListener("onPageHide", this.onPageHide, this), 
27        i.remove(e.ActionGameConf, this.onActionGameConf, this);
28    },
29    methods: {
30        onPageShow: function(t) {
31            "cover" == t.data && (this.continue = !0, this.update());
32        },
33        onPageHide: function(t) {
34            "cover" == t.data && (this.continue = !1, clearTimeout(this.timeout));
35        },
36        onActionGameConf: function(t) {
37            this.update();
38        },
39        setContext: function(t, e) {
40            if (this.data.status != t || this.data.context != e) {
41                var n = {};
42                n.status = t, n.context = e, n.contextColor = 2 == t ? "#ffe500" : "#ffffff", this.setData(n);
43            }
44        },
45        update: function() {
46            var e = this;
47            clearTimeout(this.timeout);
48            var i = getApp(), o = i.mainData.role.xiaCaiTime;
49            if (o) if (o.length <= 1) this.setContext(1, "暂无比赛"); else if (i.checkFuncOpen(t.funcType.cash)) {
50                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--) {
51                    var f = r + 3600 * o[h];
52                    if (a >= f) {
53                        c = !0;
54                        var u = h == o.length - 1;
55                        if (a < f + s) {
56                            this.setContext(2, "比赛直播中...");
57                            break;
58                        }
59                        if (a >= f + s) {
60                            if (u) {
61                                var v = n.formatTime(r + 86400 + 3600 * o[1] - a);
62                                this.setContext(0, "下一场 " + v);
63                            } else {
64                                var m = r + 3600 * o[h + 1], d = n.formatTime(m - a);
65                                this.setContext(0, "下一场 " + d);
66                            }
67                            break;
68                        }
69                    }
70                }
71                if (!c) {
72                    var p = r + 3600 * o[1], g = n.formatTime(p - a);
73                    this.setContext(0, "下一场 " + g);
74                }
75                this.continue && (this.timeout = setTimeout(function() {
76                    e.update();
77                }, 1e3));
78            } else this.setContext(1, "暂无比赛"); else this.setContext(1, "暂无比赛");
79        },
80        onTapEntry: function() {
81            o.markStatsEx({
82                event: t.event_point.click_link,
83                keyword1: "虾猜"
84            }), n.log("跳转打点 虾猜");
85        }
86    }
87});
Full Screen

RevisionAdaptorPlugin.js

Source: RevisionAdaptorPlugin.js Github

copy
1/***
2|''Name:''|RevisionAdaptorPlugin|
3|''Description:''|Adaptor for working with a tiddler revision store|
4|''Author:''|Martin Budden (mjbudden (at) gmail (dot) com)|
5|''CodeRepository:''|http://svn.tiddlywiki.org/Trunk/contributors/MartinBudden/adaptors/RevisionAdaptorPlugin.js |
6|''Version:''|0.0.8|
7|''Date:''|Jun 11, 2008|
8|''Comments:''|Please make comments at http://groups.google.co.uk/group/TiddlyWikiDev |
9|''License:''|[[Creative Commons Attribution-ShareAlike 3.0 License|http://creativecommons.org/licenses/by-sa/3.0/]] |
10|''~CoreVersion:''|2.4.0|
11
12***/
13
14//{{{
15//# Ensure that the plugin is only installed once.
16if(!version.extensions.RevisionAdaptorPlugin) {
17version.extensions.RevisionAdaptorPlugin = {installed:true};
18
19function RevisionAdaptor()
20{
21}
22
23RevisionAdaptor.prototype = new AdaptorBase();
24
25RevisionAdaptor.serverType = 'revision';
26RevisionAdaptor.isLocal = true;
27RevisionAdaptor.errorInFunctionMessage = 'Error in function RevisionAdaptor.%0: %1';
28RevisionAdaptor.revisionSavedMessage = 'Revision %0 saved';
29RevisionAdaptor.baseRevision = 1000;
30
31RevisionAdaptor.minHostName = function(host)
32{
33	return host ? host.replace(/\\/,'/').host.replace(/^http:\/\//,'').replace(/\/$/,'') : ''; //'
34};
35
36RevisionAdaptor.prototype.openWorkspace = function(workspace,context,userParams,callback)
37{
38//#displayMessage('openWorkspace:'+workspace);
39	this.workspace = workspace;
40	context = this.setContext(context,userParams,callback);
41	if(context.callback) {
42		context.status = true;
43		window.setTimeout(function() {callback(context,userParams);},0);
44	}
45	return true;
46};
47
48RevisionAdaptor.prototype.getWorkspaceList = function(context,userParams,callback)
49{
50	context = this.setContext(context,userParams,callback);
51//#displayMessage('getWorkspaceList');
52	var list = [];
53	list.push({title:'Main',name:'Main'});
54	context.workspaces = list;
55	if(context.callback) {
56		context.status = true;
57		window.setTimeout(function() {callback(context,userParams);},0);
58	}
59	return true;
60};
61
62RevisionAdaptor.prototype.getTiddlerList = function(context,userParams,callback)
63{
64//#console.log('RevisionAdaptor.getTiddlerList');
65	context = this.setContext(context,userParams,callback);
66	var path = RevisionAdaptor.contentPath();
67	var entries = null;//this.dirList(path);
68	if(entries) {
69		context.status = true;
70		var list = [];
71		var hash = {};
72		for(var i=0; i<entries.length; i++) {
73			var title = entries[i].name;
74			if(title.match(/\.tiddler$/)) {
75				title = title.replace(/\.tiddler$/,'');
76				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,'%');
77				var tiddler = new Tiddler(title);
78				tiddler.modified = entries[i].modified;
79				list.push(tiddler);
80				hash[title] = tiddler;
81			}
82		}
83		context.tiddlers = list;
84		context.content = hash;
85	} else {
86		context.status = false;
87		context.statusText = RevisionAdaptor.errorInFunctionMessage.format(['getTiddlerList']);
88	}
89	if(context.callback)
90		window.setTimeout(function() {callback(context,userParams);},0);
91	return context;
92};
93
94RevisionAdaptor.prototype.getTiddlerRevisionList = function(title,limit,context,userParams,callback)
95// get a list of the revisions for a tiddler
96{
97//#console.log('RevisionAdaptor.getTiddlerRevisionList');
98	context = this.setContext(context,userParams,callback);
99	context.dateFormat = 'YYYY mmm 0DD 0hh:0mm:0ss';
100//#console.log(tiddler);
101	context.revisions = [];
102	context.status = true;
103	var t = store.getTiddler(title);
104	var uuid = t.fields.uuid;
105	var entries = revisionStore.fileRevisionsSorted(uuid,title);
106	if(entries) {
107//#console.log('ec:'+entries.length);
108//#console.log('uuid:'+uuid);
109		var list = [];
110		for(var i=0; i<entries.length; i++) {
111			var tiddler = revisionStore.getTiddler(entries,i,uuid,title);
112			if(tiddler)
113				list.push(tiddler);
114		}
115		context.revisions = list;
116	} else {
117		context.status = false;
118		context.statusText = RevisionAdaptor.errorInFunctionMessage.format(['getTiddlerList']);
119	}
120	if(context.callback) {
121		//# direct callback doesn't work, not sure why
122		//#context.callback(context,context.userParams);
123		window.setTimeout(function() {callback(context,userParams);},0);
124	}
125};
126
127RevisionAdaptor.prototype.generateTiddlerInfo = function(tiddler)
128{
129	var info = {};
130	var uriTemplate = '%0#%1';
131	var host = RevisionAdaptor.fullHostName(this.host);
132	info.uri = uriTemplate.format([host,tiddler.title]);
133	return info;
134};
135
136RevisionAdaptor.prototype.getTiddlerRevision = function(title,revision,context,userParams,callback)
137{
138//#displayMessage('RevisionAdaptor.getTiddlerRev:' + context.modified);
139	context = this.setContext(context,userParams,callback);
140	if(revision)
141		context.revision = revision;
142	return this.getTiddler(title,context,userParams,callback);
143};
144
145RevisionAdaptor.prototype.getTiddler = function(title,context,userParams,callback)
146{
147//#console.log('RevisionAdaptor.getTiddler:',title,'rev:',context.revision);
148	context = this.setContext(context,userParams,callback);
149	if(title)
150		context.title = title;
151	var t = store.getTiddler(title);
152
153	context.status = false;
154	context.statusText = RevisionAdaptor.errorInFunctionMessage.format(['getTiddler',title]);
155
156	if(context.revision) {
157		var uuid = t.fields.uuid;
158		var entries = revisionStore.fileRevisionsSorted(uuid,title);
159		if(entries) {
160			var revisionIndex = parseInt(context.revision,10);
161			var tiddler = revisionStore.getTiddler(entries,revisionIndex,uuid,title);
162			if(tiddler) {
163				context.tiddler = tiddler;
164				context.status = true;
165				context.statusText = '';
166			}
167		}
168	} else {
169		context.tiddler = t;
170		context.status = true;
171		context.statusText = '';
172	}
173	if(context.callback)
174		window.setTimeout(function() {callback(context,userParams);},0);
175	return context.status;
176};
177
178RevisionAdaptor.prototype.getTiddlerDiff = function(title,context,userParams,callback)
179{
180//#console.log('getTiddlerDiff:'+title+' r1:'+context.rev1+' r2:'+context.rev2);
181	context = this.setContext(context,userParams,null);
182	context.revision = context.rev1;
183	this.getTiddler(title,context,userParams);
184	var tiddler1 = context.tiddler;
185	context.revision = context.rev2;
186	this.getTiddler(title,context,userParams);
187	var tiddler2 = context.tiddler;
188	context.diff = [];
189	if(Diff && Diff.diff_patch) {
190		var r1 = tiddler1.text.split('\n');
191		var r2 = tiddler1.text.split('\n');
192		var x = Diff.diff_patch(r1,r2);
193	}
194	context.status = true;
195	if(callback)
196		window.setTimeout(function() {callback(context,userParams);},0);
197	return context.status;
198};
199
200
201config.adaptors[RevisionAdaptor.serverType] = RevisionAdaptor;
202} //# end of 'install only once'
203//}}}
204
Full Screen

SecurityManagerGroupContext.js

Source: SecurityManagerGroupContext.js Github

copy
1/*globals Sage, dojo, dojox, dijit, Simplate, window, Sys, define */
2define([
3    'Sage/Groups/GroupContextService',
4    'dojo/_base/declare'
5],
6function (groupContextService, declare) {
7    var grpContext = declare('Sage.MainView.SecurityMgr.SecurityManagerGroupContext', groupContextService, {
8        _currentContext: {},
9        constructor: function () {
10            dojo.mixin(this._currentContext, this._emptyContext);
11        },
12        getContext: function () {
13            if (this._currentContext.CurrentGroupID === null) {
14                this.requestContext();
15            }
16            return this._currentContext;
17        },
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;
41});
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Run JavaScript Tests on LambdaTest Cloud Grid

Execute automation tests with Appium Android Driver on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)