How to use bringToFront method in Puppeteer

Best JavaScript code snippet using puppeteer

inboxonly.js

Source:inboxonly.js Github

copy

Full Screen

...102 // } catch (ex) {103 // console.error(ex);104 // // await browser.close()105 // }106 await page.bringToFront();107 await page.authenticate({108 username: item.proxyUsername,109 password: item.proxyPassword,110 });111 await page.bringToFront();112 for (let i = 0; i <= 11; i++) {113 await sleep(1000);114 if (i == 11) {115 i = 0;116 }117 https://mail.google.com/mail/u/1/#search/in%3Ainbox+welcome+OR+liberty/FMfcgzGmthmXxmntkRPvnCnWBNrlpkTn118 await page.bringToFront();119 await Promise.all([page.keyboard.press("Enter")]);120 await Promise.all([page.keyboard.press("Enter")]);121 try {122 123 // await page.goto(124 // `https://mail.google.com/mail/u/${i}/#inbox`,125 // pressenter(page,i),126 // // https://mail.google.com/mail/u/${i}/h/1skwmxqy8dsdn/?&127 // {128 129 // waitUntil:"domcontentloaded",130 131 // timeout: 1* 1000* 60,132 // },133 134 // );135 await sleep(9000)136 await page.goto(`https://mail.google.com/mail/u/${i}/#inbox`, {waituntil: "domcontentloaded"});137 // //Find the iFrame with the URL http://www.allwebco-templates.com/support/138 // const frame = await page.frames().find(f => f.url() === `https://mail.google.com/mail/u/${i-1}/#search/in%3Ainbox+welcome+OR+liberty/FMfcgzGmthmXxmntkRPvnCnWBNrlpkTn`);139 // if(!frame){140 // console.log("iFrame not found with the specified url");141 142 // }143 // await Promise.all([page.keyboard.press("Enter")]);144 // await Promise.all([page.keyboard.press("Enter")]);145 146 } catch (ex) {147 148 console.error(ex);149 // await browser.close()150 }151 await page.bringToFront();152 if ((await page.$("#main-message > h1 > span")) !== null) {153 let proxyreconnect = await eval(154 page,155 `() => document.querySelector('#main-message > h1 > span').innerText == 'No internet'`156 );157 if (proxyreconnect == true) {158 await page.reload({159 waitUntil: ["networkidle0", "domcontentloaded"],160 });161 }162 }163 await Promise.all([page.keyboard.press("Enter")]);164 await Promise.all([page.keyboard.press("Enter")]);165 await page.bringToFront();166 // if(i == 0){167 // let pages3 = await browser.pages();168 // await pages3[0].close();169 // }170 // for (let j = 0; i <= 2; j++) {171 if ((await page.$("#maia-main > form > p > input")) !== null) {172 await page.click("#maia-main > form > p > input");173 }174 await Promise.all([page.keyboard.press("Enter")]);175 await page.bringToFront();176 await Promise.all([page.keyboard.press("Enter")]);177 await Promise.all([page.keyboard.press("Enter")]);178 const searchmail = '[aria-label="Search mail"]';179 await page.waitForSelector(searchmail);180 await page.click(searchmail);181 await page.bringToFront();182 let pages13 = await browser.pages();183 if (pages13[1]) {184 await pages13[1].close();185 }186 if (pages13[2]) {187 await pages13[2].close();188 }189 if (pages13[3]) {190 await pages13[3].close();191 }192 await Promise.all([page.keyboard.press("Enter")]);193 await Promise.all([page.keyboard.press("Enter")]);194 // await searchmail.click({ clickCount: 3 });195 await page.type(searchmail, `in:spam `);196 await Promise.all([page.keyboard.press("Enter")]);197 await page.bringToFront();198 await sleep(20000);199 const checkPrice = await page.$x(200 "//td[contains(text(), 'Hooray, no spam here!')]"201 );202 console.log(checkPrice.length);203 204 if (checkPrice.length == 0) {205 const click1 = await page.$x(206 "/html/body/div[7]/div[3]/div/div[2]/div[1]/div[2]/div/div/div/div/div[2]/div/div[1]/div/div[2]/div[4]/div[2]/div/table/tbody/tr[1]/td[2]"207 );208 await page.bringToFront();209 // "/html/body/div[7]/div[3]/div/div[2]/div[1]/div[2]/div/div/div/div/div[2]/div/div[1]/div/div[3]/div[5]/div[2]/div/table/tbody/tr[1]/td[2]"210 if (click1.length) {211 await click1[0].click();212 }213 const click2 = await page.$x(214 "/html/body/div[7]/div[3]/div/div[2]/div[1]/div[2]/div/div/div/div/div[2]/div/div[1]/div/div[2]/div[4]/div[2]/div/table/tbody/tr[2]/td[2]"215 );216 if (click2.length) {217 await click2[0].click();218 }219 const click3 = await page.$x(220 "/html/body/div[7]/div[3]/div/div[2]/div[1]/div[2]/div/div/div/div/div[2]/div/div[1]/div/div[2]/div[4]/div[2]/div/table/tbody/tr[3]/td[2]"221 );222 if (click3.length) {223 await click3[0].click();224 }225 const click4 = await page.$x(226 "/html/body/div[7]/div[3]/div/div[2]/div[1]/div[2]/div/div/div/div/div[2]/div/div[1]/div/div[2]/div[4]/div[2]/div/table/tbody/tr[4]/td[2]"227 );228 if (click4.length) {229 await click4[0].click();230 }231 const click5 = await page.$x(232 "/html/body/div[7]/div[3]/div/div[2]/div[1]/div[2]/div/div/div/div/div[2]/div/div[1]/div/div[2]/div[4]/div[2]/div/table/tbody/tr[5]/td[2]"233 );234 if (click5.length) {235 await click5[0].click();236 }237 const click6 = await page.$x(238 "/html/body/div[7]/div[3]/div/div[2]/div[1]/div[2]/div/div/div/div/div[2]/div/div[1]/div/div[2]/div[4]/div[2]/div/table/tbody/tr[6]/td[2]"239 );240 // "/html/body/div[7]/div[3]/div/div[2]/div[1]/div[2]/div/div/div/div/div[2]/div/div[1]/div/div[3]/div[5]/div[2]/div/table/tbody/tr[1]/td[2]"241 if (click6.length) {242 await click6[0].click();243 }244 const click7 = await page.$x(245 "/html/body/div[7]/div[3]/div/div[2]/div[1]/div[2]/div/div/div/div/div[2]/div/div[1]/div/div[2]/div[4]/div[2]/div/table/tbody/tr[7]/td[2]"246 );247 if (click7.length) {248 await click7[0].click();249 }250 const click8 = await page.$x(251 "/html/body/div[7]/div[3]/div/div[2]/div[1]/div[2]/div/div/div/div/div[2]/div/div[1]/div/div[2]/div[4]/div[2]/div/table/tbody/tr[8]/td[2]"252 );253 if (click8.length) {254 await click8[0].click();255 }256 const click9 = await page.$x(257 "/html/body/div[7]/div[3]/div/div[2]/div[1]/div[2]/div/div/div/div/div[2]/div/div[1]/div/div[2]/div[4]/div[2]/div/table/tbody/tr[9]/td[2]"258 );259 if (click9.length) {260 await click9[0].click();261 }262 const click10 = await page.$x(263 "/html/body/div[7]/div[3]/div/div[2]/div[1]/div[2]/div/div/div/div/div[2]/div/div[1]/div/div[2]/div[4]/div[2]/div/table/tbody/tr[10]/td[2]"264 );265 if (click10.length) {266 await click10[0].click();267 }268 await page.bringToFront();269 await sleep(2000);270 let notspamcheck = await eval(271 page,272 `() => document.getElementsByClassName('Bn')[1].innerText == 'Not spam'`273 );274 await page.bringToFront();275 await sleep(3000);276 // let notspamclick = await eval(page, `() => document.getElementsByClassName('Bn')[1]`);277 if (notspamcheck == true) {278 await page.click(279 "div.D.E.G-atb.PY > div.nH.aqK > div.Cq.aqL > div > div > div:nth-child(3) > div > div"280 );281 }282 await page.bringToFront();283 await sleep(15000)284 }285 await page.bringToFront();286 await page.goto(287 `https://mail.google.com/mail/u/${i}/#inbox`,288 // https://mail.google.com/mail/u/${i}/h/1skwmxqy8dsdn/?&289 {290 waitUntil: "domcontentloaded",291 timeout: 1000 * 60 * 5,292 }293 );294 await page.bringToFront();295 for (let i = 0; i < 20; i++) {296 await sleep(5000);297 await page.waitForSelector('[aria-label="Search mail"]');298 await page.bringToFront();299 await page.click('[aria-label="Search mail"]');300 await page.bringToFront();301 if (i == 0) {302 await page.type(303 '[aria-label="Search mail"]',304 `in:inbox welcome OR liberty `305 );306 }307 await page.bringToFront();308 // is:unread in:inbox welcome OR liberty309 await Promise.all([page.keyboard.press("Enter")]);310 await page.bringToFront();311 logger.log("mailsync:", i);312 // document.getElementsByClassName('v1')[0].innerText == 'Loading...'313 if (i == 0) {314 await sleep(15000);315 await page.bringToFront();316 } else {317 await sleep(5000);318 }319 await page.bringToFront();320 await eval(321 page,322 `() => document.getElementsByClassName('xY a4W')[10].click()`323 );324 await page.bringToFront();325 // const firstmail = await page.$x(326 // "/html/body/div[7]/div[3]/div/div[2]/div[1]/div[2]/div/div/div/div/div[2]/div/div[1]/div/div[3]/div[5]/div[2]/div/table/tbody/tr[1]"327 // );328 // if (firstmail[0] == undefined) {329 // const firstmailoptional = await page.$x(330 // "/html/body/div[7]/div[3]/div/div[2]/div[1]/div[2]/div/div/div/div/div[2]/div/div[1]/div/div[2]/div[5]/div[2]/div/table/tbody/tr[1]"331 // );332 // await sleep(2000);333 // await firstmailoptional[0].click();334 // } else {335 // await firstmail[0].click();336 // }337 await page.bringToFront();338 let pages13 = await browser.pages();339 if (pages13[1]) {340 await pages13[1].close();341 }342 await page.bringToFront();343 await sleep(3000);344 let pages14 = await browser.pages();345 if (pages14[1]) {346 await pages14[1].close();347 }348 await page.bringToFront();349 const aElementsWithHi = await page.$x("//a[contains(string(),'Hi ')]");350 if (aElementsWithHi.length) { 351 if (aElementsWithHi[0] >= 1) {352 aElementsWithHi[0].click();353 } else {354 await sleep(2000)355 await page.bringToFront();356 const headerWithHi = await page.$x("//a[contains(string(),'Hi')]");357 headerWithHi[0].click();358 }359 await page.bringToFront();360 await sleep(7000);361 await page.bringToFront();362 let pages2 = await browser.pages();363 if (pages2[1]) {364 await pages2[1].close();365 }366 if (pages2[2]) {367 await pages2[2].close();368 }369 if (pages2[3]) {370 await pages2[3].close();371 }372 await page.bringToFront();373 const starclick = await page.$x(374 "//div[contains(@aria-label, 'Not starred')]"375 );376 await sleep(2000);377 await page.bringToFront();378 if (starclick.length >= 1) {379 await starclick[0].click();380 }381 await sleep(8000);382 await page.bringToFront();383 let impcheck = await eval(384 page,385 `() => document.getElementsByClassName('pG')[20].ariaLabel`386 );387 await sleep(1000);388 // console.log(impcheck)389 await page.bringToFront();390 if (impcheck == "Not important") {391 const tryagain = await page.$x(392 "/html/body/div[7]/div[3]/div/div[2]/div[1]/div[2]/div/div/div/div/div[2]/div/div[1]/div/div[4]/div/table/tr/td[1]/div[2]/div[1]/div[2]/div[1]/span/div[1]"393 );394 395 396 if(tryagain[0] == undefined){397 const tryagain1 = await page.$x(398 "/html/body/div[7]/div[3]/div/div[2]/div[1]/div[2]/div/div/div/div/div[2]/div/div[1]/div/div[3]/div/table/tr/td[1]/div[2]/div[1]/div[2]/div[1]/span/div[1]"399 );400 await tryagain1[0].click();401 }else{402 await tryagain[0].click();403 }404 }405 await page.bringToFront();406 // const impclick = await page.$x(407 // "/html/body/div[7]/div[3]/div/div[2]/div[1]/div[2]/div/div/div/div/div[2]/div/div[1]/div/div[4]/div/table/tr/td[1]/div[2]/div[1]/div[2]/div[1]/span"408 // );409 // // await sleep(1000);410 // if (impclick.length >= 1) {411 // await impclick[0].click();412 // }413 // await sleep(2000)414 // document.getElementsByClassName('bAq')[0].innerText == 'Conversation marked as not important.'415 // try{416 // let impcheck = await eval(417 // page,418 // `() => document.getElementsByClassName('bAq')`419 // );420 // console.log(impcheck)421 // if (impcheck == true) {422 // const confirmimpclick = await page.$x(423 // "/html/body/div[7]/div[3]/div/div[2]/div[1]/div[2]/div/div/div/div/div[2]/div/div[1]/div/div[4]/div/table/tr/td[1]/div[2]/div[1]/div[2]/div[1]/span"424 // );425 // if (confirmimpclick.length >= 1) {426 // await confirmimpclick[0].click();427 // }428 // }429 // }catch(ex)430 // {431 // console.log(ex)432 // }433 await page.bringToFront();434 }435 await sleep(3000);436 await page.bringToFront();437 const Archive = await page.$x(438 "/html/body/div[7]/div[3]/div/div[2]/div[1]/div[2]/div/div/div/div/div[1]/div[4]/div[1]/div/div[2]/div[1]"439 );440 if (Archive[0]) {441 await Archive[0].click();442 } else {443 const Archive1 = await page.$x(444 "/html/body/div[7]/div[3]/div/div[2]/div[1]/div[2]/div/div/div/div/div[1]/div[3]/div[1]/div/div[2]/div[1]"445 );446 await Archive1[0].click();447 }448 await page.bringToFront();449 await Promise.all([page.keyboard.press("Enter")]);450 await Promise.all([page.keyboard.press("Enter")]);451 }452 }453 }454 // await browser.close();455 // processBrowsers(browser,page)456 return "DONE";457 } catch (ex) {458 console.log(ex);459 }460}461module.exports = {462 gmailProcess,...

Full Screen

Full Screen

TrackerManager.js

Source:TrackerManager.js Github

copy

Full Screen

1///<reference path="DEDesigner.ts"/>2///<reference path="../Util.ts"/>3var DEJS;4(function (DEJS) {5 var TrackerManager = (function () {6 function TrackerManager(designer) {7 this.trackers = {};8 this.zoom = 100;9 this.lockProportions = true;10 this.designer = designer;11 }12 TrackerManager.prototype.track = function (element, forceRedraw) {13 var _this = this;14 if (typeof forceRedraw === "undefined") { forceRedraw = false; }15 if (element) {16 var tracker = this.trackers[element.id];17 if (!tracker)18 tracker = this.trackers[element.id] = new Tracker(element, this.designer.canvas, function (action) {19 return _this.onTrackerMouseDown(action);20 }, this);21 else22 tracker.update(forceRedraw);23 } else {24 for (var key in this.trackers) {25 this.trackers[key].update(forceRedraw);26 }27 }28 };29 TrackerManager.prototype.stopTrack = function (element) {30 if (element) {31 var tracker = this.trackers[element.id];32 if (tracker) {33 tracker.remove();34 delete this.trackers[element.id];35 }36 } else {37 this.clear();38 }39 };40 TrackerManager.prototype.clear = function () {41 for (var key in this.trackers) {42 this.trackers[key].remove();43 delete this.trackers[key];44 }45 };46 TrackerManager.prototype.processClick = function (x, y) {47 for (var key in this.trackers) {48 var tracker = this.trackers[key];49 if (tracker.processClick(x, y))50 return true;51 }52 return false;53 };54 TrackerManager.prototype.setLockProportions = function (lockProportions) {55 if (lockProportions == this.lockProportions)56 return;57 this.lockProportions = lockProportions;58 this.track(null, true);59 };60 TrackerManager.prototype.onTrackerMouseDown = function (action) {61 this.designer.trackerAction(action);62 };63 TrackerManager.prototype.markTracker = function (element) {64 element.node.isTracker = true;65 return element;66 };67 TrackerManager.prototype.setZoom = function (zoom) {68 if (zoom == this.zoom)69 return;70 this.zoom = zoom;71 this.track();72 };73 return TrackerManager;74 })();75 DEJS.TrackerManager = TrackerManager;76 var Tracker = (function () {77 function Tracker(element, canvas, mouseHandler, trackerManager) {78 this.element = element;79 this.canvas = canvas;80 this.mouseHandler = mouseHandler;81 this.trackerManager = trackerManager;82 this.draw();83 }84 Tracker.prototype.draw = function () {85 var obj = this.element.node.objectLink;86 var bbox = DEJS.Util.getBBox(this.element, true);87 this.lastBBox = bbox;88 var boxColor = "#494949";89 var padding = 0;90 var x, y;91 this.box = this.canvas.rect(bbox.x - padding, bbox.y - padding, bbox.width + padding * 2, bbox.height + padding * 2).attr({ "opacity": 0.7, "stroke": boxColor, "stroke-dasharray": "- " });92 var preloaderSize = Math.min(bbox.width + padding * 2, bbox.height + padding * 2);93 this.preloader = this.canvas.image(DEJS.Model.ConfigManager.imagePreloaderPath(), bbox.x + ((bbox.width + padding * 2) - preloaderSize) / 2, bbox.y + ((bbox.height + padding * 2) - preloaderSize) / 2, preloaderSize, preloaderSize); //.attr({ "opacity": 0.7 });94 this.preloader.hide();95 if (obj && obj.canRotate()) {96 x = this.getTrackerXY(DEJS.Action.Rotate, bbox).x;97 y = this.getTrackerXY(DEJS.Action.Rotate, bbox).y;98 this.rotateEl = this.trackerIcon(x, y, DEJS.Action.Rotate);99 }100 if (obj && obj.canDelete()) {101 x = this.getTrackerXY(DEJS.Action.Delete, bbox).x;102 y = this.getTrackerXY(DEJS.Action.Delete, bbox).y;103 this.deleteEl = this.trackerIcon(x, y, DEJS.Action.Delete);104 }105 if (obj && obj.canResize()) {106 if (!this.trackerManager.lockProportions) {107 x = this.getTrackerXY(DEJS.Action.ResizeH, bbox).x;108 y = this.getTrackerXY(DEJS.Action.ResizeH, bbox).y;109 this.resizeHEl = this.trackerIcon(x, y, DEJS.Action.ResizeH);110 x = this.getTrackerXY(DEJS.Action.ResizeV, bbox).x;111 y = this.getTrackerXY(DEJS.Action.ResizeV, bbox).y;112 this.resizeVEl = this.trackerIcon(x, y, DEJS.Action.ResizeV);113 }114 x = this.getTrackerXY(DEJS.Action.Resize, bbox).x;115 y = this.getTrackerXY(DEJS.Action.Resize, bbox).y;116 this.resizeEl = this.trackerIcon(x, y, DEJS.Action.Resize);117 }118 //-----119 x = this.getTrackerXY(DEJS.Action.BringToFront, bbox).x;120 y = this.getTrackerXY(DEJS.Action.BringToFront, bbox).y;121 this.BringToFront = this.trackerIcon(x, y, DEJS.Action.BringToFront);122 //-----123 this.update();124 };125 Tracker.prototype.update = function (forceRedraw) {126 if (typeof forceRedraw === "undefined") { forceRedraw = false; }127 var bbox = DEJS.Util.getBBox(this.element, true);128 if (forceRedraw || (bbox.width != this.lastBBox.width || bbox.height != this.lastBBox.height)) {129 this.remove();130 this.draw();131 return;132 }133 var padding = 0;134 var transform = this.element.transform();135 var matrix = this.element.matrix;136 //var r = this.element.matrix.split().rotate;137 var r = DEJS.Util.getMatrixRotate(matrix, bbox.x + bbox.width / 2, bbox.y + bbox.height / 2);138 var scaleX = DEJS.Util.getMatrixScaleX(matrix);139 var scaleY = DEJS.Util.getMatrixScaleY(matrix);140 var x;141 var y;142 var x2;143 var y2;144 if (this.box) {145 x = this.getTrackerXY("", bbox).x;146 y = this.getTrackerXY("", bbox).y;147 x2 = matrix.x(x, y);148 y2 = matrix.y(x, y);149 var newWidth = bbox.width * Math.abs(scaleX) * this.trackerManager.zoom / 100;150 var newHeight = bbox.height * Math.abs(scaleY) * this.trackerManager.zoom / 100;151 this.box.attr({ x: x2, y: y2, width: newWidth, height: newHeight });152 var ns = 100 / this.trackerManager.zoom;153 this.box.transform("s" + ns + "," + ns + "," + x2 + "," + y2 + "r" + r + "," + x2 + "," + y2);154 if (this.preloader) {155 var preloaderSize = Math.min(newWidth, newHeight);156 this.preloader.attr({ x: x2 + (newWidth - preloaderSize) / 2, y: y2 + (newHeight - preloaderSize) / 2, width: preloaderSize, height: preloaderSize });157 this.preloader.transform("s" + ns + "," + ns + "," + x2 + "," + y2 + "r" + r + "," + x2 + "," + y2);158 var obj = this.element.node.objectLink;159 if (obj && obj.showPreloader) {160 this.preloader.show();161 } else {162 this.preloader.hide();163 }164 }165 }166 if (this.resizeEl) {167 x = this.getTrackerXY(DEJS.Action.Resize, bbox).x;168 y = this.getTrackerXY(DEJS.Action.Resize, bbox).y;169 x2 = matrix.x(x, y);170 y2 = matrix.y(x, y);171 this.resizeEl.transform("t" + (x2 - x) + "," + (y2 - y) + "r" + r);172 DEJS.Util.scaleElement(this.resizeEl, 100 / this.trackerManager.zoom, true);173 }174 if (this.resizeHEl) {175 x = this.getTrackerXY(DEJS.Action.ResizeH, bbox).x;176 y = this.getTrackerXY(DEJS.Action.ResizeH, bbox).y;177 x2 = matrix.x(x, y);178 y2 = matrix.y(x, y);179 this.resizeHEl.transform("t" + (x2 - x) + "," + (y2 - y) + "r" + r);180 DEJS.Util.scaleElement(this.resizeHEl, 100 / this.trackerManager.zoom, true);181 }182 if (this.resizeVEl) {183 x = this.getTrackerXY(DEJS.Action.ResizeV, bbox).x;184 y = this.getTrackerXY(DEJS.Action.ResizeV, bbox).y;185 x2 = matrix.x(x, y);186 y2 = matrix.y(x, y);187 this.resizeVEl.transform("t" + (x2 - x) + "," + (y2 - y) + "r" + r);188 DEJS.Util.scaleElement(this.resizeVEl, 100 / this.trackerManager.zoom, true);189 }190 if (this.rotateEl) {191 x = this.getTrackerXY(DEJS.Action.Rotate, bbox).x;192 y = this.getTrackerXY(DEJS.Action.Rotate, bbox).y;193 x2 = matrix.x(x, y);194 y2 = matrix.y(x, y);195 this.rotateEl.transform("t" + (x2 - x) + "," + (y2 - y) + "r" + r);196 DEJS.Util.scaleElement(this.rotateEl, 100 / this.trackerManager.zoom, true);197 }198 if (this.deleteEl) {199 x = this.getTrackerXY(DEJS.Action.Delete, bbox).x;200 y = this.getTrackerXY(DEJS.Action.Delete, bbox).y;201 x2 = matrix.x(x, y);202 y2 = matrix.y(x, y);203 this.deleteEl.transform("t" + (x2 - x) + "," + (y2 - y) + "r" + r);204 DEJS.Util.scaleElement(this.deleteEl, 100 / this.trackerManager.zoom, true);205 }206 if (this.moveEl) {207 x = this.getTrackerXY(DEJS.Action.Move, bbox).x;208 y = this.getTrackerXY(DEJS.Action.Move, bbox).y;209 x2 = matrix.x(x, y);210 y2 = matrix.y(x, y);211 this.moveEl.transform("t" + (x2 - x) + "," + (y2 - y) + "r" + r);212 DEJS.Util.scaleElement(this.moveEl, 100 / this.trackerManager.zoom, true);213 }214 //-----215 if (this.BringToFront) {216 x = this.getTrackerXY(DEJS.Action.BringToFront, bbox).x;217 y = this.getTrackerXY(DEJS.Action.BringToFront, bbox).y;218 x2 = matrix.x(x, y);219 y2 = matrix.y(x, y);220 this.BringToFront.transform("t" + (x2 - x) + "," + (y2 - y) + "r" + r);221 DEJS.Util.scaleElement(this.BringToFront, 100 / this.trackerManager.zoom, true);222 }223 //-----224 };225 Tracker.prototype.remove = function () {226 this.box.remove();227 if (this.preloader)228 this.preloader.remove();229 if (this.resizeEl)230 this.resizeEl.remove();231 if (this.resizeHEl)232 this.resizeHEl.remove();233 if (this.resizeVEl)234 this.resizeVEl.remove();235 if (this.rotateEl)236 this.rotateEl.remove();237 if (this.deleteEl)238 this.deleteEl.remove();239 if (this.moveEl)240 this.moveEl.remove();241 //-----242 if (this.BringToFront)243 this.BringToFront.remove();244 //-----245 };246 Tracker.prototype.trackerIcon = function (x, y, action) {247 var _this = this;248 var w = mobilesafari ? 32 : 21;249 var addName = mobilesafari ? "_32px" : "";250 var element;251 switch (action) {252 case DEJS.Action.Resize:253 element = this.canvas.image(DEJS.Model.ConfigManager.assetsUrl + "img/tracker/resize" + addName + ".png", x - w / 2, y - w / 2, w, w);254 break;255 case DEJS.Action.ResizeH:256 element = this.canvas.image(DEJS.Model.ConfigManager.assetsUrl + "img/tracker/resizeH" + addName + ".png", x - w / 2, y - w / 2, w, w);257 break;258 case DEJS.Action.ResizeV:259 element = this.canvas.image(DEJS.Model.ConfigManager.assetsUrl + "img/tracker/resizeV" + addName + ".png", x - w / 2, y - w / 2, w, w);260 break;261 case DEJS.Action.Rotate:262 element = this.canvas.image(DEJS.Model.ConfigManager.assetsUrl + "img/tracker/rotate" + addName + ".png", x - w / 2, y - w / 2, w, w);263 break;264 case DEJS.Action.Delete:265 element = this.canvas.image(DEJS.Model.ConfigManager.assetsUrl + "img/tracker/delete" + addName + ".png", x - w / 2, y - w / 2, w, w);266 break;267 //-----268 case DEJS.Action.BringToFront:269 element = this.canvas.image(DEJS.Model.ConfigManager.assetsUrl + "img/tracker/bringtofront" + addName + ".png", x - w / 2, y - w / 2, w, w);270 break;271 //-----272 default:273 element = this.canvas.ellipse(x, y, w / 2, w / 2).attr({274 "stroke-width": 1,275 "stroke": "grey",276 "fill": "white"277 });278 break;279 }280 element.node.id = "de-tracker-" + action;281 element.attr("cursor", "pointer").mouseover(function () {282 this.attr("fill", "grey");283 }).mouseout(function () {284 this.attr("fill", "white");285 }).mousedown(function (event) {286 return _this.onTrackerMouseDown(event, action);287 }).dblclick(function (dblclickEvent) {288 //this.paper.editor.trackers[0].object.rotate(0, true);289 //this.paper.editor.updateTracker();290 });291 if (mobilesafari) {292 element.node.addEventListener("touchstart", function (event) {293 return _this.onTrackerMouseDown(event, action);294 }, false);295 }296 this.markTracker(element);297 return element;298 };299 Tracker.prototype.onTrackerMouseDown = function (event, action) {300 if (this.mouseHandler)301 this.mouseHandler(action);302 };303 Tracker.prototype.markTracker = function (element) {304 element.node.isTracker = true;305 return element;306 };307 Tracker.prototype.processClick = function (x, y) {308 if (this.resizeEl && DEJS.Util.isClicked(x, y, this.resizeEl)) {309 this.onTrackerMouseDown(null, DEJS.Action.Resize);310 return true;311 }312 if (this.resizeHEl && DEJS.Util.isClicked(x, y, this.resizeHEl)) {313 this.onTrackerMouseDown(null, DEJS.Action.ResizeH);314 return true;315 }316 if (this.resizeVEl && DEJS.Util.isClicked(x, y, this.resizeVEl)) {317 this.onTrackerMouseDown(null, DEJS.Action.ResizeV);318 return true;319 }320 if (this.rotateEl && DEJS.Util.isClicked(x, y, this.rotateEl)) {321 this.onTrackerMouseDown(null, DEJS.Action.Rotate);322 return true;323 }324 if (this.deleteEl && DEJS.Util.isClicked(x, y, this.deleteEl)) {325 this.onTrackerMouseDown(null, DEJS.Action.Delete);326 return true;327 }328 if (this.moveEl && DEJS.Util.isClicked(x, y, this.moveEl)) {329 this.onTrackerMouseDown(null, DEJS.Action.Move);330 return true;331 }332 //-----333 if (this.BringToFront && DEJS.Util.isClicked(x, y, this.BringToFront)) {334 this.onTrackerMouseDown(null, DEJS.Action.BringToFront);335 return true;336 }337 //-----338 return false;339 };340 Tracker.prototype.getTrackerXY = function (action, bbox) {341 var x;342 var y;343 var padding = 0;344 switch (action) {345 case DEJS.Action.Resize:346 x = bbox.x + bbox.width + padding;347 y = bbox.y + bbox.height + padding;348 break;349 case DEJS.Action.ResizeH:350 x = bbox.x + bbox.width + padding;351 y = bbox.y + bbox.height / 2;352 break;353 case DEJS.Action.ResizeV:354 x = bbox.x + bbox.width / 2;355 y = bbox.y + bbox.height + padding;356 break;357 case DEJS.Action.Rotate:358 x = bbox.x - padding;359 y = bbox.y + bbox.height + padding;360 break;361 case DEJS.Action.Delete:362 x = bbox.x + bbox.width + padding;363 y = bbox.y - padding;364 break;365 //-----366 case DEJS.Action.BringToFront:367 x = bbox.x - padding;368 y = bbox.y - padding;369 break;370 //-----371 default:372 x = bbox.x;373 y = bbox.y;374 break;375 }376 var m = this.element.matrix;377 var cx = m.x(bbox.x + bbox.width / 2, bbox.y + bbox.height / 2);378 var cy = m.y(bbox.x + bbox.width / 2, bbox.y + bbox.height / 2);379 var curRotate = DEJS.Util.getMatrixRotate(m, cx, cy);380 var m2 = Raphael.matrix(1, 0, 0, 1, 0, 0);381 m2.rotate(0 - curRotate, cx, cy);382 m2.add(m.a, m.b, m.c, m.d, m.e, m.f);383 var flipH = m2.a < 0;384 var flipV = m2.d < 0;385 if (flipH)386 x = 2 * bbox.x + bbox.width - x;387 if (flipV)388 y = 2 * bbox.y + bbox.width - y;389 return { x: x, y: y, flipH: flipH, flipV: flipV };390 };391 return Tracker;392 })();393 DEJS.Tracker = Tracker;...

Full Screen

Full Screen

loginonly.js

Source:loginonly.js Github

copy

Full Screen

...130 catch(ex) {131 console.error(ex)132 await browser.close()133 }134 await page.bringToFront();135 await sleep(5000);136 // await page.authenticate({137 // username: currentItem.proxyUsername,138 // password: currentItem.proxyPassword,139 // });140 await page.bringToFront();141 await sleep(3000);142 if ((await page.$('#reload-button')) !== null) {143 await page.click('#reload-button');144 }145 if(currentItem.seedno == 1) {146 // try{147 await page.goto("http://accounts.google.com ", {148 waitUntil: "domcontentloaded",149 timeout: 0,150 });151// } catch(ex){152// await browser.close()153// } 154 }155 await sleep(3000);156 if ((await page.$('#reload-button')) !== null) {157 await page.click('#reload-button');158 }159 // let pages1 = await browser.pages();160 // await pages1[0].close();161 if ((await page.$('div[class="BHzsHc"]')) !== null) {162 await page.click('div[class="BHzsHc"]');163 }164 if ((await page.$('input[type="email"]')) !== null) {165 await sleep(3000);166 // await page.waitForSelector('input[type="email"]');167 // await page.type('input[type="email"]', currentItem.email);168 const email = await page.$x("//input[@type='email'] ");169 await sleep(5000);170 await email[0].type(currentItem.email);171 await page.bringToFront();172 await Promise.all([page.keyboard.press("Enter")]);173 await sleep(5000);174 // await page.waitForSelector('input[type="password"]');175 await page.bringToFront();176 // await sleep(3000);177 // await page.type('input[type="password"]', currentItem.pwd),178 const pwd = await page.$x("//input[@type='password'] ");179 await sleep(5000);180 await pwd[0].type(currentItem.pwd);181 await sleep(6000);182 await Promise.all([page.keyboard.press("Enter")]);183 }184 await sleep(3000);185 if ((await page.$('#yDmH0d > c-wiz.yip5uc.SSPGKf > c-wiz > div > div.p9lFnc > div > div > div > div.ZRg0lb.Kn8Efe > div:nth-child(3) > div > div.yKBrKe > div > span > span')) !== null) {186 await page.click('#yDmH0d > c-wiz.yip5uc.SSPGKf > c-wiz > div > div.p9lFnc > div > div > div > div.ZRg0lb.Kn8Efe > div:nth-child(3) > div > div.yKBrKe > div > span > span');187 }188 await sleep(3000);189 // if ((await page.$('div[class="lCoei YZVTmd SmR8"]')) !== null) {190 // await page.waitForSelector('div[class="lCoei YZVTmd SmR8"]');191 // await sleep(3000);192 // await page.click('div[class="lCoei YZVTmd SmR8"]');193 // // await page.click('div[class="vxx8jf"]');194 // await sleep(3000);195 // await page.waitForSelector('input[type="email"]');196 // await sleep(3000);197 // await page.type('input[type="email"]', currentItem.recovery);198 // await page.bringToFront();199 // await Promise.all([page.keyboard.press("Enter")]);200 // }201 if ((await page.$('div[class="lCoei YZVTmd SmR8"]')) !== null) {202 const doesntHave = await page.$x("//*[@class='vxx8jf']");203 if (doesntHave[2]) {204 await doesntHave[2].click();205 await sleep(3000);206 await page.waitForSelector('input[type="email"]');207 await sleep(3000);208 await page.type('input[type="email"]', currentItem.recovery);209 await page.bringToFront();210 await Promise.all([page.keyboard.press("Enter")]);211 // await sleep(6000)212 } else {213 await page.waitForSelector('div[class="lCoei YZVTmd SmR8"]');214 await sleep(3000);215 await page.click('div[class="lCoei YZVTmd SmR8"]');216 // await page.click('div[class="vxx8jf"]');217 await sleep(3000);218 await page.waitForSelector('input[type="email"]');219 await sleep(3000);220 await page.type('input[type="email"]', currentItem.recovery);221 await page.bringToFront();222 await Promise.all([page.keyboard.press("Enter")]);223 }224 }225 //not now click226 await sleep(3000);227 if ((await page.$('div[class="VfPpkd-RLmnJb"]')) !== null) {228 await sleep(3000);229 await page.click('div[class="VfPpkd-RLmnJb"]');230 }231 if (232 (await page.$(233 "#yDmH0d > c-wiz > div > div > div > div.L5MEH.Bokche.ypEC4c > div.lq3Znf > div:nth-child(1) > button > div.VfPpkd-RLmnJb"234 )) !== null235 ) {236 await sleep(3000);237 await page.click(238 "#yDmH0d > c-wiz > div > div > div > div.L5MEH.Bokche.ypEC4c > div.lq3Znf > div:nth-child(1) > button > div.VfPpkd-RLmnJb"239 );240 }241 if (242 (await page.$(243 "#yDmH0d > c-wiz > div > div > div > div.L5MEH.Bokche.ypEC4c > div.lq3Znf > div:nth-child(1) > button > span"244 )) !== null245 ) {246 await sleep(3000);247 await page.click(248 "#yDmH0d > c-wiz > div > div > div > div.L5MEH.Bokche.ypEC4c > div.lq3Znf > div:nth-child(1) > button > span"249 );250 }251 await page.bringToFront();252 //confirm click253 if (254 (await page.$(255 "#yDmH0d > c-wiz.yip5uc.SSPGKf > c-wiz > div > div.p9lFnc > div > div > div > div.ZRg0lb.Kn8Efe > div:nth-child(3) > div > div.yKBrKe > div > span > span"256 )) !== null257 ) {258 await sleep(3000);259 await page.click(260 "#yDmH0d > c-wiz.yip5uc.SSPGKf > c-wiz > div > div.p9lFnc > div > div > div > div.ZRg0lb.Kn8Efe > div:nth-child(3) > div > div.yKBrKe > div > span > span"261 );262 await page.bringToFront();263 }264 if (265 (await page.$(266 "#yDmH0d > c-wiz.yip5uc.SSPGKf > c-wiz > div > div.p9lFnc > div > div > div > div.ZRg0lb.Kn8Efe > div:nth-child(3) > div > div.yKBrKe > div > div.ZFr60d.CeoRYc"267 )) !== null268 ) {269 await sleep(3000);270 await page.click(271 "#yDmH0d > c-wiz.yip5uc.SSPGKf > c-wiz > div > div.p9lFnc > div > div > div > div.ZRg0lb.Kn8Efe > div:nth-child(3) > div > div.yKBrKe > div > div.ZFr60d.CeoRYc"272 );273 }274 if ((await page.$('div[class="ZFr60d"]')) !== null) {275 await sleep(3000);276 await page.click('div[class="ZFr60d"]');277 }278 if (279 (await page.$(280 "#yDmH0d > c-wiz.yip5uc.SSPGKf > c-wiz > div > div.p9lFnc > div > div > div > div.ZRg0lb.Kn8Efe > div:nth-child(3) > div > div.yKBrKe > div > span > span"281 )) !== null282 ) {283 await sleep(3000);284 await page.click(285 "#yDmH0d > c-wiz.yip5uc.SSPGKf > c-wiz > div > div.p9lFnc > div > div > div > div.ZRg0lb.Kn8Efe > div:nth-child(3) > div > div.yKBrKe > div > span > span"286 );287 }288 if ((await page.$('div[class="VfPpkd"]')) !== null) {289 await sleep(3000);290 await page.click('div[class="VfPpkd"]');291 }292 logger.log(`email:${currentItem.email} login sucessfully`)293 294 295 // 1296 for (let i = 1; i <= 10; i++) {297 try{298 if (i == 10) {299 logger.log('all user login sucessfully');300 break;301 }302 await sleep(5000);303 await page.bringToFront();304 // await page.authenticate({305 // username: browserArr[1].proxyUsername,306 // password: browserArr[1].proxyPassword,307 // });308 let pages5 = await browser.pages();309 if(pages5[1]){310 await pages5[1].close();311 }312 await sleep(3000);313 if ((await page.$('#reload-button')) !== null) {314 await page.click('#reload-button');315 }316 await page.bringToFront();317 try{318 await page.goto("https://accounts.google.com/signin/v2/identifier?service=accountsettings&continue=https%3A%2F%2Fmyaccount.google.com%2F%3Fpli%3D1&ec=GAlAwAE&flowName=GlifWebSignIn&flowEntry=AddSession", {319 waitUntil: "domcontentloaded",320 timeout: 0,321 });322} catch(ex){323 await browser.close()324} 325await page.bringToFront();326 327 328 await sleep(3000);329 if ((await page.$('#reload-button')) !== null) {330 await page.click('#reload-button');331 }332 await page.bringToFront();333 // let pages11 = await browser.pages();334 // await pages11[0].close();335 if ((await page.$('div[class="BHzsHc"]')) !== null) {336 await page.click('div[class="BHzsHc"]');337 }338 await page.bringToFront();339 await page.bringToFront();340 if ((await page.$('input[type="email"]')) !== null) {341 await sleep(3000);342 await page.waitForSelector('input[type="email"]');343 await page.type('input[type="email"]', browserArr[i].email);344 await Promise.all([page.keyboard.press("Enter")]);345 await sleep(5000);346 await page.waitForSelector('input[type="password"]');347 await sleep(3000);348 await page.type('input[type="password"]', browserArr[i].pwd),349 await sleep(6000);350 await Promise.all([page.keyboard.press("Enter")]);351 }352 353 await page.bringToFront();354 await sleep(3000);355 if ((await page.$('#yDmH0d > c-wiz.yip5uc.SSPGKf > c-wiz > div > div.p9lFnc > div > div > div > div.ZRg0lb.Kn8Efe > div:nth-child(3) > div > div.yKBrKe > div > span > span')) !== null) {356 await page.click('#yDmH0d > c-wiz.yip5uc.SSPGKf > c-wiz > div > div.p9lFnc > div > div > div > div.ZRg0lb.Kn8Efe > div:nth-child(3) > div > div.yKBrKe > div > span > span');357 }358 await sleep(3000);359 await page.bringToFront();360 if ((await page.$('div[class="lCoei YZVTmd SmR8"]')) !== null) {361 await page.waitForSelector('div[class="lCoei YZVTmd SmR8"]');362 await sleep(3000);363 await page.click('div[class="lCoei YZVTmd SmR8"]');364 // await page.click('div[class="vxx8jf"]');365 await sleep(3000);366 await page.bringToFront();367 await page.waitForSelector('input[type="email"]');368 await sleep(3000);369 await page.type('input[type="email"]', browserArr[i].recovery);370 await Promise.all([page.keyboard.press("Enter")]);371 }372 await page.bringToFront();373 //not now click374 await page.bringToFront();375 await sleep(3000);376 if ((await page.$('div[class="VfPpkd-RLmnJb"]')) !== null) {377 await sleep(3000);378 await page.click('div[class="VfPpkd-RLmnJb"]');379 }380 await page.bringToFront();381 if (382 (await page.$(383 "#yDmH0d > c-wiz > div > div > div > div.L5MEH.Bokche.ypEC4c > div.lq3Znf > div:nth-child(1) > button > div.VfPpkd-RLmnJb"384 )) !== null385 ) {386 await sleep(3000);387 await page.click(388 "#yDmH0d > c-wiz > div > div > div > div.L5MEH.Bokche.ypEC4c > div.lq3Znf > div:nth-child(1) > button > div.VfPpkd-RLmnJb"389 );390 }391 await page.bringToFront();392 if (393 (await page.$(394 "#yDmH0d > c-wiz > div > div > div > div.L5MEH.Bokche.ypEC4c > div.lq3Znf > div:nth-child(1) > button > span"395 )) !== null396 ) {397 await sleep(3000);398 await page.click(399 "#yDmH0d > c-wiz > div > div > div > div.L5MEH.Bokche.ypEC4c > div.lq3Znf > div:nth-child(1) > button > span"400 );401 }402 await page.bringToFront();403 //confirm click404 if (405 (await page.$(406 "#yDmH0d > c-wiz.yip5uc.SSPGKf > c-wiz > div > div.p9lFnc > div > div > div > div.ZRg0lb.Kn8Efe > div:nth-child(3) > div > div.yKBrKe > div > span > span"407 )) !== null408 ) {409 await sleep(3000);410 await page.click(411 "#yDmH0d > c-wiz.yip5uc.SSPGKf > c-wiz > div > div.p9lFnc > div > div > div > div.ZRg0lb.Kn8Efe > div:nth-child(3) > div > div.yKBrKe > div > span > span"412 );413 }414 await page.bringToFront();415 if (416 (await page.$(417 "#yDmH0d > c-wiz.yip5uc.SSPGKf > c-wiz > div > div.p9lFnc > div > div > div > div.ZRg0lb.Kn8Efe > div:nth-child(3) > div > div.yKBrKe > div > div.ZFr60d.CeoRYc"418 )) !== null419 ) {420 await sleep(3000);421 await page.click(422 "#yDmH0d > c-wiz.yip5uc.SSPGKf > c-wiz > div > div.p9lFnc > div > div > div > div.ZRg0lb.Kn8Efe > div:nth-child(3) > div > div.yKBrKe > div > div.ZFr60d.CeoRYc"423 );424 }425 await page.bringToFront();426 if ((await page.$('div[class="ZFr60d"]')) !== null) {427 await sleep(3000);428 await page.click('div[class="ZFr60d"]');429 }430 await page.bringToFront();431 if (432 (await page.$(433 "#yDmH0d > c-wiz.yip5uc.SSPGKf > c-wiz > div > div.p9lFnc > div > div > div > div.ZRg0lb.Kn8Efe > div:nth-child(3) > div > div.yKBrKe > div > span > span"434 )) !== null435 ) {436 await sleep(3000);437 await page.click(438 "#yDmH0d > c-wiz.yip5uc.SSPGKf > c-wiz > div > div.p9lFnc > div > div > div > div.ZRg0lb.Kn8Efe > div:nth-child(3) > div > div.yKBrKe > div > span > span"439 );440 }441 await page.bringToFront();442 if ((await page.$('div[class="VfPpkd"]')) !== null) {443 await sleep(3000);444 await page.click('div[class="VfPpkd"]');445 }446 await page.bringToFront();447 logger.log(`email:${browserArr[i].email} login sucessfully`)448}catch(err){449 logger.log(`email:${browserArr[i].email} NOT LOGIN`)450 continue;451}452}453await page.bringToFront();454 455 // await browser.close();456 457 return "DONE";458}459module.exports = {460 gmailProcess,461};462const sleep = (time) => {463 return new Promise((resolve) => {464 setTimeout(() => {465 resolve(true);466 }, time);467 });...

Full Screen

Full Screen

popup-options.js

Source:popup-options.js Github

copy

Full Screen

...6 })7 describe('button - raw/markdown', () => {8 before(async () => {9 // popup10 await popup.bringToFront()11 // defaults button12 await popup.click('button:nth-of-type(2)')13 })14 it('render markdown as html', async () => {15 // go to page serving markdown as text/markdown16 await content.goto('http://localhost:3000/correct-content-type')17 await content.bringToFront()18 await content.waitFor(300)19 t.equal(20 await content.evaluate(() =>21 document.querySelector('#_html p strong').innerText22 ),23 'bold',24 'markdown should be rendered'25 )26 // popup27 await popup.bringToFront()28 t.strictEqual(29 await popup.evaluate(() =>30 state.raw31 ),32 false,33 'state.raw should equal false'34 )35 t.equal(36 await popup.evaluate(() =>37 document.querySelector('.m-button:first-child').innerText.toLowerCase()38 ),39 'markdown',40 'button text should equal markdown'41 )42 })43 it('display raw markdown', async () => {44 // raw button45 await content.bringToFront()46 await popup.click('button:nth-of-type(1)')47 // content auto reloads48 await content.waitFor(300)49 t.equal(50 await content.evaluate(() =>51 document.querySelector('#_markdown').innerText52 ),53 '**bold**',54 'markdown should not be rendered'55 )56 // popup57 await popup.bringToFront()58 t.strictEqual(59 await popup.evaluate(() =>60 state.raw61 ),62 true,63 'state.raw should equal true'64 )65 t.equal(66 await popup.evaluate(() =>67 document.querySelector('.m-button:first-child').innerText.toLowerCase()68 ),69 'html',70 'button text should equal html'71 )72 })73 })74 describe('set theme', () => {75 before(async () => {76 // popup77 await popup.bringToFront()78 // defaults button79 await popup.click('button:nth-of-type(2)')80 // theme tab81 await popup.click('.m-tabs a:nth-of-type(1)')82 })83 it('github theme should be set by default', async () => {84 // go to page serving markdown as text/markdown85 await content.goto('http://localhost:3000/correct-content-type')86 await content.bringToFront()87 await content.waitFor(300)88 t.strictEqual(89 await content.evaluate(() =>90 /github\.css$/.test(91 document.querySelector('#_theme').getAttribute('href')92 )93 ),94 true,95 'github theme styles should be included'96 )97 })98 it('set github-dark theme', async () => {99 // select github-dark theme100 await content.bringToFront()101 await popup.select('.m-panel:nth-of-type(1) select', 'github-dark')102 // content auto reloads103 await content.waitFor(300)104 t.strictEqual(105 await content.evaluate(() =>106 /github-dark\.css$/.test(107 document.querySelector('#_theme').getAttribute('href')108 )109 ),110 true,111 'github-dark theme styles should be included'112 )113 })114 it('popup should preserve state', async () => {115 // reload popup116 await popup.bringToFront()117 await popup.reload()118 await popup.waitFor(300)119 t.equal(120 await popup.evaluate(() =>121 state.theme.name122 ),123 'github-dark',124 'state.theme.name should equal github-dark'125 )126 t.equal(127 await popup.evaluate(() =>128 document.querySelectorAll('.m-panel:nth-of-type(1) select option')[129 document.querySelector('.m-panel:nth-of-type(1) select').selectedIndex130 ].innerText131 ),132 'github-dark',133 'dom select option should be github-dark'134 )135 })136 })137 describe('set compiler options - marked', () => {138 before(async () => {139 // popup140 await popup.bringToFront()141 // defaults button142 await popup.click('button:nth-of-type(2)')143 // compiler tab144 await popup.click('.m-tabs a:nth-of-type(2)')145 })146 it('gfm is enabled by default', async () => {147 // go to page serving markdown as text/markdown148 await content.goto('http://localhost:3000/compiler-options-marked')149 await content.bringToFront()150 await content.waitFor(300)151 t.equal(152 await content.evaluate(() =>153 document.querySelector('#_html p del').innerText154 ),155 'strikethrough',156 'gfm should be rendered'157 )158 })159 it('gfm is disabled', async () => {160 // disable gfm161 await content.bringToFront()162 // gfm switch163 await popup.click('.m-panel:nth-of-type(2) .m-switch:nth-of-type(2)')164 // content auto reloads165 await content.waitFor(300)166 t.equal(167 await content.evaluate(() =>168 document.querySelector('#_html p').innerText169 ),170 '~~strikethrough~~',171 'gfm should not be rendered'172 )173 })174 it('popup should preserve state', async () => {175 // reload popup176 await popup.bringToFront()177 await popup.reload()178 await popup.waitFor(300)179 t.equal(180 await popup.evaluate(() =>181 document.querySelectorAll('.m-panel:nth-of-type(2) .m-select option')[182 document.querySelector('.m-panel:nth-of-type(2) .m-select').selectedIndex183 ].innerText184 ),185 'marked',186 'dom select option should be marked'187 )188 t.strictEqual(189 await popup.evaluate(() =>190 state.options.gfm191 ),192 false,193 'state.options.gfm should be false'194 )195 t.strictEqual(196 await popup.evaluate(() =>197 document.querySelector('.m-panel:nth-of-type(2) .m-switch:nth-of-type(2)').classList.contains('is-checked')198 ),199 false,200 'dom gfm checkbox should be disabled'201 )202 })203 })204 describe('set compiler options - remark', () => {205 before(async () => {206 // popup207 await popup.bringToFront()208 // defaults button209 await popup.click('button:nth-of-type(2)')210 // compiler tab211 await popup.click('.m-tabs a:nth-of-type(2)')212 })213 it('marked should render gfm task lists by default', async () => {214 // go to page serving markdown as text/markdown215 await content.goto('http://localhost:3000/compiler-options-remark')216 await content.bringToFront()217 await content.waitFor(300)218 t.equal(219 await content.evaluate(() =>220 document.querySelector('#_html ul li').getAttribute('class')221 ),222 null,223 'no class on dom li'224 )225 t.strictEqual(226 await content.evaluate(() =>227 document.querySelector('#_html ul li [type=checkbox]').hasAttribute('disabled')228 ),229 true,230 'dom li should contain checkbox in it'231 )232 t.equal(233 await content.evaluate(() =>234 document.querySelector('#_html ul li').innerText235 ),236 ' task',237 'dom li should contain the task text'238 )239 })240 it('remark should render gfm task lists by default', async () => {241 // select remark compiler242 await content.bringToFront()243 await popup.select('.m-panel:nth-of-type(2) select', 'remark')244 // content auto reloads245 await content.waitFor(300)246 t.equal(247 await content.evaluate(() =>248 document.querySelector('#_html ul li').getAttribute('class')249 ),250 'task-list-item',251 'dom li should have a class set'252 )253 t.strictEqual(254 await content.evaluate(() =>255 document.querySelector('#_html ul li [type=checkbox]').hasAttribute('disabled')256 ),257 true,258 'dom li should contain checkbox in it'259 )260 t.equal(261 await content.evaluate(() =>262 document.querySelector('#_html ul li').innerText263 ),264 ' task',265 'dom li should contain the task text'266 )267 })268 it('remark disable gfm', async () => {269 // redraw popup270 await popup.bringToFront()271 await popup.reload()272 await popup.waitFor(300)273 // disable gfm274 await content.bringToFront()275 // gfm switch276 await popup.click('.m-panel:nth-of-type(2) .m-switch[title~=GFM]')277 // content auto reloads278 await content.waitFor(300)279 t.equal(280 await content.evaluate(() =>281 document.querySelector('#_html ul li').innerText282 ),283 '[ ] task',284 'gfm task lists should not be rendered'285 )286 })287 it('popup should preserve state', async () => {288 // reload popup289 await popup.bringToFront()290 await popup.reload()291 await popup.waitFor(300)292 t.equal(293 await popup.evaluate(() =>294 document.querySelectorAll('.m-panel:nth-of-type(2) .m-select option')[295 document.querySelector('.m-panel:nth-of-type(2) .m-select').selectedIndex296 ].innerText297 ),298 'remark',299 'dom select option should be remark'300 )301 t.strictEqual(302 await popup.evaluate(() =>303 state.options.gfm304 ),305 false,306 'state.options.gfm should be false'307 )308 t.strictEqual(309 await popup.evaluate(() =>310 document.querySelector('.m-panel:nth-of-type(2) .m-switch[title~=GFM]').classList.contains('is-checked')311 ),312 false,313 'dom gfm checkbox should be disabled'314 )315 })316 })317 describe('set content options - toc', () => {318 before(async () => {319 // popup320 await popup.bringToFront()321 // defaults button322 await popup.click('button:nth-of-type(2)')323 // content tab324 await popup.click('.m-tabs a:nth-of-type(3)')325 })326 it('toc is disabled by default', async () => {327 // go to page serving markdown as text/markdown328 await content.goto('http://localhost:3000/content-options-toc')329 await content.bringToFront()330 await content.waitFor(300)331 t.strictEqual(332 await content.evaluate(() =>333 document.querySelector('#_toc')334 ),335 null,336 'toc should be disabled'337 )338 })339 it('enable toc', async () => {340 // enable toc341 await content.bringToFront()342 // toc switch343 await popup.click('.m-panel:nth-of-type(3) .m-switch:nth-of-type(3)')344 // content auto reloads345 await content.waitFor(300)346 t.deepStrictEqual(347 await content.evaluate(() =>348 Array.from(document.querySelectorAll('#_toc ._ul a'))349 .map((a) => ({href: a.getAttribute('href'), text: a.innerText}))350 ),351 [352 {href: '#h1', text: 'h1'},353 {href: '#h2', text: 'h2'},354 {href: '#h3', text: 'h3'},355 ],356 'toc should be rendered'357 )358 })359 })360 describe('set content options - scroll', () => {361 before(async () => {362 // popup363 await popup.bringToFront()364 // defaults button365 await popup.click('button:nth-of-type(2)')366 // content tab367 await popup.click('.m-tabs a:nth-of-type(3)')368 })369 it('preserve scroll position by default', async () => {370 // go to page serving markdown as text/markdown371 await content.goto('http://localhost:3000/content-options-scroll')372 await content.bringToFront()373 await content.waitFor(300)374 // scroll down 200px375 await content.evaluate(() =>376 document.querySelector('body').scrollTop = 200377 )378 await content.waitFor(300)379 // reload page380 await content.reload()381 await content.waitFor(300)382 t.strictEqual(383 await content.evaluate(() =>384 document.querySelector('body').scrollTop,385 ),386 200,387 'scrollTop should be 200px'388 )389 })390 it('scroll to top', async () => {391 // disable scroll option392 await content.bringToFront()393 // scroll switch394 await popup.click('.m-panel:nth-of-type(3) .m-switch:nth-of-type(2)')395 // content auto reloads396 await content.waitFor(300)397 t.strictEqual(398 await content.evaluate(() =>399 document.querySelector('body').scrollTop,400 ),401 0,402 'scrollTop should be 0px'403 )404 // scroll down 200px405 await content.evaluate(() =>406 document.querySelector('body').scrollTop = 200407 )408 await content.waitFor(300)409 // reload page410 await content.reload()411 await content.waitFor(300)412 t.strictEqual(413 await content.evaluate(() =>414 document.querySelector('body').scrollTop,415 ),416 0,417 'scrollTop should be 0px'418 )419 })420 it('scroll to anchor', async () => {421 // click on header link422 await content.click('h2 a')423 await content.waitFor(300)424 t.strictEqual(425 await content.evaluate(() =>426 document.querySelector('body').scrollTop + 1427 ),428 await content.evaluate(() =>429 document.querySelector('h2').offsetTop430 ),431 'page should be scrolled to the anchor'432 )433 // scroll down 200px434 await content.evaluate(() =>435 document.querySelector('body').scrollTop += 200436 )437 await content.waitFor(300)438 t.strictEqual(439 await content.evaluate(() =>440 document.querySelector('body').scrollTop + 1441 ),442 await content.evaluate(() =>443 document.querySelector('h2').offsetTop + 200444 ),445 'page should be scrolled below the anchor'446 )447 // reload page448 await content.reload()449 await content.waitFor(300)450 t.strictEqual(451 await content.evaluate(() =>452 document.querySelector('body').scrollTop453 ),454 await content.evaluate(() =>455 document.querySelector('h2').offsetTop456 ),457 'page should be scrolled back to the anchor'458 )459 })460 })461 describe('set content options - autoreload', () => {462 before(async () => {463 // popup464 await popup.bringToFront()465 // defaults button466 await popup.click('button:nth-of-type(2)')467 // content tab468 await popup.click('.m-tabs a:nth-of-type(3)')469 await content.goto('about:blank')470 await content.bringToFront()471 await content.waitFor(300)472 // go to test page473 await content.goto('http://localhost:3000/popup-autoreload')474 await content.bringToFront()475 await content.waitFor(300)476 // enable autoreload477 await content.bringToFront()478 // autoreload switch479 await popup.click('.m-panel:nth-of-type(3) .m-switch:nth-of-type(5)')480 // content auto reloads481 await content.waitFor(300)482 // TODO: wait for https://github.com/GoogleChrome/puppeteer/pull/2812483 // update autoreload interval484 // await content.evaluate(() => state.ms = 250)485 })486 it('test ajax autoreload with non UTF-8 encoding and inactive tab', async () => {487 t.equal(488 await content.evaluate(() =>489 document.querySelector('#_html p').innerText.trim()490 ),491 '你好',492 'first request'493 )494 // the initial interval is 1000495 await content.waitFor(1300)496 t.equal(497 await content.evaluate(() =>498 document.querySelector('#_html p').innerText.trim()499 ),500 '你好',501 'second request - xhr body is UTF-8 - should not trigger reload'502 )503 // the initial interval is 1000504 await content.waitFor(1300)505 t.equal(506 await content.evaluate(() =>507 document.querySelector('#_html p').innerText.trim()508 ),509 '你好你好',510 'third request - actual change'511 )512 // popup513 await popup.bringToFront()514 // the initial interval is 1000515 await content.waitFor(1300)516 await content.bringToFront()517 t.equal(518 await content.evaluate(() =>519 document.querySelector('#_html p').innerText.trim()520 ),521 '你好你好你好',522 'fourth request - should reload inactive tab'523 )524 })525 })...

Full Screen

Full Screen

test.js

Source:test.js Github

copy

Full Screen

...36 $div1 = $container.find('#div1'),37 $div2 = $container.find('#div2'),38 $div3 = $container.find('#div3');39 QUnit.expect(3);40 stacker.bringToFront($div1);41 assert.equal(stacker.getCurrent(), 1010, 'index has been correctly incremented');42 stacker.bringToFront($div2);43 assert.equal(stacker.getCurrent(), 1020, 'index has been correctly incremented');44 stacker.bringToFront($div3);45 assert.equal(stacker.getCurrent(), 1030, 'index has been correctly incremented');46 });47 QUnit.module('.bringToFront()');48 QUnit.test('set the highest zIndex', function (assert) {49 var stacker = stackerFactory(),50 $container = $(fixtureContainer),51 $div1 = $container.find('#div1');52 QUnit.expect(3);53 assert.equal($div1.css('z-index'), 'auto', 'no z-index is set');54 stacker.bringToFront($div1);55 assert.equal($div1.css('z-index'), stacker.getCurrent(), 'z-index has been set to ' + stacker.getCurrent());56 stacker.reset($div1);57 assert.equal($div1.css('z-index'), 'auto', 'z-index has been removed');58 });59 QUnit.test('does not increase z-index if already max', function (assert) {60 var stacker = stackerFactory(),61 $container = $(fixtureContainer),62 $div1 = $container.find('#div1'),63 index;64 QUnit.expect(3);65 assert.equal($div1.css('z-index'), 'auto', 'no z-index is set');66 stacker.bringToFront($div1);67 index = stacker.getCurrent();68 assert.equal($div1.css('z-index'), index, 'z-index has been set');69 stacker.bringToFront($div1);70 assert.equal($div1.css('z-index'), index, 'z-index has not been increased again');71 });72 QUnit.test('increase z-index of multiple elements', function (assert) {73 var stacker = stackerFactory(),74 $container = $(fixtureContainer),75 $div1 = $container.find('#div1'),76 $div2 = $container.find('#div2'),77 $div3 = $container.find('#div3'),78 index1,79 index2 = 'auto',80 index3 = 'auto';81 QUnit.expect(18);82 stacker.bringToFront($div1);83 index1 = stacker.getCurrent();84 assert.equal($div1.css('z-index'), index1, 'div1 has the correct z-index');85 assert.equal($div2.css('z-index'), index2, 'div2 has the correct z-index');86 assert.equal($div3.css('z-index'), index3, 'div3 has the correct z-index');87 stacker.bringToFront($div2);88 index2 = stacker.getCurrent();89 assert.equal($div1.css('z-index'), index1, 'div1 has the correct z-index');90 assert.equal($div2.css('z-index'), index2, 'div2 has the correct z-index');91 assert.equal($div3.css('z-index'), index3, 'div3 has the correct z-index');92 stacker.bringToFront($div3);93 index3 = stacker.getCurrent();94 assert.equal($div1.css('z-index'), index1, 'div1 has the correct z-index');95 assert.equal($div2.css('z-index'), index2, 'div2 has the correct z-index');96 assert.equal($div3.css('z-index'), index3, 'div3 has the correct z-index');97 stacker.bringToFront($div1);98 index1 = stacker.getCurrent();99 assert.equal($div1.css('z-index'), index1, 'div1 has the correct z-index');100 assert.equal($div2.css('z-index'), index2, 'div2 has the correct z-index');101 assert.equal($div3.css('z-index'), index3, 'div3 has the correct z-index');102 stacker.bringToFront($div3);103 index3 = stacker.getCurrent();104 assert.equal($div1.css('z-index'), index1, 'div1 has the correct z-index');105 assert.equal($div2.css('z-index'), index2, 'div2 has the correct z-index');106 assert.equal($div3.css('z-index'), index3, 'div3 has the correct z-index');107 stacker.bringToFront($div2);108 index2 = stacker.getCurrent();109 assert.equal($div1.css('z-index'), index1, 'div1 has the correct z-index');110 assert.equal($div2.css('z-index'), index2, 'div2 has the correct z-index');111 assert.equal($div3.css('z-index'), index3, 'div3 has the correct z-index');112 });113 QUnit.module('.autoBringToFront()');114 QUnit.test('set the highest zIndex on mousedown', function (assert) {115 var stacker = stackerFactory(),116 $container = $(fixtureContainer),117 $div1 = $container.find('#div1'),118 $div2 = $container.find('#div2'),119 $div3 = $container.find('#div3'),120 index1,121 index2 = 'auto',122 index3 = 'auto';123 QUnit.expect(18);124 stacker.autoBringToFront($div1);125 stacker.autoBringToFront($div2);126 stacker.autoBringToFront($div3);127 $div1.trigger('mousedown');128 index1 = stacker.getCurrent();129 assert.equal($div1.css('z-index'), index1, 'div1 has the correct z-index');130 assert.equal($div2.css('z-index'), index2, 'div2 has the correct z-index');131 assert.equal($div3.css('z-index'), index3, 'div3 has the correct z-index');132 $div2.trigger('mousedown');133 index2 = stacker.getCurrent();134 assert.equal($div1.css('z-index'), index1, 'div1 has the correct z-index');135 assert.equal($div2.css('z-index'), index2, 'div2 has the correct z-index');136 assert.equal($div3.css('z-index'), index3, 'div3 has the correct z-index');137 $div3.trigger('mousedown');138 index3 = stacker.getCurrent();139 assert.equal($div1.css('z-index'), index1, 'div1 has the correct z-index');140 assert.equal($div2.css('z-index'), index2, 'div2 has the correct z-index');141 assert.equal($div3.css('z-index'), index3, 'div3 has the correct z-index');142 $div1.trigger('mousedown');143 index1 = stacker.getCurrent();144 assert.equal($div1.css('z-index'), index1, 'div1 has the correct z-index');145 assert.equal($div2.css('z-index'), index2, 'div2 has the correct z-index');146 assert.equal($div3.css('z-index'), index3, 'div3 has the correct z-index');147 $div3.trigger('mousedown');148 index3 = stacker.getCurrent();149 assert.equal($div1.css('z-index'), index1, 'div1 has the correct z-index');150 assert.equal($div2.css('z-index'), index2, 'div2 has the correct z-index');151 assert.equal($div3.css('z-index'), index3, 'div3 has the correct z-index');152 $div2.trigger('mousedown');153 index2 = stacker.getCurrent();154 assert.equal($div1.css('z-index'), index1, 'div1 has the correct z-index');155 assert.equal($div2.css('z-index'), index2, 'div2 has the correct z-index');156 assert.equal($div3.css('z-index'), index3, 'div3 has the correct z-index');157 });158 QUnit.module('Scopes');159 QUnit.test('handle different scopes', function(assert) {160 var stacker1 = stackerFactory('scope1'),161 stacker2 = stackerFactory('scope2'),162 stacker3 = stackerFactory('scope3'),163 $container = $(fixtureContainer),164 $div1 = $container.find('#div1'),165 $div2 = $container.find('#div2'),166 $div3 = $container.find('#div3'),167 $div4 = $container.find('#div4'),168 $div5 = $container.find('#div5'),169 $div6 = $container.find('#div6'),170 index1,171 index2 = 'auto',172 index3 = 'auto',173 index4 = 'auto',174 index5 = 'auto',175 index6 = 'auto';176 QUnit.expect(36);177 stacker1.bringToFront($div1);178 index1 = stacker1.getCurrent();179 assert.equal($div1.css('z-index'), index1, 'div1 has the correct z-index');180 assert.equal($div2.css('z-index'), index2, 'div2 has the correct z-index');181 assert.equal($div3.css('z-index'), index3, 'div3 has the correct z-index');182 assert.equal($div4.css('z-index'), index4, 'div4 has the correct z-index');183 assert.equal($div5.css('z-index'), index5, 'div5 has the correct z-index');184 assert.equal($div6.css('z-index'), index6, 'div6 has the correct z-index');185 stacker2.bringToFront($div2);186 index2 = stacker2.getCurrent();187 assert.equal($div1.css('z-index'), index1, 'div1 has the correct z-index');188 assert.equal($div2.css('z-index'), index2, 'div2 has the correct z-index');189 assert.equal($div3.css('z-index'), index3, 'div3 has the correct z-index');190 assert.equal($div4.css('z-index'), index4, 'div4 has the correct z-index');191 assert.equal($div5.css('z-index'), index5, 'div5 has the correct z-index');192 assert.equal($div6.css('z-index'), index6, 'div6 has the correct z-index');193 stacker3.bringToFront($div3);194 index3 = stacker3.getCurrent();195 assert.equal($div1.css('z-index'), index1, 'div1 has the correct z-index');196 assert.equal($div2.css('z-index'), index2, 'div2 has the correct z-index');197 assert.equal($div3.css('z-index'), index3, 'div3 has the correct z-index');198 assert.equal($div4.css('z-index'), index4, 'div4 has the correct z-index');199 assert.equal($div5.css('z-index'), index5, 'div5 has the correct z-index');200 assert.equal($div6.css('z-index'), index6, 'div6 has the correct z-index');201 stacker1.bringToFront($div4);202 index4 = stacker1.getCurrent();203 assert.equal($div1.css('z-index'), index1, 'div1 has the correct z-index');204 assert.equal($div2.css('z-index'), index2, 'div2 has the correct z-index');205 assert.equal($div3.css('z-index'), index3, 'div3 has the correct z-index');206 assert.equal($div4.css('z-index'), index4, 'div4 has the correct z-index');207 assert.equal($div5.css('z-index'), index5, 'div5 has the correct z-index');208 assert.equal($div6.css('z-index'), index6, 'div6 has the correct z-index');209 stacker3.bringToFront($div6);210 index6 = stacker3.getCurrent();211 assert.equal($div1.css('z-index'), index1, 'div1 has the correct z-index');212 assert.equal($div2.css('z-index'), index2, 'div2 has the correct z-index');213 assert.equal($div3.css('z-index'), index3, 'div3 has the correct z-index');214 assert.equal($div4.css('z-index'), index4, 'div4 has the correct z-index');215 assert.equal($div5.css('z-index'), index5, 'div5 has the correct z-index');216 assert.equal($div6.css('z-index'), index6, 'div6 has the correct z-index');217 stacker2.bringToFront($div5);218 index5 = stacker2.getCurrent();219 assert.equal($div1.css('z-index'), index1, 'div1 has the correct z-index');220 assert.equal($div2.css('z-index'), index2, 'div2 has the correct z-index');221 assert.equal($div3.css('z-index'), index3, 'div3 has the correct z-index');222 assert.equal($div4.css('z-index'), index4, 'div4 has the correct z-index');223 assert.equal($div5.css('z-index'), index5, 'div5 has the correct z-index');224 assert.equal($div6.css('z-index'), index6, 'div6 has the correct z-index');225 });...

Full Screen

Full Screen

containerManagerTestTest.js

Source:containerManagerTestTest.js Github

copy

Full Screen

...62 this.createPanels(3, cmp);63 }, function(cmp) {64 var stackManager = this.getStackManager(cmp);65 var panelRefs = this.getPanelRefs(cmp);66 stackManager.bringToFront(panelRefs[0]);67 this.verifyZIndices(this.getPanelRefs(cmp), ['4', '2', '3']);68 stackManager.bringToFront(panelRefs[1].getElement());69 this.verifyZIndices(this.getPanelRefs(cmp), ['4', '5', '3']);70 stackManager.bringToFront(panelRefs[2].getGlobalId());71 this.verifyZIndices(this.getPanelRefs(cmp), ['4', '5', '6']);72 }]73 },74 testStackManager: {75 attributes: {"useContainer": "true"},76 test: [function(cmp) {77 //initial panel_id => zIndex78 //panel_1 => 1 panelRefs[0]79 //panel_2 => 2 panelRefs[1]80 //panel_3 => 3 panelRefs[2]81 //panel_4 => 4 panelRefs[3]82 //panel_5 => 5 panelRefs[4]83 this.createPanels(5, cmp);84 }, function(cmp) {85 var stackManager = this.getStackManager(cmp);86 var panelRefs = this.getPanelRefs(cmp);87 var length = panelRefs.length;88 //after sendToBack89 //reverse loop90 //panel_5 => 5 =>sendToBack 0,1,2,3,491 //panel_4 => 4 =>sendToBack 0,1,2,392 //panel_3 => 3 =>sendToBack 0,1,293 //panel_2 => 2 =>sendToBack 0,194 //panel_1 => 1 =>sendToBack 095 panelRefs.slice(0,5).reverse().forEach(function(panel) {96 var panelEl = panel.getElement();97 stackManager.sendToBack(panelEl);98 });99 panelRefs.forEach(function(panel, index) {100 var panelEl = panel.getElement();101 $A.test.assertEquals(index, parseInt(panelEl.style.zIndex),102 "(sendToBack) Incorrect z-index value for panel id: " + panelEl.id);103 });104 //after bringToFront105 //regular loop106 //panel_1 => 1 =>bringToFront 5107 //panel_2 => 2 =>bringToFront 5,6108 //panel_3 => 3 =>bringToFront 5,6,7109 //panel_4 => 4 =>bringToFront 5,6,7,8110 //panel_5 => 5 =>bringToFront 5,6,7,8,9111 panelRefs.forEach(function(panel) {112 var panelEl = panel.getElement();113 stackManager.bringToFront(panelEl);114 });115 panelRefs.forEach(function(panel, index) {116 var panelEl = panel.getElement();117 $A.test.assertEquals((index+length), parseInt(panelEl.style.zIndex),118 "(bringToFront) Incorrect z-index value for panel id: " + panelEl.id);119 });120 }, function(cmp) {121 var panelRefs = this.getPanelRefs(cmp);122 var panel_2 = panelRefs[1];123 //delete panel_2 and assert newly assigned zIndexes124 panel_2.destroy();125 //1-5, 3-7, 4-8, 5-9126 //after you destroy panel_2, z-indexes will get recomputed127 //only if you call sendToBack or bringToFront...

Full Screen

Full Screen

filter.js

Source:filter.js Github

copy

Full Screen

...102 await sleep(1000);103 if (i == 11) {104 i = 0;105 }106 await page.bringToFront();107 try {108 await page.goto(109 `https://mail.google.com/mail/u/${i}/#settings/filters`,110 // https://mail.google.com/mail/u/${i}/h/1skwmxqy8dsdn/?&111 {112 waitUntil: "domcontentloaded",113 timeout: 1000 * 60 * 5,114 }115 );116 } catch (ex) {117 console.error(ex);118 // await browser.close()119 }120 await sleep(40000);121 await page.bringToFront();122 if (item.from == "delete") {123 const deleteFilter = await page.$x("//span[contains(., 'delete')]");124 if (deleteFilter[0]) {125 await deleteFilter[0].click();126 await page.bringToFront();127 await sleep(3000);128 const confirm = await page.$x("//button[contains(., 'OK')]");129 await confirm[0].click();130 await page.bringToFront();131 await sleep(3000);132 }133 } else {134 const createFilter = await page.$x(135 "//span[contains(., 'Create a new filter')]"136 );137 await createFilter[0].click();138 await page.bringToFront();139 await sleep(3000);140 // const from = await page.$x("//*[@class='ZH nr aQa']");141 // await from[0].type(item.from);142 // await sleep(1000)143 // const to = await page.$x("//*[@class='ZH nr aQf']");144 // await to[0].type(item.to);145 // await sleep(1000)146 // const subject = await page.$x("//*[@class='ZH nr aQd']");147 // await subject[0].type(item.subject);148 // await sleep(1000)149 // const hasWord = await page.$x("//*[@class='ZH nr aQb']");150 // await hasWord[0].type(item.hasword);151 // await sleep(1000)152 const doesntHave = await page.$x("//*[@class='ZH nr aP9']");153 await doesntHave[0].type("qwerty");154 await page.bringToFront();155 await sleep(1000);156 const clickcreateFilter = await page.$x("//*[@class='acM']");157 await clickcreateFilter[0].click();158 await page.bringToFront();159 await sleep(7000);160 const starcheck = await page.$x("//label[contains(., 'Star it')]");161 await starcheck[0].click();162 await page.bringToFront();163 await sleep(1000);164 const alwaymarkimp = await page.$x(165 "//label[contains(., 'Always mark it as important')]"166 );167 await alwaymarkimp[0].click();168 await page.bringToFront();169 await sleep(1000);170 const neverspam = await page.$x(171 "//label[contains(., 'Never send it to Spam')]"172 );173 await neverspam[0].click();174 await page.bringToFront();175 await sleep(1000);176 const categoryas = await page.$x(177 "//label[contains(., 'Categorize as:')]"178 );179 await categoryas[0].click();180 await page.bringToFront();181 await sleep(3000);182 // const categorycheck = await page.$x(183 // "//div[contains(., 'Choose category...')]"184 // );//*[@id=":82"]185 // if (categorycheck.length > 0) {186 // await categorycheck[0].click();187 // } else {188 // throw new Error(" Link not found");189 // }190 const categorycheck = await page.$x(191 "//*[@class='J-J5-Ji J-JN-M-I-JG']"192 );193 await categorycheck[2].click();194 await page.bringToFront();195 await sleep(2000);196 const clickprimary = await page.$x(197 "//div[@class='J-N'][contains(., 'Primary')]"198 );199 // const clickprimary = await page.$x(200 // );201 await clickprimary[0].click();202 await page.bringToFront();203 // const selectCategory = await page.$x("//div[contains(., 'Choose category...')]");204 // await selectCategory[0].click();205 // const selectCategory = await page.$x("//div[contains(@class, 'J-J5-Ji J-JN-M-I-Jm')]");206 // await selectCategory[0].click();207 // const primary = await page.$x("//div[contains(@aria-activedescendant, ':8q')]");208 // await primary[0].click();209 await sleep(1000);210 const finalclickcreateFilter = await page.$x(211 "//*[@class='T-I J-J5-Ji Zx acL T-I-atl L3']"212 );213 await page.bringToFront();214 await finalclickcreateFilter[0].click();215 await page.bringToFront();216 }217 }218 }219 return "DONE";220}221module.exports = {222 filterProcess,223};224const sleep = (time) => {225 return new Promise((resolve) => {226 setTimeout(() => {227 resolve(true);228 }, time);229 });...

Full Screen

Full Screen

origin-csp.js

Source:origin-csp.js Github

copy

Full Screen

...12 await advanced.waitFor(800)13 })14 describe('not correct content-type + non matching path', () => {15 before(async () => {16 await advanced.bringToFront()17 // enable csp18 if (!await advanced.evaluate(() => origins.state.origins['http://localhost:3000'].csp)) {19 await advanced.click('.m-list li:nth-of-type(1) .m-switch')20 }21 // go to page serving content with strict csp22 await content.goto('http://localhost:3000/csp-no-header-no-path')23 await content.bringToFront()24 await content.waitFor(300)25 })26 it('non matching urls should be skipped', async () => {27 t.strictEqual(28 await content.evaluate(() => {29 try {30 window.localStorage31 }32 catch (err) {33 return err.message.split(':')[1].trim()34 }35 }),36 `The document is sandboxed and lacks the 'allow-same-origin' flag.`,37 'localStorage should not be accessible'38 )39 })40 })41 describe('correct content-type + non matching path', () => {42 before(async () => {43 await advanced.bringToFront()44 // enable csp45 if (!await advanced.evaluate(() => origins.state.origins['http://localhost:3000'].csp)) {46 await advanced.click('.m-list li:nth-of-type(1) .m-switch')47 }48 // go to page serving content with strict csp49 await content.goto('http://localhost:3000/csp-match-header')50 await content.bringToFront()51 await content.waitFor(300)52 })53 it('non matching urls cannot be checked for enabled csp', async () => {54 t.strictEqual(55 await content.evaluate(() => {56 try {57 window.localStorage58 }59 catch (err) {60 return err.message.split(':')[1].trim()61 }62 }),63 `The document is sandboxed and lacks the 'allow-same-origin' flag.`,64 'localStorage should not be accessible'65 )66 })67 })68 describe('not correct content-type + matching path', () => {69 before(async () => {70 await advanced.bringToFront()71 // enable csp72 if (!await advanced.evaluate(() => origins.state.origins['http://localhost:3000'].csp)) {73 await advanced.click('.m-list li:nth-of-type(1) .m-switch')74 }75 // go to page serving content with strict csp76 await content.goto('http://localhost:3000/csp-match-path')77 await content.bringToFront()78 await content.waitFor(300)79 })80 it('webRequest.onHeadersReceived event is enabled', async () => {81 t.strictEqual(82 await content.evaluate(() =>83 window.localStorage.toString()84 ),85 '[object Storage]',86 'localStorage should be accessible'87 )88 })89 })90 describe('disable - enable - disable', () => {91 it('full cycle', async () => {92 // 1. disable93 await advanced.bringToFront()94 // disable csp95 if (await advanced.evaluate(() => origins.state.origins['http://localhost:3000'].csp)) {96 await advanced.click('.m-list li:nth-of-type(1) .m-switch')97 }98 await advanced.waitFor(300)99 // go to page serving content with strict csp100 await content.goto('http://localhost:3000/csp-match-path')101 await content.bringToFront()102 await content.waitFor(300)103 t.strictEqual(104 await content.evaluate(() => {105 try {106 window.localStorage107 }108 catch (err) {109 return err.message.split(':')[1].trim()110 }111 }),112 `The document is sandboxed and lacks the 'allow-same-origin' flag.`,113 'localStorage should not be accessible'114 )115 // 2. enable116 await advanced.bringToFront()117 // enable csp118 if (!await advanced.evaluate(() => origins.state.origins['http://localhost:3000'].csp)) {119 await advanced.click('.m-list li:nth-of-type(1) .m-switch')120 }121 await advanced.waitFor(300)122 // go to page serving content with strict csp123 await content.goto('http://localhost:3000/csp-match-path')124 await content.bringToFront()125 await content.waitFor(300)126 t.strictEqual(127 await content.evaluate(() =>128 window.localStorage.toString()129 ),130 '[object Storage]',131 'localStorage should be accessible'132 )133 // 3. disable134 await advanced.bringToFront()135 // disable csp136 if (await advanced.evaluate(() => origins.state.origins['http://localhost:3000'].csp)) {137 await advanced.click('.m-list li:nth-of-type(1) .m-switch')138 }139 await advanced.waitFor(300)140 // go to page serving content with strict csp141 await content.goto('http://localhost:3000/csp-match-path')142 await content.bringToFront()143 await content.waitFor(300)144 t.strictEqual(145 await content.evaluate(() => {146 try {147 window.localStorage148 }149 catch (err) {150 return err.message.split(':')[1].trim()151 }152 }),153 `The document is sandboxed and lacks the 'allow-same-origin' flag.`,154 'localStorage should not be accessible'155 )156 })157 })158 describe('persist state', () => {159 it('enable csp', async () => {160 await advanced.bringToFront()161 // enable csp162 if (!await advanced.evaluate(() => origins.state.origins['http://localhost:3000'].csp)) {163 await advanced.click('.m-list li:nth-of-type(1) .m-switch')164 }165 await advanced.reload()166 await advanced.waitFor(300)167 // expand origin168 await advanced.click('.m-list li:nth-of-type(1)')169 t.strictEqual(170 await advanced.evaluate(() =>171 document.querySelector('.m-list li:nth-of-type(1) .m-switch').classList.contains('is-checked')172 ),173 true,174 'csp checkbox should be enabled'175 )176 })177 it('disable csp', async () => {178 await advanced.bringToFront()179 // disable csp180 if (await advanced.evaluate(() => origins.state.origins['http://localhost:3000'].csp)) {181 await advanced.click('.m-list li:nth-of-type(1) .m-switch')182 }183 await advanced.reload()184 await advanced.waitFor(300)185 // expand origin186 await advanced.click('.m-list li:nth-of-type(1)')187 t.strictEqual(188 await advanced.evaluate(() =>189 document.querySelector('.m-list li:nth-of-type(1) .m-switch').classList.contains('is-checked')190 ),191 false,192 'csp checkbox should be disabled'193 )194 })195 })196 describe('enable csp + suspend the event page', () => {197 before(async () => {198 await advanced.bringToFront()199 // enable csp200 if (!await advanced.evaluate(() => origins.state.origins['http://localhost:3000'].csp)) {201 await advanced.click('.m-list li:nth-of-type(1) .m-switch')202 }203 // chrome://extensions204 await extensions.bringToFront()205 // enable developer mode206 await extensions.evaluate(() => {207 Array.from(208 document.querySelector('extensions-manager').shadowRoot209 .querySelector('extensions-item-list').shadowRoot210 .querySelectorAll('extensions-item'))[0].shadowRoot211 .querySelector('#enable-toggle').click()212 })213 // disable the extension214 await extensions.evaluate(() => {215 Array.from(216 document.querySelector('extensions-manager').shadowRoot217 .querySelector('extensions-item-list').shadowRoot218 .querySelectorAll('extensions-item'))[0].shadowRoot219 .querySelector('#enable-toggle').click()220 })221 await extensions.waitFor(300)222 // check223 t.equal(224 await extensions.evaluate(() =>225 Array.from(226 document.querySelector('extensions-manager').shadowRoot227 .querySelector('extensions-item-list').shadowRoot228 .querySelectorAll('extensions-item'))[0].shadowRoot229 .querySelector('#inspect-views a').innerText230 ),231 'background page (Inactive)',232 'background page should be inactive'233 )234 // go to page serving content with strict csp235 await content.goto('http://localhost:3000/csp-match-path')236 await content.bringToFront()237 await content.waitFor(300)238 })239 it('the tab is reloaded on event page wakeup', async () => {240 t.strictEqual(241 await content.evaluate(() =>242 window.localStorage.toString()243 ),244 '[object Storage]',245 'localStorage should be accessible'246 )247 })248 })...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch();4 const page = await browser.newPage();5 await page.bringToFront();6 await browser.close();7})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch();4 const page = await browser.newPage();5 await page.bringToFront();6 await browser.close();7})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch({headless: false});4 const page = await browser.newPage();5 await page.bringToFront();6 await browser.close();7})();8const puppeteer = require('puppeteer');9(async () => {10 const browser = await puppeteer.launch({headless: false});11 const page = await browser.newPage();12 await page.click('#tsf > div:nth-child(2) > div > div.RNNXgb > div > div.a4bIc > input');13 await page.type('#tsf > div:nth-child(2) > div > div.RNNXgb > div > div.a4bIc > input', 'Puppeteer');14 await page.click('#tsf > div:nth-child(2) > div > div.FPdoLc.VlcLAe > center > input.gNO89b');15 await browser.close();16})();17const puppeteer = require('puppeteer');18(async () => {19 const browser = await puppeteer.launch({headless: false});20 const page = await browser.newPage();21 await page.close();22 await browser.close();23})();24const puppeteer = require('puppeteer');25(async () => {26 const browser = await puppeteer.launch({headless: false});27 const page = await browser.newPage();28 const content = await page.content();29 console.log(content);30 await browser.close();31})();32const puppeteer = require('puppeteer');33(async () => {34 const browser = await puppeteer.launch({headless: false});35 const page = await browser.newPage();36 const cookies = await page.cookies();37 console.log(cookies);38 await browser.close();39})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch({headless: false});4 const page = await browser.newPage();5 await page.bringToFront();6 await browser.close();7})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch({ headless: false });4 const page = await browser.newPage();5 await page.bringToFront();6 await page.screenshot({ path: 'google.png' });7 await browser.close();8})();

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Puppeteer automation tests on LambdaTest cloud grid

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

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful