How to use parentFrame method in Puppeteer

Best JavaScript code snippet using puppeteer

graph.js

Source:graph.js Github

copy

Full Screen

1function Graph(frame) {2 //保存7种图形相对坐标的数组3// var arr = "0,1,0,2,1,2,2,2;0,1,1,1,1,2,2,2;0,1,0,2,1,1,2,1;0,2,1,1,1,2,2,1;1,0,1,1,1,2,1,3;1,1,1,2,2,1,2,2;1,1,2,0,2,1,2,2".split(";");4 //保存4个小图形的数组5 this.divs = [];6 //外部容器div的数组7 this.parentFrame = frame;8 //图形横纵偏移9 this.x = 0;10 this.y = 0;11 //记录图形的坐标数组12 this.zb = [];13 //记录消除的行数14 this.line=0;15 16 17 //初始化小图形的方法18 this.init = function(rand,color) {19 //计算图形其实坐标的单位20 var startleft = (this.parentFrame.row - 4) / 2;21 this.x = startleft;22 //随机生成图形数组下标23// var rand = Math.floor(Math.random() * arr.length);24 //分解图形的坐标25 var smallarr = this.parentFrame.arr[rand].split(",");26 this.zb = smallarr;27 //循环设置小div的 left和top28 for (var i = 0; i < 8; i += 2) {29 //创建小div30 var smalldiv = document.createElement("div");31 //设置样式32 smalldiv.className = "smallDiv";33 //设置颜色34 smalldiv.style.backgroundColor=color;35 //定义高宽36 smalldiv.style.width = (this.parentFrame.unit - 2) + "px";37 smalldiv.style.height = (this.parentFrame.unit - 2) + "px";38 //设置小div的top39 smalldiv.style.top = ((smallarr[i] - 0) * this.parentFrame.unit) + "px";40 //设置小div的left41 smalldiv.style.left = (((smallarr[i + 1] - 0) + startleft) * this.parentFrame.unit) + "px";42 //保存小div的引用43 this.divs.push(smalldiv); 44 //加入到外部容器45 document.getElementById("MainFrame").appendChild(smalldiv);46 }47 //执行自动向下移动48 //this.parentFrame.intervalid = setInterval(autoMoveDown, this.parentFrame.speed);49 }50 //左移动51 this.moveleft = function() {52 // var canmove = true;53 // //判断能否左移动54 // 55 // for(var i=0;i<this.divs.length;i++)56 // {57 // var left=parseInt(this.divs[i].style.left); //div目前的left58 // if(left - this.parentFrame.unit <0) //减去一个单位的像素是否小于059 // {60 // canmove = false; //不能向左移动了61 // break;62 // }63 // }64 if (canMove(this.zb, this.x, this.y, this.parentFrame, 2)) //可以移动65 {66 this.x -= 1;67 for (var i = 0; i < this.divs.length; i++) //循环小div,把每个div的left减去一个单位的像素68 {69 var left = parseInt(this.divs[i].style.left);70 this.divs[i].style.left = (left - this.parentFrame.unit) + "px";71 }72 }73 }74 //右移动75 this.moveright = function() {76 // var canmove = true;77 // //判断能否右移动78 // for(var i=0;i<this.divs.length;i++)79 // {80 // var left=parseInt(this.divs[i].style.left);81 // if(left + this.parentFrame.unit >=parseInt(this.parentFrame.Content.style.width))82 // {83 // canmove = false;84 // break;85 // }86 // }87 var temp = canMove(this.zb, this.x, this.y, this.parentFrame, 1);88// alert(temp);89 console.log(temp);90 if (canMove(this.zb, this.x, this.y, this.parentFrame, 1)) {91 this.x += 1;92 for (var i = 0; i < this.divs.length; i++) {93 var left = parseInt(this.divs[i].style.left);94 this.divs[i].style.left = (left + this.parentFrame.unit) + "px";95 }96 }97 }98 //变形99 this.change = function() {100 //变形的公式101 //小div的2个相对坐标点改变 x = y ; y= 3-x; 比如 (0,1) 变化之后 就是 x=1,y=3-0 -> (1,3)102 //循环4个小div103 if (!canMove(this.zb, this.x, this.y, this.parentFrame, 4)) {104 if (this.x < 0) {105 this.x += 1;106 } else {107 this.x -= 1;108 }109 }110 for (var i = 0; i < this.divs.length; i++) {111 //根据公式改变每个div的相对偏移量,2个一改112 var temp = this.zb[i * 2]113 this.zb[i * 2] = this.zb[i * 2 + 1];114 this.zb[i * 2 + 1] = 3 - temp;115 //根据改变后的偏移量计算图形的当前left和top116 this.divs[i].style.top = ((this.y + parseInt(this.zb[i * 2])) * this.parentFrame.unit) + "px";117 this.divs[i].style.left = ((this.x + parseInt(this.zb[i * 2 + 1])) * this.parentFrame.unit) + "px";118 }119 }120 this.movedown = function() {121 122 var $this = this =="window" ? this.frame.samlldiv : this;123 124 if (canMove($this.zb, $this.x, $this.y, $this.parentFrame, 3)) {125 $this.y += 1;126 for (var i = 0; i < $this.divs.length; i++) {127 var top = parseInt($this.divs[i].style.top);128 $this.divs[i].style.top = (top + $this.parentFrame.unit) + "px";129 }130 return false;131 } else {132 clearInterval($this.parentFrame.intervalid);133// var temp = $this.parentFrame.Content.getElementsByTagName("div");134 for (var i=0;i<$this.divs.length;i++) {135 //div变灰136 //$this.divs[i].className ="smallDivblack";137 var $y = $this.y + parseInt($this.zb[i*2]);138 var $x = $this.x+parseInt($this.zb[i*2+1]);139// debugger;140 $this.parentFrame.datas[$y*$this.parentFrame.row+ $x] =1;141 $this.divs[i].dataset.row=$y; //记录div所在的行142 $this.divs[i].dataset.col=$x; //记录div所在的列143 $this.divs[i].className="smallDivblack";144 $this.divs[i].style.backgroundColor="black";145 //$this.parentFrame.datas[]146 }147 148 149 //消行并计分150 for (var i= 0;i<$this.parentFrame.col;i++) { //i为行151 //判断是否满足消行条件152 for (var j=0;j<$this.parentFrame.row;j++) { //j为列153 if($this.parentFrame.datas[i*$this.parentFrame.row+ j] !=1){154 break;155 }156 }157 //消行,将该行上面的所有div下移一行158 if(j==$this.parentFrame.row){159 var x; //记录div在哪一列160 var y; //记录div在哪一行161 var getsmalldiv=document.getElementById("TFrime").getElementsByClassName("smallDivblack");//得到小div162 for (var a=0;a<getsmalldiv.length;a++){163 y=parseInt(getsmalldiv[a].dataset.row);164 x=parseInt(getsmalldiv[a].dataset.col);165 if(y==i){ //消除该行166 debugger;167 $this.parentFrame.datas[y*$this.parentFrame.row+ x]=0;168 getsmalldiv[a].remove();169 a--;170 }171 }172 173 for (var a=i-1;a>0;a--) {174 for (var b=0;b<getsmalldiv.length;b++) {175 y=parseInt(getsmalldiv[b].dataset.row);176 x=parseInt(getsmalldiv[b].dataset.col);177 if(y==a){ //将上面的div下移一行178// debugger;179 var divtop=parseInt(getsmalldiv[b].style.top);180 getsmalldiv[b].style.top=(divtop+$this.parentFrame.unit)+"px";181 getsmalldiv[b].dataset.row++;182 $this.parentFrame.datas[y*$this.parentFrame.row+ x]=0;183 $this.parentFrame.datas[(y+1)*$this.parentFrame.row+ x]=1;184 }185 }186 187 }188 $this.line++;189 190// for (var a=0;a<getsmalldiv.length;a++) {191// y=parseInt(getsmalldiv[a].dataset.row);192// x=parseInt(getsmalldiv[a].dataset.col);193//// alert(getsmalldiv[a].dataset.row);194// if(y<i){ //将上面的div下移一行195//// debugger;196// var divtop=parseInt(getsmalldiv[a].style.top);197//// alert(getsmalldiv[a].style.top);198// getsmalldiv[a].style.top=(divtop+$this.parentFrame.unit)+"px";199// getsmalldiv[a].dataset.row++;200// debugger;201// $this.parentFrame.datas[y*$this.parentFrame.row+ x]=0;202// $this.parentFrame.datas[(y+1)*$this.parentFrame.row+ x]=1;203// }204//// }else if(y==i){ //消除该行205//// debugger;206//// $this.parentFrame.datas[y*$this.parentFrame.row+ x]=0;207//// getsmalldiv[a].className="MainFramediv";208//// }209// }210 }211 }212 213 return true;214 }215 }216// function autoMoveDown() {217// 218// var small = this.frame.samlldiv;219// var f = this.frame;220// 221// if (canMove(small.zb, small.x, small.y, 0, f.col, 3)) {222// small.y += 1;223// for (var i = 0; i < small.divs.length; i++) {224// var top = parseInt(small.divs[i].style.top);225// small.divs[i].style.top = (top + f.unit) + "px";226// }227// } else {228// clearInterval(f.intervalid);229// }230//231// }232 //预判能否移动或变化,action:1.右移,2.左移,3.下移,4.变化233 //zb是4个小图形的相对偏移,x是图形左偏移,y是top偏移,f是外部frame234 function canMove(zb, x, y, f, action) {235 //datas[parseInt(zb[i + 1]) + x + 1)+(this.y-1)*row] !=0236 237 switch (action) {238 case 1:239// debugger;240 for (var i = 0; i < zb.length; i += 2) {241 if (parseInt(zb[i + 1]) + x + 1 >= f.row)242 {243 return false;244 }else if(f.datas[(parseInt(zb[i + 1]) + x + 1)+(y+parseInt(zb[i]))*f.row] !=0)245 {246 return false;247 }248 }249 break;250 case 2:251 for (var i = 0; i < zb.length; i += 2) {252 if (parseInt(zb[i + 1]) + x - 1 < 0 ) {253 return false;254 }else if(f.datas[(parseInt(zb[i + 1]) + x - 1)+(y+parseInt(zb[i]))*f.row] !=0)255 {256 return false;257 }258 }259 break;260 case 3:261 for (var i = 0; i < zb.length; i += 2) {262 if (parseInt(zb[i]) + y + 1 >= f.col ||263 f.datas[(parseInt(zb[i + 1]) + x)+(parseInt(zb[i]) + y+1)*f.row] !=0) {264 return false;265 }266 }267 break;268 case 4:269 for (var i = 0; i < zb.length; i += 2) {270 var temp = 3 - zb[i];271 if (temp + x < 0 || temp + x >= f.row) {272 return false;273 }274 }275 break;276 }277 return true;278 }279 280 this.rescore=function(){281 var gamescore=document.getElementById("score");282 gamescore.innerHTML=parseInt(gamescore.innerHTML)+this.parentFrame.score[this.line];283 }...

Full Screen

Full Screen

teacherList.js

Source:teacherList.js Github

copy

Full Screen

1var parentFrame;2var singleChecks;3var modifyModal;4var resetPwdModal;5var deleteItemModal;6$(function () {7 parentFrame = parent.$(window.parent.document);8 singleChecks = $(".single .form-check-sign");9 modifyModal = {10 modal: $("#modifyModal"),11 id: $("#id"),12 teacherNum: $("#teacherNum"),13 name: $("#teacherName"),14 email: $("#email")15 };16 resetPwdModal = $("#resetPwdModal");17 deleteItemModal = $("#deleteItemModal");18 singleChecks.click(function () {19 //A little messed...20 // 确认自己为checked,并修改所在列的显示效果21 var item = $(this).parent().parent().parent().parent();22 var check = $(this);23 if (check.hasClass("checked")) {24 item.removeClass("chosen");25 check.removeClass("checked");26 } else {27 item.addClass("chosen");28 check.addClass("checked");29 }30 });31 modifyModal.modal.on("show.bs.modal", function (event) {32 var item = $(event.relatedTarget).parent().parent();33 modifyModal.id.val(item.attr("data-id"));34 modifyModal.name.val(item.find(".name").html());35 modifyModal.name.parent().addClass("is-filled");36 modifyModal.teacherNum.val(item.find(".teacherNum").html());37 modifyModal.teacherNum.parent().addClass("is-filled");38 modifyModal.email.val(item.find(".email").html());39 modifyModal.email.parent().addClass("is-filled");40 });41 resetPwdModal.on("show.bs.modal", function (event) {42 $(this).find(".confirm").attr("data-gist", $(event.relatedTarget).attr("data-gist"));43 });44 deleteItemModal.on("show.bs.modal", function (event) {45 $(this).find(".confirm").attr("data-gist", $(event.relatedTarget).attr("data-gist"));46 });47 modifyModal.modal.find(".confirm").click(function () {48 var btn = $(this);49 var form = modifyModal.modal.find(".form");50 if (util.verifyWithPop(form)) {51 $.ajax({52 type: "patch",53 url: "/admin/teacher",54 contentType: "application/json; charset=utf-8",55 data: JSON.stringify(form.serializeObject()),56 success: function (result, status, xhr) {57 if (xhr.status === 200) {58 modifyModal.modal.modal("hide");59 parentFrame.trigger("showNotification", ["修改成功", "success"]);60 location.reload();61 }62 },63 error: function () {64 if (xhr.status === 409) {65 btn.delayedPop("修改失败,工号不存在", 3);66 } else {67 btn.delayedPop("修改失败,未知错误", 3);68 }69 }70 });71 }72 });73 resetPwdModal.find(".confirm").click(function () {74 $.ajax({75 type: "patch",76 url: "/admin/teacher/" + $(this).attr("data-gist") + "/resetPwd",77 success: function () {78 resetPwdModal.modal("hide");79 parentFrame.trigger("showNotification", ["重置密码成功", "success"]);80 location.reload();81 },82 error: function () {83 $(resetPwdModal.find(".confirm")).delayedPop("重置密码失败", 3);84 }85 });86 });87 deleteItemModal.find(".confirm").click(function () {88 $.ajax({89 type: "delete",90 url: "/admin/teacher/" + $(this).attr("data-gist"),91 success: function () {92 deleteItemModal.modal("hide");93 parentFrame.trigger("showNotification", ["删除成功", "success"]);94 location.reload();95 },96 error: function () {97 $(deleteItemModal.find(".confirm")).delayedPop("删除失败", 3);98 }99 });100 });101 var table = $(".table");102 if (table.attr("data-new") === "true") {103 parentFrame.trigger("pageReset", [table.attr("data-pages"), 1]);104 }105 var page = table.attr("data-page");106 if (page !== parent.$("#pagination").find(".active>a").html()) {107 parentFrame.trigger("pageReset", [table.attr("data-pages"), page]);108 }...

Full Screen

Full Screen

studentList.js

Source:studentList.js Github

copy

Full Screen

1var parentFrame;2var singleChecks;3var modifyModal;4var resetPwdModal;5var deleteItemModal;6$(function () {7 parentFrame = parent.$(window.parent.document);8 singleChecks = $(".single .form-check-sign");9 modifyModal = {10 modal: $("#modifyModal"),11 id: $("#id"),12 studentNum: $("#studentNum"),13 name: $("#name"),14 email: $("#email")15 };16 resetPwdModal = $("#resetPwdModal");17 deleteItemModal = $("#deleteItemModal");18 singleChecks.click(function () {19 //A little messed...20 // 确认自己为checked,并修改所在列的显示效果21 var item = $(this).parent().parent().parent().parent();22 var check = $(this);23 if (check.hasClass("checked")) {24 item.removeClass("chosen");25 check.removeClass("checked");26 } else {27 item.addClass("chosen");28 check.addClass("checked");29 }30 });31 modifyModal.modal.on("show.bs.modal", function (event) {32 var item = $(event.relatedTarget).parent().parent();33 modifyModal.id.val(item.attr("data-id"));34 modifyModal.name.val(item.find(".name").html());35 modifyModal.name.parent().addClass("is-filled");36 modifyModal.studentNum.val(item.find(".studentNum").html());37 modifyModal.studentNum.parent().addClass("is-filled");38 modifyModal.email.val(item.find(".email").html());39 modifyModal.email.parent().addClass("is-filled");40 });41 resetPwdModal.on("show.bs.modal", function (event) {42 $(this).find(".confirm").attr("data-gist", $(event.relatedTarget).attr("data-gist"));43 });44 deleteItemModal.on("show.bs.modal", function (event) {45 $(this).find(".confirm").attr("data-gist", $(event.relatedTarget).attr("data-gist"));46 });47 modifyModal.modal.find(".confirm").click(function () {48 var btn = $(this);49 var form = modifyModal.modal.find(".form");50 if (util.verifyWithPop(form)) {51 $.ajax({52 type: "patch",53 url: "/admin/student",54 contentType: "application/json; charset=utf-8",55 data: JSON.stringify(form.serializeObject()),56 success: function (result, status, xhr) {57 if (xhr.status === 200) {58 modifyModal.modal.modal("hide");59 parentFrame.trigger("showNotification", ["修改成功", "success"]);60 location.reload();61 } else if (xhr.status === 204) {62 btn.delayedPop("修改失败,学号不存在", 3);63 }64 },65 error: function () {66 btn.delayedPop("修改失败,未知错误", 3);67 }68 });69 }70 });71 resetPwdModal.find(".confirm").click(function () {72 $.ajax({73 type: "patch",74 url: "/admin/student/" + $(this).attr("data-gist") + "/resetPwd",75 success: function () {76 resetPwdModal.modal("hide");77 parentFrame.trigger("showNotification", ["重置密码成功", "success"]);78 location.reload();79 },80 error: function () {81 $(resetPwdModal.find(".confirm")).delayedPop("删除失败", 3);82 }83 });84 });85 deleteItemModal.find(".confirm").click(function () {86 $.ajax({87 type: "delete",88 url: "/admin/student/" + $(this).attr("data-gist"),89 success: function () {90 deleteItemModal.modal("hide");91 parentFrame.trigger("showNotification", ["删除成功", "success"]);92 location.reload();93 },94 error: function () {95 $(deleteItemModal.find(".confirm")).delayedPop("删除失败", 3);96 }97 });98 });99 var table = $(".table");100 if (table.attr("data-new") === "true") {101 parentFrame.trigger("pageReset", [table.attr("data-pages"), 1]);102 }103 var page = table.attr("data-page");104 if (page !== parent.$("#pagination").find(".active>a").html()) {105 parentFrame.trigger("pageReset", [table.attr("data-pages"), page]);106 }...

Full Screen

Full Screen

app.js

Source:app.js Github

copy

Full Screen

1/**2 * UI v1.1.03 * Copyright 2017-2018 Muyao4 * Licensed under the Muyao License 1.0 5 */6(function (window, document, $) {7 'use strict';8 // 父级dom节点9 $.parentFrame = $(window.parent.document);10 // 父级方法&属性11 var parentFrame = window.parentFrame = window.parent;12 // 项目名称13 $.ctx = parentFrame.$.ctx;14 // 配置颜色获取方法15 $.colors = parentFrame.$.colors;16 // 注册组件默认配置参数获取方法17 $.po = parentFrame.$.po;18 // 本地存储对象操作19 $.storage = parentFrame.$.storage;20 $.sessionStorage = parentFrame.$.sessionStorage;21 // 网址基础设置对象22 $.site = parentFrame.$.site;23 if ($.site && $.site.contentTabs)24 $.site.contentTabs.ifameTabs(document);25 // 配置信息存储管理26 $.configs = parentFrame.$.configs;27 // 注册组件初始化28 if (parentFrame.$.components)29 parentFrame.$.components.init(document, window);30 // 公用对象31 window.Breakpoints = parentFrame.Breakpoints;32 window.toastr = parentFrame.toastr;33 window.layer = parentFrame.layer;34 window.haoutil = parentFrame.haoutil;35 window.notifyFn = parentFrame.$.notifyFn;36 // 自定义扩展对象37 var _objExtend = _objExtend || {};38 $.extend(_objExtend, {39 _queue: {40 prepare: [],41 run: [],42 complete: []43 },44 run: function () {45 var self = this;46 this._dequeue('prepare', function () {47 self._trigger('before.run', self);48 });49 this._dequeue('run', function () {50 self._dequeue('complete', function () {51 self._trigger('after.run', self);52 });53 });54 },55 _dequeue: function (name, done) { // 队列当前状态离队,进行下一步操作56 var self = this,57 queue = this._getQueue(name),58 fn = queue.shift(),59 next = function () {60 self._dequeue(name, done);61 };62 if (fn) {63 fn.call(this, next);64 } else if ($.isFunction(done)) {65 done.call(this);66 }67 },68 _getQueue: function (name) { // 获取队列状态信息69 if (!$.isArray(this._queue[name])) {70 this._queue[name] = [];71 }72 return this._queue[name];73 },74 extend: function (obj) { // 公用模块对象扩展方法75 $.each(this._queue, function (name, queue) {76 if ($.isFunction(obj[name])) {77 queue.unshift(obj[name]);78 delete obj[name];79 }80 });81 $.extend(this, obj);82 return this;83 },84 _trigger: function (name, data, $el) { // 离队状态执行动作85 if (typeof name === 'undefined') {86 return;87 }88 if (typeof $el === 'undefined') {89 $el = $("#admui-pageContent");90 }91 $el.trigger(name + '.app', data);92 }93 });94 // 通用功能对象(可配置增加,也可扩展)95 var _app = {96 pageAside: function () { // 小屏幕下侧边栏(展开&收起)操作97 var pageAside = $(".page-aside"),98 isOpen = pageAside.hasClass('open');99 pageAside.toggleClass('open', !isOpen);100 },101 run: function (next) {102 var self = this;103 // 侧边栏开关104 $(document).on('click', '.page-aside-switch', function (e) {105 self.pageAside();106 e.stopPropagation();107 });108 next();109 }110 };111 window.App = $.extend({}, _objExtend);112 App.extend(_app);...

Full Screen

Full Screen

cpTemp.js

Source:cpTemp.js Github

copy

Full Screen

1/*******************************************************************************2 * Copyright ©2015. IT Services Jacek Kurasiewicz, Warsaw, Poland. All Rights3 * Reserved.4 *5 * Republication, redistribution, granting a license to other parties, using,6 * copying, modifying this software and its documentation is prohibited without the7 * prior written consent of IT Services Jacek Kurasiewicz.8 * Contact The Office of IT Services Jacek Kurasiewicz, ul. Koszykowa 60/62 lok.9 * 43, 00-673 Warszawa, jk@softpro.pl, +48 512-25-67-67, for commercial licensing10 * opportunities.11 *12 * IN NO EVENT SHALL IT SERVICES JACEK KURASIEWICZ BE LIABLE TO ANY PARTY FOR13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST14 * PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF15 * IT SERVICES JACEK KURASIEWICZ HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH16 * DAMAGE.17 *18 * IT SERVICES JACEK KURASIEWICZ SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A20 * PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY,21 * PROVIDED HEREUNDER IS PROVIDED "AS IS". IT SERVICES JACEK KURASIEWICZ HAS NO22 * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR23 * MODIFICATIONS.24 *******************************************************************************/25/*26 * This file is to be delete when the port of the apps to fulcrum is complete27 */2829var currentPanel;3031function hover(tab)32{33 tab.style.backgroundColor = '#ffffc0';34 tab.style.color = '#1D5EAA';35}3637function getCurrentPanel(parentFrame)38{39 if (parentFrame != null && typeof(parentFrame) != "undefined")40 {41 return parentFrame.currentPanel;42 }43 return currentPanel;44}4546function setCurrentPanel(newpanel, parentFrame)47{48 if (parentFrame != null && typeof(parentFrame) != "undefined")49 {50 parentFrame.currentPanel = newpanel;51 }52 else53 {54 currentPanel = newpanel;55 }56}5758function setState(tabNum, parentFrame)59{60 var documentToUse = document;6162 if (parentFrame != null && typeof(parentFrame) != "undefined")63 {64 documentToUse = parentFrame.document;65 }66 if (tabNum == getCurrentPanel(parentFrame))67 {68 documentToUse.getElementById('tab' + tabNum).style.backgroundColor = '#ddddff';69 documentToUse.getElementById('tab' + tabNum).style.color = 'navy';70 }71 else72 {73 documentToUse.getElementById('tab' + tabNum).style.backgroundColor = '#FFFFF4';74 documentToUse.getElementById('tab' + tabNum).style.color = '#1D5EAA';75 }76}7778function showPanel(newpanel, parentFrame)79{80 var documentToUse = document;8182 if (parentFrame != null && typeof(parentFrame) != "undefined")83 {84 documentToUse = parentFrame.document;85 }86 var panel = getCurrentPanel(parentFrame);8788 // Hide the current panel.89 if (panel != null && typeof(panel) != "undefined")90 {91 hidePanel(parentFrame);92 }9394 // Show the selected panel.95 documentToUse.getElementById('tabpanel' + newpanel).style.display = 'block';9697 // Update current panel.98 setCurrentPanel(newpanel, parentFrame);99100 // Set current panel state.101 setState(newpanel, parentFrame);102}103104function hidePanel(parentFrame)105{106 var documentToUse = document;107108 if (parentFrame != null && typeof(parentFrame) != "undefined")109 {110 documentToUse = parentFrame.document;111 }112 var curPanel = getCurrentPanel(parentFrame);113114 // Hide visible panel and unhighlight tab.115 if (documentToUse != null)116 {117 var tabpanel = getDocumentObjectFromObject(documentToUse, 'tabpanel' + curPanel);118 if (tabpanel != null)119 {120 tabpanel.style.display = 'none';121 }122123 var tab = getDocumentObjectFromObject(documentToUse, 'tab' + curPanel);124 if (tab != null)125 {126 tab.style.backgroundColor = '#FFFFF4';127 tab.style.color = '#1D5EAA';128 }129130 }131}132133function addOverFlow()134{135 dojo.byId("mainFrame").style.overflow = 'auto'; ...

Full Screen

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.click('a[href="/search?q=google&source=hp&ei=5aX9XcT4D4bA4-EPjZ6U4A4&iflsig=AINFCbYAAAAAYKXQ7VvY2YlQ8z0nL1b3KqBpDZI0g1Rf"]');6 await page.waitForNavigation();7 await page.waitForTimeout(1000);8 await page.click('a[href="/search?q=google&source=hp&ei=5aX9XcT4D4bA4-EPjZ6U4A4&iflsig=AINFCbYAAAAAYKXQ7VvY2YlQ8z0nL1b3KqBpDZI0g1Rf"]');9 await page.waitForNavigation();10 await page.waitForTimeout(1000);11 await page.click('a[href="/search?q=google&source=hp&ei=5aX9XcT4D4bA4-EPjZ6U4A4&iflsig=AINFCbYAAAAAYKXQ7VvY2YlQ8z0nL1b3KqBpDZI0g1Rf"]');12 await page.waitForNavigation();13 await page.waitForTimeout(1000);14 await page.click('a[href="/search?q=google&source=hp&ei=5aX9XcT4D4bA4-EPjZ6U4A4&iflsig=AINFCbYAAAAAYKXQ7VvY2YlQ8z0nL1b3KqBpDZI0g1Rf"]');15 await page.waitForNavigation();16 await page.waitForTimeout(1000);17 await page.click('a[href="/search?q=google&source=hp&ei=5aX9XcT4D4bA4-EPjZ6U4A4&iflsig=AINFCbYAAAAAYKXQ

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2const fs = require('fs');3(async () => {4 const browser = await puppeteer.launch({ headless: false });5 const page = await browser.newPage();6 await page.type('input[name="q"]', 'puppeteer');7 await page.click('input[name="btnK"]');8 await page.waitForNavigation();9 await page.waitForSelector('div[id="result-stats"]');10 const pageContent = await page.content();11 fs.writeFileSync('google.html', pageContent);12 await browser.close();13})();14const puppeteer = require('puppeteer');15const fs = require('fs');16(async () => {17 const browser = await puppeteer.launch({ headless: false });18 const page = await browser.newPage();19 await page.type('input[name="q"]', 'puppeteer');20 await page.click('input[name="btnK"]');21 await page.waitForNavigation();22 await page.waitForSelector('div[id="result-stats"]');23 const pageContent = await page.content();24 fs.writeFileSync('google.html', pageContent);25 await browser.close();26})();27const puppeteer = require('puppeteer');28const fs = require('fs');29(async () => {30 const browser = await puppeteer.launch({ headless: false });31 const page = await browser.newPage();32 await page.type('input[name="q"]', 'puppeteer');33 await page.click('input[name="btnK"]');34 await page.waitForNavigation();35 await page.waitForSelector('div[id="result-stats"]');36 const pageContent = await page.content();37 fs.writeFileSync('google.html', pageContent);38 await browser.close();39})();40const puppeteer = require('puppeteer');41const fs = require('fs');42(async () => {43 const browser = await puppeteer.launch({ headless: false });44 const page = await browser.newPage();45 await page.type('input[name="q"]', '

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2const path = require('path');3const fs = require('fs');4(async () => {5 const browser = await puppeteer.launch();6 const page = await browser.newPage();7 await page.screenshot({ path: 'google.png' });8 await browser.close();9})();10const puppeteer = require('puppeteer');11const path = require('path');12const fs = require('fs');13(async () => {14 const browser = await puppeteer.launch();15 const page = await browser.newPage();16 await page.screenshot({ path: 'google.png' });17 await browser.close();18})();19const puppeteer = require('puppeteer');20const path = require('path');21const fs = require('fs');22(async () => {23 const browser = await puppeteer.launch();24 const page = await browser.newPage();25 await page.screenshot({ path: 'google.png' });26 await browser.close();27})();28const puppeteer = require('puppeteer');29const path = require('path');30const fs = require('fs');31(async () => {32 const browser = await puppeteer.launch();33 const page = await browser.newPage();34 await page.screenshot({ path: 'google.png' });35 await browser.close();36})();37const puppeteer = require('puppeteer');38const path = require('path');39const fs = require('fs');40(async () => {41 const browser = await puppeteer.launch();42 const page = await browser.newPage();43 await page.screenshot({ path: 'google.png' });44 await browser.close();45})();46const puppeteer = require('puppeteer');47const path = require('path');48const fs = require('fs');49(async () => {

Full Screen

Using AI Code Generation

copy

Full Screen

1var puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch({headless: false});4 const page = await browser.newPage();5 await page.waitFor(5000);6 await page.evaluate(() => {7 var frame = document.getElementById('iframeId');8 frame.contentWindow.parentFrame();9 });10 await page.waitFor(5000);11 await browser.close();12})();13function parentFrame() {14 alert('parentFrame');15}

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.waitForSelector('input[aria-label="Search Google Maps"]');6 await page.type('input[aria-label="Search Google Maps"]', 'pizza');7 await page.waitForSelector('button[aria-label="Search Google Maps"]');8 await page.click('button[aria-label="Search Google Maps"]');9 await page.waitFor(1000);10 await page.waitForSelector('div.section-result-text-content');11 await page.click('div.section-result-text-content');12 await page.waitFor(1000);13 await page.waitForSelector('button[aria-label="Directions"]');14 await page.click('button[aria-label="Directions"]');15 await page.waitFor(1000);16 await page.waitForSelector('div.section-directions-trip-description');17 await page.click('div.section-directions-trip-description');18 await page.waitFor(1000);19 await page.waitForSelector('div.section-directions-trip-description');20 await page.click('div.section-directions-trip-description');21 await page.waitFor(1000);22 await page.waitForSelector('div.section-directions-trip-description');23 await page.click('div.section-directions-trip-description');24 await page.waitFor(1000);25 await page.waitForSelector('div.section-directions-trip-description');26 await page.click('div.section-directions-trip-description');27 await page.waitFor(1000);28 await page.waitForSelector('div.section-directions-trip-description');29 await page.click('div.section-directions-trip-description');30 await page.waitFor(1000);31 await page.waitForSelector('div.section-directions-trip-description');32 await page.click('div.section-directions-trip-description');33 await page.waitFor(1000);34 await page.waitForSelector('div.section-directions-trip-description');35 await page.click('div.section-directions-trip-description');36 await page.waitFor(1000);37 await page.waitForSelector('div.section-directions-trip-description');38 await page.click('div.section-directions-trip-description');39 await page.waitFor(1000);40 await page.waitForSelector('div.section-directions-trip-description');41 await page.click('div.section-directions-trip-description');42 await page.waitFor(1000);

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.waitFor(5000);6 await page.screenshot({path: 'example.png'});7 await browser.close();8})();

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 const frame = page.frames().find(frame => frame.name() === 'gsft_main');6 const parentFrame = frame.parentFrame();7 console.log(parentFrame);8 await browser.close();9})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const frame = await page.mainFrame().childFrames()[0];2const parentFrame = frame.parentFrame();3const childFrame = await parentFrame.childFrames()[0];4await page.waitForSelector('#myId');5await page.waitForSelector('#myId');6await page.click('#myId');7await page.waitForSelector('#myId');8await page.type('#myId', 'my text');9const text = await page.waitForSelector('#myId');10const text = await page.$eval('#myId', (el) => el.textContent);

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