Best JavaScript code snippet using appium
medium.test.js
Source:medium.test.js
1import assert from 'assert';2import uuid from 'uuid';3import * as ga from './ga';4import { getHitLogs } from './server';5import * as injection from './injection';6let testId;7describe('Medium', () => {8 beforeEach((done) => {9 testId = uuid();10 done();11 });12 it('with utm_medium', (done) => {13 browser.get('http://localhost:8888/medium.html?utm_medium=cpc')14 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })15 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })16 .then(() => { browser.executeScript(ga.logHitData, testId); })17 .then(() => { browser.executeScript(ga.run, 'powerup:medium'); } )18 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })19 .then(() => {20 const hits = getHitLogs(testId);21 assert.equal(hits.length, 1);22 assert.equal(hits[0].t, 'pageview');23 assert.equal(hits[0].cs, undefined);24 })25 .then(done);26 });27 it('with utm_id', (done) => {28 browser.get('http://localhost:8888/medium.html?utm_id=test')29 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })30 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })31 .then(() => { browser.executeScript(ga.logHitData, testId); })32 .then(() => { browser.executeScript(ga.run, 'powerup:medium'); } )33 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })34 .then(() => {35 const hits = getHitLogs(testId);36 assert.equal(hits.length, 1);37 assert.equal(hits[0].t, 'pageview');38 assert.equal(hits[0].cs, undefined);39 })40 .then(done);41 });42 it('referrer = https://t.co/test.html', (done) => {43 browser.get('http://localhost:8888/medium.html')44 .then(() => { browser.executeScript(injection.updateReferrer, 'https://t.co/test.html'); })45 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })46 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })47 .then(() => { browser.executeScript(ga.logHitData, testId); })48 .then(() => { browser.executeScript(ga.run, 'powerup:medium'); } )49 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })50 .then(() => {51 const hits = getHitLogs(testId);52 assert.equal(hits.length, 1);53 assert.equal(hits[0].t, 'pageview');54 assert.equal(hits[0].cm, 'social');55 })56 .then(done);57 }); 58 it('referrer = https://m.facebook.com/test.html', (done) => {59 browser.get('http://localhost:8888/medium.html')60 .then(() => { browser.executeScript(injection.updateReferrer, 'https://m.facebook.com/test.html'); })61 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })62 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })63 .then(() => { browser.executeScript(ga.logHitData, testId); })64 .then(() => { browser.executeScript(ga.run, 'powerup:medium'); } )65 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })66 .then(() => {67 const hits = getHitLogs(testId);68 assert.equal(hits.length, 1);69 assert.equal(hits[0].t, 'pageview');70 assert.equal(hits[0].cm, 'social');71 })72 .then(done);73 }); 74 it('referrer = https://l.facebook.com/test.html', (done) => {75 browser.get('http://localhost:8888/medium.html')76 .then(() => { browser.executeScript(injection.updateReferrer, 'https://l.facebook.com/test.html'); })77 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })78 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })79 .then(() => { browser.executeScript(ga.logHitData, testId); })80 .then(() => { browser.executeScript(ga.run, 'powerup:medium'); } )81 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })82 .then(() => {83 const hits = getHitLogs(testId);84 assert.equal(hits.length, 1);85 assert.equal(hits[0].t, 'pageview');86 assert.equal(hits[0].cm, 'social');87 })88 .then(done);89 }); 90 it('referrer = https://lm.facebook.com/test.html', (done) => {91 browser.get('http://localhost:8888/medium.html')92 .then(() => { browser.executeScript(injection.updateReferrer, 'https://lm.facebook.com/test.html'); })93 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })94 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })95 .then(() => { browser.executeScript(ga.logHitData, testId); })96 .then(() => { browser.executeScript(ga.run, 'powerup:medium'); } )97 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })98 .then(() => {99 const hits = getHitLogs(testId);100 assert.equal(hits.length, 1);101 assert.equal(hits[0].t, 'pageview');102 assert.equal(hits[0].cm, 'social');103 })104 .then(done);105 }); 106 it('referrer = https://facebook.com/test.html', (done) => {107 browser.get('http://localhost:8888/medium.html')108 .then(() => { browser.executeScript(injection.updateReferrer, 'https://facebook.com/test.html'); })109 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })110 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })111 .then(() => { browser.executeScript(ga.logHitData, testId); })112 .then(() => { browser.executeScript(ga.run, 'powerup:medium'); } )113 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })114 .then(() => {115 const hits = getHitLogs(testId);116 assert.equal(hits.length, 1);117 assert.equal(hits[0].t, 'pageview');118 assert.equal(hits[0].cm, 'social');119 })120 .then(done);121 }); 122 it('referrer = https://test.mail.yahoo.co.jp/test.html', (done) => {123 browser.get('http://localhost:8888/medium.html')124 .then(() => { browser.executeScript(injection.updateReferrer, 'https://test.mail.yahoo.co.jp/test.html'); })125 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })126 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })127 .then(() => { browser.executeScript(ga.logHitData, testId); })128 .then(() => { browser.executeScript(ga.run, 'powerup:medium'); } )129 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })130 .then(() => {131 const hits = getHitLogs(testId);132 assert.equal(hits.length, 1);133 assert.equal(hits[0].t, 'pageview');134 assert.equal(hits[0].cm, 'email');135 })136 .then(done);137 }); 138 it('referrer = https://test.mail.live.com/test.html', (done) => {139 browser.get('http://localhost:8888/medium.html')140 .then(() => { browser.executeScript(injection.updateReferrer, 'https://test.mail.live.com/test.html'); })141 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })142 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })143 .then(() => { browser.executeScript(ga.logHitData, testId); })144 .then(() => { browser.executeScript(ga.run, 'powerup:medium'); } )145 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })146 .then(() => {147 const hits = getHitLogs(testId);148 assert.equal(hits.length, 1);149 assert.equal(hits[0].t, 'pageview');150 assert.equal(hits[0].cm, 'email');151 })152 .then(done);153 }); 154 it('referrer = https://test.mail.google.com/test.html', (done) => {155 browser.get('http://localhost:8888/medium.html')156 .then(() => { browser.executeScript(injection.updateReferrer, 'https://test.mail.google.com/test.html'); })157 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })158 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })159 .then(() => { browser.executeScript(ga.logHitData, testId); })160 .then(() => { browser.executeScript(ga.run, 'powerup:medium'); } )161 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })162 .then(() => {163 const hits = getHitLogs(testId);164 assert.equal(hits.length, 1);165 assert.equal(hits[0].t, 'pageview');166 assert.equal(hits[0].cm, 'email');167 })168 .then(done);169 }); 170 it('referrer = https://test.alpha-mail.ne.jp/test.html', (done) => {171 browser.get('http://localhost:8888/medium.html')172 .then(() => { browser.executeScript(injection.updateReferrer, 'https://test.alpha-mail.ne.jp/test.html'); })173 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })174 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })175 .then(() => { browser.executeScript(ga.logHitData, testId); })176 .then(() => { browser.executeScript(ga.run, 'powerup:medium'); } )177 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })178 .then(() => {179 const hits = getHitLogs(testId);180 assert.equal(hits.length, 1);181 assert.equal(hits[0].t, 'pageview');182 assert.equal(hits[0].cm, 'email');183 })184 .then(done);185 }); 186 it('referrer = https://email.exite.co.jp/test.html', (done) => {187 browser.get('http://localhost:8888/medium.html')188 .then(() => { browser.executeScript(injection.updateReferrer, 'https://email.exite.co.jp/test.html'); })189 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })190 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })191 .then(() => { browser.executeScript(ga.logHitData, testId); })192 .then(() => { browser.executeScript(ga.run, 'powerup:medium'); } )193 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })194 .then(() => {195 const hits = getHitLogs(testId);196 assert.equal(hits.length, 1);197 assert.equal(hits[0].t, 'pageview');198 assert.equal(hits[0].cm, 'email');199 })200 .then(done);201 }); 202 it('referrer = https://outlook.office365.com/test.html', (done) => {203 browser.get('http://localhost:8888/medium.html')204 .then(() => { browser.executeScript(injection.updateReferrer, 'https://outlook.office365.com/test.html'); })205 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })206 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })207 .then(() => { browser.executeScript(ga.logHitData, testId); })208 .then(() => { browser.executeScript(ga.run, 'powerup:medium'); } )209 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })210 .then(() => {211 const hits = getHitLogs(testId);212 assert.equal(hits.length, 1);213 assert.equal(hits[0].t, 'pageview');214 assert.equal(hits[0].cm, 'email');215 })216 .then(done);217 }); 218 it('referrer = https://mail.ocn.ne.jp/test.html', (done) => {219 browser.get('http://localhost:8888/medium.html')220 .then(() => { browser.executeScript(injection.updateReferrer, 'https://mail.ocn.ne.jp/test.html'); })221 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })222 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })223 .then(() => { browser.executeScript(ga.logHitData, testId); })224 .then(() => { browser.executeScript(ga.run, 'powerup:medium'); } )225 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })226 .then(() => {227 const hits = getHitLogs(testId);228 assert.equal(hits.length, 1);229 assert.equal(hits[0].t, 'pageview');230 assert.equal(hits[0].cm, 'email');231 })232 .then(done);233 }); 234 it('referrer = https://webmail.sso.biglobe.ne.jp/test.html', (done) => {235 browser.get('http://localhost:8888/medium.html')236 .then(() => { browser.executeScript(injection.updateReferrer, 'https://webmail.sso.biglobe.ne.jp/test.html'); })237 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })238 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })239 .then(() => { browser.executeScript(ga.logHitData, testId); })240 .then(() => { browser.executeScript(ga.run, 'powerup:medium'); } )241 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })242 .then(() => {243 const hits = getHitLogs(testId);244 assert.equal(hits.length, 1);245 assert.equal(hits[0].t, 'pageview');246 assert.equal(hits[0].cm, 'email');247 })248 .then(done);249 }); 250 it('referrer = https://webmail.so-net.ne.jp/test.html', (done) => {251 browser.get('http://localhost:8888/medium.html')252 .then(() => { browser.executeScript(injection.updateReferrer, 'https://webmail.so-net.ne.jp/test.html'); })253 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })254 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })255 .then(() => { browser.executeScript(ga.logHitData, testId); })256 .then(() => { browser.executeScript(ga.run, 'powerup:medium'); } )257 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })258 .then(() => {259 const hits = getHitLogs(testId);260 assert.equal(hits.length, 1);261 assert.equal(hits[0].t, 'pageview');262 assert.equal(hits[0].cm, 'email');263 })264 .then(done);265 }); 266 it('referrer = https://eowebmail.eonet.jp/test.html', (done) => {267 browser.get('http://localhost:8888/medium.html')268 .then(() => { browser.executeScript(injection.updateReferrer, 'https://eowebmail.eonet.jp/test.html'); })269 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })270 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })271 .then(() => { browser.executeScript(ga.logHitData, testId); })272 .then(() => { browser.executeScript(ga.run, 'powerup:medium'); } )273 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })274 .then(() => {275 const hits = getHitLogs(testId);276 assert.equal(hits.length, 1);277 assert.equal(hits[0].t, 'pageview');278 assert.equal(hits[0].cm, 'email');279 })280 .then(done);281 }); 282 it('referrer = https://mail.auone-net.jp/test.html', (done) => {283 browser.get('http://localhost:8888/medium.html')284 .then(() => { browser.executeScript(injection.updateReferrer, 'https://mail.auone-net.jp/test.html'); })285 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })286 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })287 .then(() => { browser.executeScript(ga.logHitData, testId); })288 .then(() => { browser.executeScript(ga.run, 'powerup:medium'); } )289 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })290 .then(() => {291 const hits = getHitLogs(testId);292 assert.equal(hits.length, 1);293 assert.equal(hits[0].t, 'pageview');294 assert.equal(hits[0].cm, 'email');295 })296 .then(done);297 }); 298 it('referrer = https://mail.goo.jp/test.html', (done) => {299 browser.get('http://localhost:8888/medium.html')300 .then(() => { browser.executeScript(injection.updateReferrer, 'https://mail.goo.jp/test.html'); })301 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })302 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })303 .then(() => { browser.executeScript(ga.logHitData, testId); })304 .then(() => { browser.executeScript(ga.run, 'powerup:medium'); } )305 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })306 .then(() => {307 const hits = getHitLogs(testId);308 assert.equal(hits.length, 1);309 assert.equal(hits[0].t, 'pageview');310 assert.equal(hits[0].cm, 'email');311 })312 .then(done);313 }); 314 it('referrer = https://mail.commufa.jp/test.html', (done) => {315 browser.get('http://localhost:8888/medium.html')316 .then(() => { browser.executeScript(injection.updateReferrer, 'https://mail.commufa.jp/test.html'); })317 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })318 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })319 .then(() => { browser.executeScript(ga.logHitData, testId); })320 .then(() => { browser.executeScript(ga.run, 'powerup:medium'); } )321 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })322 .then(() => {323 const hits = getHitLogs(testId);324 assert.equal(hits.length, 1);325 assert.equal(hits[0].t, 'pageview');326 assert.equal(hits[0].cm, 'email');327 })328 .then(done);329 }); 330 it('referrer = https://webmail.cyberhome.ne.jp/test.html', (done) => {331 browser.get('http://localhost:8888/medium.html')332 .then(() => { browser.executeScript(injection.updateReferrer, 'https://webmail.cyberhome.ne.jp/test.html'); })333 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })334 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })335 .then(() => { browser.executeScript(ga.logHitData, testId); })336 .then(() => { browser.executeScript(ga.run, 'powerup:medium'); } )337 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })338 .then(() => {339 const hits = getHitLogs(testId);340 assert.equal(hits.length, 1);341 assert.equal(hits[0].t, 'pageview');342 assert.equal(hits[0].cm, 'email');343 })344 .then(done);345 }); 346 it('referrer = https://mail45.bizmail123.com/test.html', (done) => {347 browser.get('http://localhost:8888/medium.html')348 .then(() => { browser.executeScript(injection.updateReferrer, 'https://mail45.bizmail123.com/test.html'); })349 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })350 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })351 .then(() => { browser.executeScript(ga.logHitData, testId); })352 .then(() => { browser.executeScript(ga.run, 'powerup:medium'); } )353 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })354 .then(() => {355 const hits = getHitLogs(testId);356 assert.equal(hits.length, 1);357 assert.equal(hits[0].t, 'pageview');358 assert.equal(hits[0].cm, 'email');359 })360 .then(done);361 }); 362 it('referrer = https://reader.livedoor.com/test.html', (done) => {363 browser.get('http://localhost:8888/medium.html')364 .then(() => { browser.executeScript(injection.updateReferrer, 'https://reader.livedoor.com/test.html'); })365 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })366 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })367 .then(() => { browser.executeScript(ga.logHitData, testId); })368 .then(() => { browser.executeScript(ga.run, 'powerup:medium'); } )369 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })370 .then(() => {371 const hits = getHitLogs(testId);372 assert.equal(hits.length, 1);373 assert.equal(hits[0].t, 'pageview');374 assert.equal(hits[0].cm, 'rss');375 })376 .then(done);377 }); 378 it('referrer = https://feedly.com/test.html', (done) => {379 browser.get('http://localhost:8888/medium.html')380 .then(() => { browser.executeScript(injection.updateReferrer, 'https://feedly.com/test.html'); })381 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })382 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })383 .then(() => { browser.executeScript(ga.logHitData, testId); })384 .then(() => { browser.executeScript(ga.run, 'powerup:medium'); } )385 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })386 .then(() => {387 const hits = getHitLogs(testId);388 assert.equal(hits.length, 1);389 assert.equal(hits[0].t, 'pageview');390 assert.equal(hits[0].cm, 'rss');391 })392 .then(done);393 }); 394 it('referrer = https://feeds.feedburner.com/test.html', (done) => {395 browser.get('http://localhost:8888/medium.html')396 .then(() => { browser.executeScript(injection.updateReferrer, 'https://feeds.feedburner.com/test.html'); })397 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })398 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })399 .then(() => { browser.executeScript(ga.logHitData, testId); })400 .then(() => { browser.executeScript(ga.run, 'powerup:medium'); } )401 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })402 .then(() => {403 const hits = getHitLogs(testId);404 assert.equal(hits.length, 1);405 assert.equal(hits[0].t, 'pageview');406 assert.equal(hits[0].cm, 'rss');407 })408 .then(done);409 }); 410 it('referrer = https://www.google.co.jp/test.html', (done) => {411 browser.get('http://localhost:8888/medium.html')412 .then(() => { browser.executeScript(injection.updateReferrer, 'https://www.google.co.jp/test.html'); })413 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })414 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })415 .then(() => { browser.executeScript(ga.logHitData, testId); })416 .then(() => { browser.executeScript(ga.run, 'powerup:medium'); } )417 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })418 .then(() => {419 const hits = getHitLogs(testId);420 assert.equal(hits.length, 1);421 assert.equal(hits[0].t, 'pageview');422 assert.equal(hits[0].cs, undefined);423 })424 .then(done);425 }); ...
spamfilter.test.js
Source:spamfilter.test.js
1import assert from 'assert';2import uuid from 'uuid';3import * as ga from './ga';4import { getHitLogs } from './server';5import * as injection from './injection';6let testId;7let options = {8 dimension: {9 index: 1,10 value: 'Referrer Spam Avoidance',11 },12};13describe('SPAM Filter', () => {14 beforeEach((done) => {15 testId = uuid();16 done();17 });18 it('referrer = www.google.co.jp', (done) => {19 browser.get('http://localhost:8888/spamfilter.html')20 .then(() => { browser.executeScript(injection.updateReferrer, 'https://www.google.co.jp'); })21 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })22 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })23 .then(() => { browser.executeScript(ga.logHitData, testId); })24 .then(() => { browser.executeScript(ga.run, 'powerup:spamFilter', options); } )25 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })26 .then(() => {27 const hits = getHitLogs(testId);28 assert.equal(hits.length, 1);29 assert.equal(hits[0].t, 'pageview');30 assert.equal(hits[0].cd1, 'Referrer Spam Avoidance');31 assert.equal(hits[0].dr, 'https://www.google.co.jp');32 })33 .then(done);34 });35 it('referrer = https://100dollars-seo.com', (done) => {36 browser.get('http://localhost:8888/spamfilter.html')37 .then(() => { browser.executeScript(injection.updateReferrer, 'https://100dollars-seo.com'); })38 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })39 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })40 .then(() => { browser.executeScript(ga.logHitData, testId); })41 .then(() => { browser.executeScript(ga.run, 'powerup:spamFilter', options); } )42 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })43 .then(() => {44 const hits = getHitLogs(testId);45 assert.equal(hits.length, 1);46 assert.equal(hits[0].t, 'pageview');47 assert.equal(hits[0].cd1, 'Spam Traffic');48 assert.equal(hits[0].dr, 'https://100dollars-seo.com');49 })50 .then(done);51 });52 it('referrer = https://100dollars-seo.com/index.html', (done) => {53 browser.get('http://localhost:8888/spamfilter.html')54 .then(() => { browser.executeScript(injection.updateReferrer, 'https://100dollars-seo.com/index.html'); })55 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })56 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })57 .then(() => { browser.executeScript(ga.logHitData, testId); })58 .then(() => { browser.executeScript(ga.run, 'powerup:spamFilter', options); } )59 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })60 .then(() => {61 const hits = getHitLogs(testId);62 assert.equal(hits.length, 1);63 assert.equal(hits[0].t, 'pageview');64 assert.equal(hits[0].cd1, 'Spam Traffic');65 assert.equal(hits[0].dr, 'https://100dollars-seo.com/index.html');66 })67 .then(done);68 });69 it('referrer = https://semaltmedia.com/index.html', (done) => {70 browser.get('http://localhost:8888/spamfilter.html')71 .then(() => { browser.executeScript(injection.updateReferrer, 'https://semaltmedia.com/index.html'); })72 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })73 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })74 .then(() => { browser.executeScript(ga.logHitData, testId); })75 .then(() => { browser.executeScript(ga.run, 'powerup:spamFilter', options); } )76 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })77 .then(() => {78 const hits = getHitLogs(testId);79 assert.equal(hits.length, 1);80 assert.equal(hits[0].t, 'pageview');81 assert.equal(hits[0].cd1, 'Spam Traffic');82 assert.equal(hits[0].dr, 'https://semaltmedia.com/index.html');83 })84 .then(done);85 });86 it('referrer = https://videos-for-your-business.com/index.html', (done) => {87 browser.get('http://localhost:8888/spamfilter.html')88 .then(() => { browser.executeScript(injection.updateReferrer, 'https://videos-for-your-business.com/index.html'); })89 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })90 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })91 .then(() => { browser.executeScript(ga.logHitData, testId); })92 .then(() => { browser.executeScript(ga.run, 'powerup:spamFilter', options); } )93 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })94 .then(() => {95 const hits = getHitLogs(testId);96 assert.equal(hits.length, 1);97 assert.equal(hits[0].t, 'pageview');98 assert.equal(hits[0].cd1, 'Spam Traffic');99 assert.equal(hits[0].dr, 'https://videos-for-your-business.com/index.html');100 })101 .then(done);102 });103 it('referrer = https://buttons-for-website.com/index.html', (done) => {104 browser.get('http://localhost:8888/spamfilter.html')105 .then(() => { browser.executeScript(injection.updateReferrer, 'https://buttons-for-website.com/index.html'); })106 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })107 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })108 .then(() => { browser.executeScript(ga.logHitData, testId); })109 .then(() => { browser.executeScript(ga.run, 'powerup:spamFilter', options); } )110 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })111 .then(() => {112 const hits = getHitLogs(testId);113 assert.equal(hits.length, 1);114 assert.equal(hits[0].t, 'pageview');115 assert.equal(hits[0].cd1, 'Spam Traffic');116 assert.equal(hits[0].dr, 'https://buttons-for-website.com/index.html');117 })118 .then(done);119 });120 it('referrer = https://success-seo.com/index.html', (done) => {121 browser.get('http://localhost:8888/spamfilter.html')122 .then(() => { browser.executeScript(injection.updateReferrer, 'https://success-seo.com/index.html'); })123 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })124 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })125 .then(() => { browser.executeScript(ga.logHitData, testId); })126 .then(() => { browser.executeScript(ga.run, 'powerup:spamFilter', options); } )127 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })128 .then(() => {129 const hits = getHitLogs(testId);130 assert.equal(hits.length, 1);131 assert.equal(hits[0].t, 'pageview');132 assert.equal(hits[0].cd1, 'Spam Traffic');133 assert.equal(hits[0].dr, 'https://success-seo.com/index.html');134 })135 .then(done);136 });137 it('referrer = https://video--production.com/index.html', (done) => {138 browser.get('http://localhost:8888/spamfilter.html')139 .then(() => { browser.executeScript(injection.updateReferrer, 'https://video--production.com/index.html'); })140 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })141 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })142 .then(() => { browser.executeScript(ga.logHitData, testId); })143 .then(() => { browser.executeScript(ga.run, 'powerup:spamFilter', options); } )144 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })145 .then(() => {146 const hits = getHitLogs(testId);147 assert.equal(hits.length, 1);148 assert.equal(hits[0].t, 'pageview');149 assert.equal(hits[0].cd1, 'Spam Traffic');150 assert.equal(hits[0].dr, 'https://video--production.com/index.html');151 })152 .then(done);153 });...
index-test.js
Source:index-test.js
...32 testId = uuid();33 log = bindLogAccessors(testId);34 });35 afterEach(() => {36 browser.execute(ga.run, 'cleanUrlTracker:remove');37 browser.execute(ga.run, 'eventTracker:remove');38 browser.execute(ga.run, 'impressionTracker:remove');39 browser.execute(ga.run, 'mediaQueryTracker:remove');40 browser.execute(ga.run, 'outboundFormTracker:remove');41 browser.execute(ga.run, 'outboundLinkTracker:remove');42 browser.execute(ga.run, 'pageVisibilityTracker:remove');43 browser.execute(ga.run, 'socialWidgetTracker:remove');44 browser.execute(ga.run, 'urlChangeTracker:remove');45 browser.execute(ga.run, 'maxScrollTracker:remove');46 browser.execute(ga.run, 'remove');47 log.removeHits();48 });49 it('provides all plugins', () => {50 browser.url('/test/e2e/fixtures/autotrack.html');51 const gaplugins = browser.execute(ga.getProvidedPlugins).value;52 assert(gaplugins.includes('CleanUrlTracker'));53 assert(gaplugins.includes('EventTracker'));54 assert(gaplugins.includes('ImpressionTracker'));55 assert(gaplugins.includes('MediaQueryTracker'));56 assert(gaplugins.includes('OutboundFormTracker'));57 assert(gaplugins.includes('OutboundLinkTracker'));58 assert(gaplugins.includes('PageVisibilityTracker'));59 assert(gaplugins.includes('SocialWidgetTracker'));60 assert(gaplugins.includes('UrlChangeTracker'));61 assert(gaplugins.includes('MaxScrollTracker'));62 });63 it('provides plugins even if sourced before the tracking snippet',64 () => {65 browser.url('/test/e2e/fixtures/autotrack-reorder.html');66 const gaplugins = browser.execute(ga.getProvidedPlugins).value;67 assert(gaplugins.includes('CleanUrlTracker'));68 assert(gaplugins.includes('ImpressionTracker'));69 assert(gaplugins.includes('EventTracker'));70 assert(gaplugins.includes('MediaQueryTracker'));71 assert(gaplugins.includes('OutboundFormTracker'));72 assert(gaplugins.includes('OutboundLinkTracker'));73 assert(gaplugins.includes('PageVisibilityTracker'));74 assert(gaplugins.includes('SocialWidgetTracker'));75 assert(gaplugins.includes('UrlChangeTracker'));76 assert(gaplugins.includes('MaxScrollTracker'));77 });78 it('works with all plugins required', () => {79 browser.url('/test/e2e/fixtures/autotrack.html');80 browser.execute(ga.run, 'create', DEFAULT_TRACKER_FIELDS);81 browser.execute(ga.logHitData, testId);82 browser.execute(ga.run, 'require', 'cleanUrlTracker');83 browser.execute(ga.run, 'require', 'eventTracker');84 browser.execute(ga.run, 'require', 'impressionTracker');85 browser.execute(ga.run, 'require', 'outboundLinkTracker');86 browser.execute(ga.run, 'require', 'mediaQueryTracker');87 browser.execute(ga.run, 'require', 'outboundFormTracker');88 browser.execute(ga.run, 'require', 'pageVisibilityTracker');89 browser.execute(ga.run, 'require', 'socialWidgetTracker');90 browser.execute(ga.run, 'require', 'urlChangeTracker');91 browser.execute(ga.run, 'require', 'maxScrollTracker');92 browser.execute(ga.run, 'send', 'pageview');93 browser.waitUntil(log.hitCountIsAtLeast(1));94 const lastHit = log.getHits().slice(-1)[0];95 assert.strictEqual(lastHit.t, 'pageview');96 });97 it('works when renaming the global object', () => {98 browser.url('/test/e2e/fixtures/autotrack-rename.html');99 browser.execute(ga.run, 'create', DEFAULT_TRACKER_FIELDS);100 browser.execute(ga.logHitData, testId);101 browser.execute(ga.run, 'require', 'cleanUrlTracker');102 browser.execute(ga.run, 'require', 'eventTracker');103 browser.execute(ga.run, 'require', 'impressionTracker');104 browser.execute(ga.run, 'require', 'outboundLinkTracker');105 browser.execute(ga.run, 'require', 'mediaQueryTracker');106 browser.execute(ga.run, 'require', 'outboundFormTracker');107 browser.execute(ga.run, 'require', 'pageVisibilityTracker');108 browser.execute(ga.run, 'require', 'socialWidgetTracker');109 browser.execute(ga.run, 'require', 'urlChangeTracker');110 browser.execute(ga.run, 'require', 'maxScrollTracker');111 browser.execute(ga.run, 'send', 'pageview');112 browser.waitUntil(log.hitCountIsAtLeast(1));113 const lastHit = log.getHits().slice(-1)[0];114 assert.strictEqual(lastHit.t, 'pageview');115 });116 it('tracks usage for all required plugins', () => {117 browser.url('/test/e2e/fixtures/autotrack.html');118 browser.execute(ga.run, 'create', DEFAULT_TRACKER_FIELDS);119 browser.execute(ga.logHitData, testId);120 browser.execute(ga.run, 'require', 'cleanUrlTracker');121 browser.execute(ga.run, 'require', 'eventTracker');122 browser.execute(ga.run, 'require', 'impressionTracker');123 browser.execute(ga.run, 'require', 'outboundLinkTracker');124 browser.execute(ga.run, 'require', 'mediaQueryTracker');125 browser.execute(ga.run, 'require', 'outboundFormTracker');126 browser.execute(ga.run, 'require', 'pageVisibilityTracker');127 browser.execute(ga.run, 'require', 'socialWidgetTracker');128 browser.execute(ga.run, 'require', 'urlChangeTracker');129 browser.execute(ga.run, 'require', 'maxScrollTracker');130 browser.execute(ga.run, 'send', 'pageview');131 browser.waitUntil(log.hitCountIsAtLeast(1));132 const lastHit = log.getHits().slice(-1)[0];133 assert.strictEqual(lastHit.did, constants.DEV_ID);134 assert.strictEqual(lastHit[constants.VERSION_PARAM], pkg.version);135 // '3ff' = '1111111111' in hex136 assert.strictEqual(lastHit[constants.USAGE_PARAM], '3ff');137 });138 it('tracks usage when plugins send hits before other plugins are required',139 () => {140 browser.url('/test/e2e/fixtures/autotrack.html');141 browser.execute(ga.run, 'create', DEFAULT_TRACKER_FIELDS);142 browser.execute(ga.logHitData, testId);143 // Run all require commands in the same execute() block so they occur in144 // the same call stack (as most people do in their tracking snippet).145 browser.execute(() => {146 ga('require', 'cleanUrlTracker');147 ga('require', 'eventTracker');148 ga('require', 'impressionTracker');149 ga('require', 'outboundLinkTracker');150 ga('require', 'mediaQueryTracker');151 ga('require', 'outboundFormTracker');152 ga('require', 'pageVisibilityTracker', {sendInitialPageview: true});153 ga('require', 'socialWidgetTracker');154 ga('require', 'urlChangeTracker');155 ga('require', 'maxScrollTracker');156 });157 browser.waitUntil(log.hitCountIsAtLeast(1));158 const lastHit = log.getHits().slice(-1)[0];159 assert.strictEqual(lastHit.did, constants.DEV_ID);...
message.po.js
Source:message.po.js
1module.exports = (type = 'column') => {2 const SELECTOR = {3 container: {4 row: '#conversation-list-rows',5 column: '#conversation-list-columns'6 },7 conversation: '.conversation',8 message: {9 container: '#conversation-view',10 title: '#conversationHeader > h1',11 subcontainer: '#pm_thread',12 item: '.message',13 body: '.bodyDecrypted',14 details: '.recipients-details',15 displayButtons: {16 remote: '.displayContentBtn-container[data-action="remote"]',17 embedded: '.displayContentBtn-container[data-action="embedded"]'18 },19 button: {20 toggleDetails: '.toggleDetails',21 composeToFrom: '.message-contact-sender',22 composeToTo: '.messageContacts-btn-compose',23 reply: '.message-actionBtn-reply',24 replyall: '.message-actionBtn-replyall',25 forward: '.message-actionBtn-forward',26 blockquote: '.proton-message-blockquote-toggle'27 }28 }29 };30 const SCOPE = `$('${SELECTOR.container[type]}')`;31 const open = (index = 0) => {32 return browser.executeScript(`33 return ${SCOPE}34 .find('${SELECTOR.conversation}')35 .eq(${index})36 .click();37 `);38 };39 const isOpened = () => {40 return browser.executeScript(`41 return $('${SELECTOR.message.container}').is(':visible');42 `);43 };44 const conversation = () => {45 const SCOPE = `$('${SELECTOR.message.container}')`;46 const isVisible = () => {47 return browser.executeScript(`48 return ${SCOPE}.is(':visible');49 `);50 };51 const count = () => {52 return browser.executeScript(`53 return ${SCOPE}54 .find('${SELECTOR.message.item}')55 .length56 `);57 };58 const getTitle = () => {59 return browser.executeScript(`60 const $title = $('${SELECTOR.message.title}');61 return {62 title: $title.find('span:last-of-type').text(),63 number: $title.find('span:first-of-type').text().split('').filter((i) => !isNaN(+i)).join(''),64 full: $title.text()65 };66 `);67 };68 const isDetailsVisibleLatest = () => {69 // the last one should be visiblee70 return browser.executeScript(`71 const lastVisible = ${SCOPE}72 .find('${SELECTOR.message.item}:not(.draft):last')73 .find('${SELECTOR.message.details}')74 .is(':visible');75 const hasOne = ${SCOPE}76 .find('${SELECTOR.message.details}').length === 1;77 return lastVisible && hasOne;78 `);79 };80 const isBodyVisibleForLatest = () => {81 // the last one should be visiblee82 return browser.executeScript(`83 const lastVisible = ${SCOPE}84 .find('${SELECTOR.message.item}:not(.draft):last')85 .find('${SELECTOR.message.body}')86 .is(':visible');87 const hasOne = ${SCOPE}88 .find('${SELECTOR.message.body}').length === 1;89 return lastVisible && hasOne;90 `);91 };92 return { isVisible, count, getTitle, isDetailsVisibleLatest, isBodyVisibleForLatest };93 };94 const message = (index = 0) => {95 const SCOPE = `$('${SELECTOR.message.container}').find('${SELECTOR.message.item}').eq(${index})`;96 const isOpened = () => {97 return browser.executeScript(`98 return ${SCOPE}99 .find('${SELECTOR.message.body}')100 .is(':visible');101 `);102 };103 const open = () => {104 return browser.executeScript(`105 return ${SCOPE}106 .find('.summary')107 .triggerHandler('mouseup');108 `);109 };110 const isDetailsVisible = () => {111 return browser.executeScript(`112 return ${SCOPE}113 .find('${SELECTOR.message.details}')114 .is(':visible');115 `);116 };117 const toggleDetails = () => {118 return browser.executeScript(`119 return ${SCOPE}120 .find('${SELECTOR.message.button.toggleDetails}')121 .click();122 `);123 };124 const reply = (type = 'reply') => {125 return browser.executeScript(`126 return ${SCOPE}127 .find('${SELECTOR.message.button[type]}')128 .get(0)129 .click();130 `);131 };132 const composeTo = (type = 'from') => {133 const selector = (type === 'from') ? 'composeToFrom' : 'composeToTo';134 return browser.executeScript(`135 return ${SCOPE}136 .find('${SELECTOR.message.button[selector]}')137 .get(0)138 .click();139 `);140 };141 const loadContent = (type) => {142 const selector = `${SCOPE}.find('${SELECTOR.message.displayButtons[type]}')`;143 const isVisible = () => {144 return browser.executeScript(`145 return ${selector}.is(':visible');146 `);147 };148 const click = () => {149 return browser.executeScript(`150 return ${selector}.click();151 `);152 };153 const hasLoaded = () => {154 const selector = `${SCOPE}.find('${SELECTOR.message.body}')`;155 if (type === 'embedded') {156 return browser.executeScript(`157 const img = ${selector}[0]158 .querySelector('img[proton-src^="cid:"]');159 return (img && /blob:http/.test(img.src));160 `);161 }162 return browser.executeScript(`163 const img = ${selector}[0]164 .querySelector('img[proton-src^="http"]');165 return (img && img.src === img.getAttribute('proton-src'));166 `);167 };168 return { isVisible, click, hasLoaded };169 };170 return { isOpened, open, isDetailsVisible, toggleDetails, reply, composeTo, loadContent };171 };172 return { open, isOpened, conversation, message };...
clean-url-tracker-test.js
Source:clean-url-tracker-test.js
...31 before(() => browser.url('/test/e2e/fixtures/autotrack.html'));32 beforeEach(() => {33 testId = uuid();34 log = bindLogAccessors(testId);35 browser.execute(ga.run, 'create', DEFAULT_TRACKER_FIELDS);36 browser.execute(ga.logHitData, testId);37 });38 afterEach(() => {39 log.removeHits();40 browser.execute(ga.run, 'cleanUrlTracker:remove');41 browser.execute(ga.run, 'remove');42 });43 it('sets the page field but does not modify the path by default', () => {44 const url = 'https://example.com/foo/bar?q=qux&b=baz#hash';45 browser.execute(ga.run, 'set', 'location', url);46 browser.execute(ga.run, 'require', 'cleanUrlTracker');47 browser.execute(ga.run, 'send', 'pageview');48 browser.waitUntil(log.hitCountEquals(1));49 const hits = log.getHits();50 assert.strictEqual(hits[0].dl, url);51 assert.strictEqual(hits[0].dp, '/foo/bar?q=qux&b=baz');52 });53 it('cleans URLs in all hits, not just the initial pageview', () => {54 const url = 'https://example.com/foo/bar?q=qux&b=baz#hash';55 browser.execute(ga.run, 'set', 'location', url);56 browser.execute(ga.run, 'require', 'cleanUrlTracker', {57 stripQuery: true,58 queryDimensionIndex: 1,59 });60 browser.execute(ga.run, 'send', 'pageview');61 browser.execute(ga.run, 'set', 'page', '/updated?query=new' );62 browser.execute(ga.run, 'send', 'pageview');63 browser.execute(ga.run, 'set', 'page', '/more/updated?query=newest' );64 browser.execute(ga.run, 'send', 'event');65 browser.execute(ga.run, 'set', 'page', '/final#ly' );66 browser.execute(ga.run, 'send', 'event');67 browser.waitUntil(log.hitCountEquals(4));68 const hits = log.getHits();69 assert.strictEqual(hits[0].dp, '/foo/bar');70 assert.strictEqual(hits[0].cd1, 'q=qux&b=baz');71 assert.strictEqual(hits[1].dp, '/updated');72 assert.strictEqual(hits[1].cd1, 'query=new');73 assert.strictEqual(hits[2].dp, '/more/updated');74 assert.strictEqual(hits[2].cd1, 'query=newest');75 assert.strictEqual(hits[3].dp, '/final');76 assert.strictEqual(hits[3].cd1, constants.NULL_DIMENSION);77 });78 it('cleans both set and sent URL fields', () => {79 const url = 'https://example.com/foo/bar?q=qux&b=baz#hash';80 browser.execute(ga.run, 'set', 'location', url);81 browser.execute(ga.run, 'require', 'cleanUrlTracker', {82 stripQuery: true,83 queryDimensionIndex: 1,84 });85 browser.execute(ga.run, 'send', 'pageview');86 browser.execute(ga.run, 'send', 'pageview', '/updated?query=new');87 browser.waitUntil(log.hitCountEquals(2));88 const hits = log.getHits();89 assert.strictEqual(hits[0].dl, url);90 assert.strictEqual(hits[0].dp, '/foo/bar');91 assert.strictEqual(hits[0].cd1, 'q=qux&b=baz');92 assert.strictEqual(hits[1].dl, url);93 assert.strictEqual(hits[1].dp, '/updated');94 assert.strictEqual(hits[1].cd1, 'query=new');95 });96 it('works with many options in conjunction with each other', () => {97 const url = 'https://example.com/path/to/index.html?q=qux&b=baz#hash';98 browser.execute(ga.run, 'set', 'location', url);99 browser.execute(requireCleanUrlTracker_multipleOpts);100 browser.execute(ga.run, 'send', 'pageview');101 browser.waitUntil(log.hitCountEquals(1));102 const hits = log.getHits();103 assert.strictEqual(hits[0].dl,104 'https://example.io/path/to/index.html?q=qux&b=baz#hash');105 assert.strictEqual(hits[0].dp, '/path/to?q=qux');106 assert.strictEqual(hits[0].cd1, 'q=qux&b=baz');107 });108 it('includes usage params with all hits', () => {109 browser.execute(ga.run, 'require', 'cleanUrlTracker');110 browser.execute(ga.run, 'send', 'pageview');111 browser.waitUntil(log.hitCountEquals(1));112 const hits = log.getHits();113 assert.strictEqual(hits[0].did, constants.DEV_ID);114 assert.strictEqual(hits[0][constants.VERSION_PARAM], pkg.version);115 // '1' = '0000000001' in hex116 assert.strictEqual(hits[0][constants.USAGE_PARAM], '1');117 });118 describe('remove', () => {119 it('destroys all bound events and functionality', () => {120 const url = 'https://example.com/foo/bar?q=qux&b=baz#hash';121 browser.execute(ga.run, 'set', 'location', url);122 browser.execute(ga.run, 'require', 'cleanUrlTracker', {123 stripQuery: true,124 });125 browser.execute(ga.run, 'send', 'pageview');126 browser.waitUntil(log.hitCountEquals(1));127 let hits = log.getHits();128 assert.strictEqual(hits[0].dl, url);129 assert.strictEqual(hits[0].dp, '/foo/bar');130 browser.execute(ga.run, 'cleanUrlTracker:remove');131 browser.execute(ga.run, 'set', 'page', '/updated?query=new' );132 browser.execute(ga.run, 'send', 'pageview');133 browser.waitUntil(log.hitCountEquals(2));134 hits = log.getHits();135 assert.strictEqual(hits[1].dl, url);136 assert.strictEqual(hits[1].dp, '/updated?query=new');137 });138 });139});140/**141 * Since function objects can't be passed via parameters from server to142 * client, this one-off function must be used to set the value for143 * `urlFieldsFilter`.144 */145function requireCleanUrlTracker_multipleOpts() {146 ga('require', 'cleanUrlTracker', {...
main.js
Source:main.js
1let Player = mp.players.local;2var gruppenErstellenBrowser;3var meineGruppierungBrowser;4var inviteBrowser;5var tabelle;6var eintrag;7var zelle1;8var zelle2;9var zelle3;10var inhalt1;11var inhalt2;12var inhalt3;13var tabelle1;14var eintrag1;15var zelle11;16var zelle22;17var zelle33;18var zelle44;19var inhalt11;20var inhalt22;21var inhalt33;22var inhalt44;23mp.events.add('gruppenerstellenbrowseroeffnen', () => {24 gruppenErstellenBrowser = mp.browsers.new('package://Server/Gruppensystem/gruppierungerstellen.html');25 mp.gui.cursor.show(true, true);26});27mp.events.add('meinegruppierungbrowseroeffnen', () => {28 meineGruppierungBrowser = mp.browsers.new('package://Server/Gruppensystem/meinegruppierung.html');29 mp.gui.cursor.show(true, true);30});31mp.events.add('invitebrowseroeffnen', (Gruppenname) => {32 inviteBrowser = mp.browsers.new('package://Server/Gruppensystem/invite.html');33 mp.gui.cursor.show(true, true);34 35 inviteBrowser.execute(`document.getElementById('text').innerHTML = 'Möchtest du der Gruppe <b>${Gruppenname}</b> beitreten?';`);36});37mp.events.add('GruppenDaten', (Name, Leader, Tag, Farbe, Geld, IstLeader) => {38 meineGruppierungBrowser.execute(`GruppenDaten('${Name}', '${Leader}', '${Tag}', '${Farbe}', '${Geld}', '${IstLeader}');`);39});40mp.events.add('RangDaten', (Rang5, Rang4, Rang3, Rang2, Rang1) => {41 meineGruppierungBrowser.execute(`RangDaten('${Rang5}', '${Rang4}', '${Rang3}', '${Rang2}', '${Rang1}');`);42});43mp.events.add('gruppenerstellenbrowserschliessen', () => {44 gruppenErstellenBrowser.destroy();45 mp.gui.cursor.show(false, false);46 47});48mp.events.add('meinegruppierungbrowserschliessen', () => {49 meineGruppierungBrowser.destroy();50 mp.gui.cursor.show(false, false);51 52});53mp.events.add('invitebrowserschliessen', () => {54 inviteBrowser.destroy();55 mp.gui.cursor.show(false, false);56 57});58mp.events.add('gruppierungerstellenzumserver', (Gruppenname, Gruppentag, Gruppenfarbe) => {59 mp.events.callRemote('GruppierungErstellen', Gruppenname, Gruppentag, Gruppenfarbe);60});61mp.events.add('rangezumserver', (Rang5, Rang4, Rang3, Rang2, Rang1) => {62 mp.events.callRemote('GruppenRaengeSpeichern', Rang5, Rang4, Rang3, Rang2, Rang1);63});64mp.events.add('gruppenspielerspeichernzumserver', (Id, Rang) => {65 mp.events.callRemote('GruppenSpielerSpeichern', Id, Rang);66});67mp.events.add('invitenzumserver', (Name) => {68 mp.events.callRemote('GruppeSpielerInviten', Name);69});70mp.events.add('uninvitezumserver', (Name) => {71 mp.events.callRemote('GruppeSpielerUninviten', Name);72});73mp.events.add('einladungannehmenzumserver', () => {74 mp.events.callRemote('GruppeEinladungAnnehmen');75});76mp.events.add('einladungablehnenzumserver', () => {77 mp.events.callRemote('GruppeEinladungAblehnen');78});79mp.events.add('Mitglieder_Eintragen', (Id, Name, Lastonline, RangName, Rang, Leader) => {80 Eintragen(Id, Name, Lastonline, RangName);81 82 if(Leader == 1)83 {84 EintragenVerwaltung(Id, Name, Lastonline, Rang);85 }86});87function Eintragen(Id, Name, Lastonline, Rang, Leader) 88{89 meineGruppierungBrowser.execute(`tabelle = document.getElementById('gruppentabelle').getElementsByTagName('tbody')[0];`);90 meineGruppierungBrowser.execute(`eintrag = tabelle.insertRow(tabelle.rows.length);`);91 meineGruppierungBrowser.execute(`zelle1 = eintrag.insertCell(0);`);92 meineGruppierungBrowser.execute(`zelle2 = eintrag.insertCell(1);`);93 meineGruppierungBrowser.execute(`zelle3 = eintrag.insertCell(2);`);94 meineGruppierungBrowser.execute(`inhalt1 = document.createTextNode('${Name}');`);95 meineGruppierungBrowser.execute(`inhalt2 = document.createTextNode('${Lastonline}');`);96 meineGruppierungBrowser.execute(`inhalt3 = document.createTextNode('${Rang}');`);97 98 meineGruppierungBrowser.execute(`zelle1.appendChild(inhalt1);`);99 meineGruppierungBrowser.execute(`zelle2.appendChild(inhalt2);`);100 meineGruppierungBrowser.execute(`zelle3.appendChild(inhalt3);`);101 102}103function EintragenVerwaltung(Id, Name, Lastonline, Rang) 104{105 meineGruppierungBrowser.execute(`tabelle1 = document.getElementById('verwaltentabelle').getElementsByTagName('tbody')[0];`);106 meineGruppierungBrowser.execute(`eintrag1 = tabelle1.insertRow(tabelle1.rows.length);`);107 meineGruppierungBrowser.execute(`zelle11 = eintrag1.insertCell(0);`);108 meineGruppierungBrowser.execute(`zelle22 = eintrag1.insertCell(1);`);109 meineGruppierungBrowser.execute(`zelle33 = eintrag1.insertCell(2);`);110 meineGruppierungBrowser.execute(`zelle44 = eintrag1.insertCell(3);`);111 meineGruppierungBrowser.execute(`inhalt11 = document.createTextNode('${Name}');`);112 113 meineGruppierungBrowser.execute(`inhalt22 = document.createElement('input');`);114 meineGruppierungBrowser.execute(`inhalt22.type = "number";`);115 meineGruppierungBrowser.execute(`inhalt22.className = "form-control";`);116 meineGruppierungBrowser.execute(`inhalt22.value = ${Rang};`);117 meineGruppierungBrowser.execute(`inhalt22.dataset.target = 'Rang${Id}';`);118 meineGruppierungBrowser.execute(`inhalt22.id = 'Rang${Id}';`);119 120 meineGruppierungBrowser.execute(`inhalt33 = document.createElement('input');`);121 meineGruppierungBrowser.execute(`inhalt33.type = "button";`);122 meineGruppierungBrowser.execute(`inhalt33.className = "btn btn-danger";`);123 meineGruppierungBrowser.execute(`inhalt33.value = "â";`);124 meineGruppierungBrowser.execute(`inhalt33.dataset.target = ${Id};`);125 meineGruppierungBrowser.execute(`inhalt33.id = ${Id};`);126 meineGruppierungBrowser.execute(`inhalt33.onclick = uninvite;`);127 128 meineGruppierungBrowser.execute(`inhalt44 = document.createElement('input');`);129 meineGruppierungBrowser.execute(`inhalt44.type = "button";`);130 meineGruppierungBrowser.execute(`inhalt44.className = "btn btn-warning";`);131 meineGruppierungBrowser.execute(`inhalt44.value = "â";`);132 meineGruppierungBrowser.execute(`inhalt44.dataset.target = ${Id};`);133 meineGruppierungBrowser.execute(`inhalt44.id = ${Id};`);134 meineGruppierungBrowser.execute(`inhalt44.onclick = speichern;`);135 136 meineGruppierungBrowser.execute(`zelle11.appendChild(inhalt11);`);137 meineGruppierungBrowser.execute(`zelle22.appendChild(inhalt22);`);138 meineGruppierungBrowser.execute(`zelle33.appendChild(inhalt33);`);139 meineGruppierungBrowser.execute(`zelle44.appendChild(inhalt44);`);140 ...
source.test.js
Source:source.test.js
1import assert from 'assert';2import uuid from 'uuid';3import * as ga from './ga';4import { getHitLogs } from './server';5import * as injection from './injection';6let testId;7describe('Source', () => {8 beforeEach((done) => {9 testId = uuid();10 done();11 });12 it('with utm_source', (done) => {13 browser.get('http://localhost:8888/source.html?utm_source=yahoo&utm_medium=cpc')14 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })15 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })16 .then(() => { browser.executeScript(ga.logHitData, testId); })17 .then(() => { browser.executeScript(ga.run, 'powerup:source'); } )18 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })19 .then(() => {20 const hits = getHitLogs(testId);21 assert.equal(hits.length, 1);22 assert.equal(hits[0].t, 'pageview');23 assert.equal(hits[0].cs, undefined);24 })25 .then(done);26 });27 it('with utm_id', (done) => {28 browser.get('http://localhost:8888/source.html?utm_id=test')29 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })30 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })31 .then(() => { browser.executeScript(ga.logHitData, testId); })32 .then(() => { browser.executeScript(ga.run, 'powerup:source'); } )33 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })34 .then(() => {35 const hits = getHitLogs(testId);36 assert.equal(hits.length, 1);37 assert.equal(hits[0].t, 'pageview');38 assert.equal(hits[0].cs, undefined);39 })40 .then(done);41 });42 it('referrer = https://t.co/test.html', (done) => {43 browser.get('http://localhost:8888/source.html')44 .then(() => { browser.executeScript(injection.updateReferrer, 'https://t.co/test.html'); })45 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })46 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })47 .then(() => { browser.executeScript(ga.logHitData, testId); })48 .then(() => { browser.executeScript(ga.run, 'powerup:source'); } )49 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })50 .then(() => {51 const hits = getHitLogs(testId);52 assert.equal(hits.length, 1);53 assert.equal(hits[0].t, 'pageview');54 assert.equal(hits[0].cs, 'twitter.com');55 })56 .then(done);57 }); 58 it('referrer = https://m.facebook.com/test.html', (done) => {59 browser.get('http://localhost:8888/source.html')60 .then(() => { browser.executeScript(injection.updateReferrer, 'https://m.facebook.com/test.html'); })61 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })62 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })63 .then(() => { browser.executeScript(ga.logHitData, testId); })64 .then(() => { browser.executeScript(ga.run, 'powerup:source'); } )65 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })66 .then(() => {67 const hits = getHitLogs(testId);68 assert.equal(hits.length, 1);69 assert.equal(hits[0].t, 'pageview');70 assert.equal(hits[0].cs, 'facebook.com');71 })72 .then(done);73 }); 74 it('referrer = https://l.facebook.com/test.html', (done) => {75 browser.get('http://localhost:8888/source.html')76 .then(() => { browser.executeScript(injection.updateReferrer, 'https://l.facebook.com/test.html'); })77 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })78 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })79 .then(() => { browser.executeScript(ga.logHitData, testId); })80 .then(() => { browser.executeScript(ga.run, 'powerup:source'); } )81 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })82 .then(() => {83 const hits = getHitLogs(testId);84 assert.equal(hits.length, 1);85 assert.equal(hits[0].t, 'pageview');86 assert.equal(hits[0].cs, 'facebook.com');87 })88 .then(done);89 }); 90 it('referrer = https://lm.facebook.com/test.html', (done) => {91 browser.get('http://localhost:8888/source.html')92 .then(() => { browser.executeScript(injection.updateReferrer, 'https://lm.facebook.com/test.html'); })93 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })94 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })95 .then(() => { browser.executeScript(ga.logHitData, testId); })96 .then(() => { browser.executeScript(ga.run, 'powerup:source'); } )97 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })98 .then(() => {99 const hits = getHitLogs(testId);100 assert.equal(hits.length, 1);101 assert.equal(hits[0].t, 'pageview');102 assert.equal(hits[0].cs, 'facebook.com');103 })104 .then(done);105 }); 106 it('referrer = https://www.google.co.jp/test.html', (done) => {107 browser.get('http://localhost:8888/source.html')108 .then(() => { browser.executeScript(injection.updateReferrer, 'https://www.google.co.jp/test.html'); })109 .then(() => { browser.executeScript(ga.run, 'create', 'UA-XXXXXX-Y', 'auto'); })110 .then(() => { browser.executeScript(ga.run, 'require', 'powerup'); })111 .then(() => { browser.executeScript(ga.logHitData, testId); })112 .then(() => { browser.executeScript(ga.run, 'powerup:source'); } )113 .then(() => { browser.executeScript(ga.run, 'send', 'pageview'); })114 .then(() => {115 const hits = getHitLogs(testId);116 assert.equal(hits.length, 1);117 assert.equal(hits[0].t, 'pageview');118 assert.equal(hits[0].cs, undefined);119 })120 .then(done);121 }); ...
allbidders_dom_spec.js
Source:allbidders_dom_spec.js
1// var verify = require('verify');2var util = require('../../common/utils.js');3module.exports = {4 'adequant ad rendering': function (browser) {5 browser6 .url('http://an.localhost:9999/test/spec/e2e/gpt-examples/all_bidders_instant_load.html')7 .waitForElementVisible('body', 5000)8 .pause(7000)9 .execute(util.findIframeInDiv, ['div-1'], function(result) {10 this.verify.equal(result.value, true, 'adequant ad not rendered');11 });12 },13 'adform ad rendering': function (browser) {14 browser15 .execute(util.findIframeInDiv, ['div-2'], function(result) {16 this.verify.equal(result.value, true, 'adform ad not rendered');17 });18 },19 'aol ad rendering': function (browser) {20 browser21 .execute(util.findIframeInDiv, ['div-3'], function(result) {22 this.verify.equal(result.value, true, 'aol ad not rendered');23 });24 },25 'appnexus ad rendering': function (browser) {26 browser27 .execute(util.findIframeInDiv, ['div-4'], function(result) {28 this.verify.equal(result.value, true, 'appnexus ad not rendered');29 });30 },31 'indexExchange ad rendering': function (browser) {32 browser33 .execute(util.findIframeInDiv, ['div-5'], function(result) {34 this.verify.equal(result.value, true, 'indexExchange ad not rendered');35 });36 },37 'openx ad rendering': function (browser) {38 browser39 .execute(util.findIframeInDiv, ['div-6'], function(result) {40 this.verify.equal(result.value, true, 'openx ad not rendered');41 });42 },43 'pubmatic ad rendering': function (browser) {44 browser45 .execute(util.findIframeInDiv, ['div-7'], function(result) {46 this.verify.equal(result.value, true, 'pubmatic ad not rendered');47 });48 },49 'pulsepoint ad rendering': function (browser) {50 browser51 .execute(util.findIframeInDiv, ['div-8'], function(result) {52 this.verify.equal(result.value, true, 'pulsepoint ad not rendered');53 });54 },55 'rubicon ad rendering': function (browser) {56 browser57 .execute(util.findIframeInDiv, ['div-9'], function(result) {58 this.verify.equal(result.value, true, 'rubicon ad not rendered');59 });60 },61 'sonobi ad rendering': function (browser) {62 browser63 .execute(util.findIframeInDiv, ['div-10'], function(result) {64 this.verify.equal(result.value, true, 'sonobi ad not rendered');65 });66 },67 'sovrn ad rendering': function (browser) {68 browser69 .execute(util.findIframeInDiv, ['div-11'], function(result) {70 this.verify.equal(result.value, true, 'sovrn ad not rendered');71 });72 },73 'springserve ad rendering': function (browser) {74 browser75 .execute(util.findIframeInDiv, ['div-12'], function(result) {76 this.verify.equal(result.value, true, 'springserve ad not rendered');77 });78 },79 'triplelift ad rendering': function (browser) {80 browser81 .execute(util.findIframeInDiv, ['div-13'], function(result) {82 this.verify.equal(result.value, true, 'triplelift ad not rendered');83 });84 },85 'yieldbot ad rendering': function (browser) {86 browser87 .execute(util.findIframeInDiv, ['div-14'], function(result) {88 this.verify.equal(result.value, true, 'yieldbot ad not rendered');89 });90 },91 'nginad ad rendering': function (browser) {92 browser93 .execute(util.findIframeInDiv, ['div-15'], function(result) {94 this.verify.equal(result.value, true, 'nginad ad not rendered');95 });96 },97 'brightcom ad rendering': function (browser) {98 browser99 .execute(util.findIframeInDiv, ['div-16'], function(result) {100 this.verify.equal(result.value, true, 'brightcom ad not rendered');101 });102 },103 'sekindo ad rendering': function (browser) {104 browser105 .execute(util.findIframeInDiv, ['div-17'], function(result) {106 this.verify.equal(result.value, true, 'sekindo ad not rendered');107 });108 },109 'kruxlink ad rendering': function (browser) {110 browser111 .execute(util.findIframeInDiv, ['div-18'], function(result) {112 this.verify.equal(result.value, true, 'kruxlink ad not rendered');113 });114 },115 'AdMedia ad rendering': function (browser) {116 browser117 .execute(util.findIframeInDiv, ['div-19'], function(result) {118 this.verify.equal(result.value, true, 'AdMedia ad not rendered');119 });120 },121 after: function(browser) {122 browser.end();123 }...
Using AI Code Generation
1var path = require('path');2var async = require('async');3var wd = require('wd');4var asserters = wd.asserters;5var chai = require('chai');6var chaiAsPromised = require('chai-as-promised');7chai.use(chaiAsPromised);8chai.should();9chaiAsPromised.transferPromiseness = wd.transferPromiseness;10var desired = {11};12var browser = wd.promiseChainRemote('localhost', 4723);13 .init(desired)14 .title()15 .should.become('Google')16 .elementByName('q')17 .type('Appium')18 .elementByName('btnG')19 .click()20 .sleep(1000)21 .title()22 .should.become('Appium - Google Search')23 .fin(function() { return browser.quit(); })24 .done();
Using AI Code Generation
1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder().withCapabilities(webdriver.Capabilities.android()).build();3var By = webdriver.By;4driver.findElement(By.name('q')).sendKeys('appium');5driver.findElement(By.name('btnG')).click();6driver.sleep(5000).then(function() {7 driver.getTitle().then(function(title) {8 if(title === 'appium - Google Search') {9 console.log('Test passed');10 } else {11 console.log('Test failed');12 }13 });14});15driver.quit();16Your name to display (optional):17Your name to display (optional):18driver.executeScript('return document.title;').then(function(title) {19 console.log('Page title is: ' + title);20});21Your name to display (optional):
Using AI Code Generation
1browser.execute(function() {2 return window.location.href;3}).then(function(url) {4 console.log(url.value);5});6browser.executeAsync(function() {7 var callback = arguments[arguments.length - 1];8 callback(window.location.href);9}).then(function(url) {10 console.log(url.value);11});12browser.executeAsync(function() {13 var callback = arguments[arguments.length - 1];14 setTimeout(function() {15 callback(window.location.href);16 }, 5000);17}).then(function(url) {18 console.log(url.value);19});20browser.executeAsync(function() {21 var callback = arguments[arguments.length - 1];22 setTimeout(function() {23 callback(window.location.href);24 }, 5000);25}).then(function(url) {26 console.log(url.value);27});28browser.executeAsync(function() {29 var callback = arguments[arguments.length - 1];30 setTimeout(function() {31 callback(window.location.href);32 }, 5000);33}).then(function(url) {34 console.log(url.value);35});36browser.executeAsync(function() {37 var callback = arguments[arguments.length - 1];38 setTimeout(function() {39 callback(window.location.href);40 }, 5000);41}).then(function(url) {42 console.log(url.value);43});44browser.executeAsync(function() {45 var callback = arguments[arguments.length - 1];46 setTimeout(function() {47 callback(window.location.href);48 }, 5000);49}).then(function(url) {50 console.log(url.value);51});52browser.executeAsync(function() {53 var callback = arguments[arguments.length - 1];54 setTimeout(function() {55 callback(window.location.href);56 }, 5000);57}).then(function(url) {58 console.log(url.value);59});60browser.executeAsync(function() {
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!!