Best JavaScript code snippet using puppeteer
frame.js
Source:frame.js
1/**2 Title:æ¡æ¶æ§å¶æéè¦çJS代ç 3 author:侯å4 date:2005å¹´07-07æ¥5 */6//var rootpath = "/TopIcms";7var webroot = document.location.href;8webroot = webroot.substring(webroot.indexOf('//') + 2, webroot.length);9webroot = webroot.substring(webroot.indexOf('/') + 1, webroot.length);10webroot = webroot.substring(0, webroot.indexOf('/'));11var rootpath = '/' + webroot;12/*以ä¸å 个æ¹æ³æ¯å©Dreamweaverèªå¨äº§çç代ç ï¼ä¸»è¦ç¨äºæ§å¶å¾ççåæ¢ææ*/13function MM_preloadImages() { //v3.014 var d = document;15 if (d.images) {16 if (!d.MM_p) d.MM_p = new Array();17 var i,j = d.MM_p.length,a = MM_preloadImages.arguments;18 for (i = 0; i < a.length; i++)19 if (a[i].indexOf("#") != 0) {20 d.MM_p[j] = new Image;21 d.MM_p[j++].src = a[i];22 }23 }24}25function MM_swapImgRestore() { //v3.026 var i,x,a = document.MM_sr;27 for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;28}29function MM_findObj(n, d) { //v4.0130 var p,i,x;31 if (!d) d = document;32 if ((p = n.indexOf("?")) > 0 && parent.frames.length) {33 d = parent.frames[n.substring(p + 1)].document;34 n = n.substring(0, p);35 }36 if (!(x = d[n]) && d.all) x = d.all[n];37 for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];38 for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);39 if (!x && d.getElementById) x = d.getElementById(n);40 return x;41}42function MM_swapImage() { //v3.043 var i,j = 0,x,a = MM_swapImage.arguments;44 document.MM_sr = new Array;45 for (i = 0; i < (a.length - 2); i += 3)46 if ((x = MM_findObj(a[i])) != null) {47 document.MM_sr[j++] = x;48 if (!x.oSrc) x.oSrc = x.src;49 x.src = a[i + 2];50 }51}52//éèæ´ä¸ªè§å¾åº53function hideViewArea() {54 top.document.getElementById("main").cols = "6,*";55 parent.document.getElementById("viewArea").cols = "0,6";56 var imageId = top.viewFrame.sizeControlFrame.document.getElementById("image");57 var imgSrc = "<a href=" + "javascript:showViewArea();" + "><img src='../" + "img/frame/showRight.gif' name='leftImage' width='7' height='50' border='0' id='leftImage' onMouseOver=" + " MM_swapImage('leftImage','','../" + "img/frame/showRightOver.gif',1)" + " onMouseOut=" + " MM_swapImgRestore()" + "></a>";58 imageId.innerHTML = imgSrc;59}60//æ¾ç¤ºæ´ä¸ªè§å¾åº61function showViewArea() {62 top.main.cols = "180,*";63 top.viewFrame.viewArea.cols = "170,6";64 var imageId = top.viewFrame.sizeControlFrame.document.getElementById("image");65 var imgSrc = "<a href=" + "javascript:hideViewArea();" + "><img src='../" + "img/frame/hideLeft.gif' name='leftImage' width='7' height='50' border='0' id='leftImage' onMouseOver=" + " MM_swapImage('leftImage','','../" + "img/frame/hideLeftOver.gif',1)" + " onMouseOut=" + " MM_swapImgRestore()" + "></a>";66 imageId.innerHTML = imgSrc;67}68//èå转åæ¶æ页é¢æ é¢æå°headFrameä¸å»ï¼ç¶åå¨æ¹å主页é¢çhrefå°å69function toURL(name, url) {70 //æ页é¢æ é¢æ交å°Head页é¢ä¸71 //top.headFrame.pageTitle.value = name;72 pageTitle.value = name;73 //æ¸
空导èªæ ï¼å¹¶éè74 //clearNavList();75 //跳转页é¢76 top.mainFrame.location.href = url;77}78//å¸å±æ¡æ¶é¡µé¢ä¸æåheadFrameä¸é¢çå¼79function getPageTitle() {80 var pageTitleStr = top.headFrame.pageTitle.value;81 var pageTitleId = document.getElementById("pageTitle");82 pageTitleId.innerHTML = pageTitleStr;83}84//导èªæ ä¸çèµæå
¥å£85function navToURL(url) {86 // top.headFrame.isShowNav.value = 'true';87 top.mainFrame.location.href = url;88}89/** -----------------导èªæ 使ç¨çå½æ°--------------------- **/90//checks browser and sets up layers accordingly91//var path = "default/images/navigate/";92var path = rootpath + "/frame/" + "default/images/navigate/";93//imgArray æ¯ä¸ä¸ªäºç»´æ°ç»ï¼[imgName,on_img_src,off_img_src]94var imgArray = [95 ["img1",path + "tab1_on.gif", path + "tab1_off.gif"] ,96 ["img2",path + "tab2_on.gif", path + "tab2_off.gif"] ]97//æ¾ç¤ºå¯¼èªæ ä¸ç第ä¸ä¸ªé¢æ¿ï¼å¹¶éèå
¶ä»é¢æ¿98function showOne() {99 initnavigate();100 updateTabs('img1');101 showLayer('one');102 hideLayer('two');103 showNavigateView();104}105//æ¾ç¤ºå¯¼èªæ ä¸ç第äºä¸ªé¢æ¿ï¼å¹¶éèå
¶ä»é¢æ¿106function showTwo() {107 initnavigate();108 updateTabs('img2');109 showLayer('two');110 hideLayer('one');111 showNavigateView();112}113function showLayer(layerName) {114 if (top.viewFrame.navigateFrame.document.layers) {115 eval(layerRef + layerName + '.style.display="block"');116 } else {117 eval('top.viewFrame.navigateFrame.document.getElementById(' + "'" + layerName + "'" + ').style.display = "block"');118 }119}120function hideLayer(layerName) {121 if (top.viewFrame.navigateFrame.document.layers) {122 eval(layerRef + layerName + '.style.display="none"');123 } else {124 eval('top.viewFrame.navigateFrame.document.getElementById(' + "'" + layerName + "'" + ').style.display = "none"');125 }126}127function initnavigate() {128 if (top.viewFrame.navigateFrame.document.layers) {129 layerRef = "top.viewFrame.navigateFrame.document.layers.";130 }131 if (top.viewFrame.navigateFrame.document.images) {132 }133}134function updateTabs(imgName) {135 with (top.viewFrame.navigateFrame) {136 if (document.images) {137 for (var i = 0; i < imgArray.length; i++) {138 if (imgArray[i][0] == imgName) {139 document.all(imgArray[i][0]).src = imgArray[i][1];140 } else {141 document.all(imgArray[i][0]).src = imgArray[i][2];142 }143 }144 }145 }146}147/**-------------------é误æ示使ç¨çå½æ°-----------------**/148//èç¦å°é误åä¸149function errorFocus(errId) {150 top.mainFrame.document.all(errId).focus();151}152//å¡«å
é误信æ¯å°é误æ示é¢æ¿ä¸153function fillError() {154 var tdiv = top.viewFrame.navigateFrame.document.getElementById('error_id');155 //为解å³æºæ管çï¼aafï¼ä¸çjsé误ï¼å¨2006å¹´3æ31æ¥è¢«è¿«å¨æ¤è¿è¡ä¿®æ¹156 //åæ¥ä»£ç 为ï¼tdiv.innerHTML = top.mainFrame.document.all("__errorInfo").innerHTML;157 //wangpu158 tdiv.innerHTML = document.all("__errorInfo").innerHTML;159}160//å¡«å
导èªå表å°å¯¼èªé¢æ¿ä¸161function fillNavList() {162 var tdiv = top.viewFrame.navigateFrame.document.getElementById('nav_id');163 tdiv.innerHTML = top.mainFrame.document.all("__nav_id").innerHTML;164}165//å¡«å
导èªå表ï¼å¹¶æ¾ç¤ºå¯¼èªå表166function fillNavAndShow() {167 //å¡«å
导èªæ 导èªå
容168 fillNavList();169 //æ¾ç¤ºå¯¼èªæ 170 showOne();171 //设置导èªæ ç¶æ为éèç¶æ172 top.headFrame.isShowNav.value = "true";173}174//æ¸
空导èªæ å表ï¼å¹¶éè175function clearNavList() {176 var tdiv = top.viewFrame.navigateFrame.document.getElementById('nav_id');177 tdiv.innerHTML = "";178 //设置导èªæ ç¶æ为éèç¶æ179 top.headFrame.isShowNav.value = "false";180 //éè导èªæ 181 hideNavigateView();182}183//ä»é误æ示é¢æ¿ä¸æ¸
空é误信æ¯,并æ¾ç¤ºå¯¼èªé¢æ¿184function clearError() {185 var tdiv = top.viewFrame.navigateFrame.document.getElementById('error_id');186 tdiv.innerHTML = "";187 if (top.headFrame.isShowNav.value == "true") {188 //æ¾ç¤ºå¯¼èªé¢æ¿189 showOne();190 } else {//éè导èªæ 191 hideNavigateView();192 }193}194function fillJsErrorAndShow(errs) {195 var tdiv = top.viewFrame.navigateFrame.document.getElementById('error_id');196 var strHtml = "<TABLE cellSpacing=0 cellPadding=0 width='100%' align=center border=0>";197 for (var i = 0; i < errs.length; i++) {198 strHtml += "<TR>";199 strHtml += "<TD><IMG src='" + rootpath + "/frame/default/images/navigate/error_light.gif'></TD>";200 strHtml += "<TD class='TD_guide_line_test'><A href=\"javascript:errorFocus('" + errs[i][0] + "');\">" + errs[i][1] + "</A></TD>";201 strHtml += "</TR>";202 }203 strHtml += "</TABLE>";204 tdiv.innerHTML = strHtml;205 showTwo();206 window.attachEvent("onunload", clearError);207}208//æ¾ç¤ºçå¾
页é¢209function _showWait() {210 var win = top.headFrame;211 if (win == null)return;212 if (win._wait != null)return;213 win._wait = win.showModelessDialog(rootpath + "/page/frame/Loading.jsp", window, "dialogTop:550px;dialogLeft:750px;dialogHeight: 100px; dialogWidth: 200px; center: yes; help: no; scroll: no; status: no;");214 ;215}216//éèçå¾
页é¢217function _hiddenWait() {218 var win = top.headFrame;219 if (win == null)return;220 if (win._wait != null) {221 if (!win._wait.closed)win._wait.close();222 win._wait = null;223 }224}225//å
æ¸
ï¼åæ·»äºä»¶ï¼é²æ¢æ·»å éå¤äºä»¶226//æ¸
äºä»¶227//window.detachEvent("onload",_hiddenWait);228//window.detachEvent("onunload",_showWait);229////æ·»å äºä»¶230//window.attachEvent("onload",_hiddenWait);...
frame1.js
Source:frame1.js
1/**2 Title:¿ò¼Ü¿ØÖÆËùÐèÒªµÄJS´úÂë3 author:ºî²©4 date:2005Äê07-07ÈÕ5 */6//var rootpath = "/TopIcms";7var webroot = document.location.href;8webroot = webroot.substring(webroot.indexOf('//') + 2, webroot.length);9webroot = webroot.substring(webroot.indexOf('/') + 1, webroot.length);10webroot = webroot.substring(0, webroot.indexOf('/'));11var rootpath = '/' + webroot;12/*ÒÔϼ¸¸ö·½·¨ÊÇÀûDreamweaver×Ô¶¯²úÉúµÄ´úÂ룬Ö÷ÒªÓÃÓÚ¿ØÖÆͼƬµÄ±ä»»Ð§¹û*/13function MM_preloadImages() { //v3.014 var d = document;15 if (d.images) {16 if (!d.MM_p) d.MM_p = new Array();17 var i,j = d.MM_p.length,a = MM_preloadImages.arguments;18 for (i = 0; i < a.length; i++)19 if (a[i].indexOf("#") != 0) {20 d.MM_p[j] = new Image;21 d.MM_p[j++].src = a[i];22 }23 }24}25function MM_swapImgRestore() { //v3.026 var i,x,a = document.MM_sr;27 for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;28}29function MM_findObj(n, d) { //v4.0130 var p,i,x;31 if (!d) d = document;32 if ((p = n.indexOf("?")) > 0 && parent.frames.length) {33 d = parent.frames[n.substring(p + 1)].document;34 n = n.substring(0, p);35 }36 if (!(x = d[n]) && d.all) x = d.all[n];37 for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];38 for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);39 if (!x && d.getElementById) x = d.getElementById(n);40 return x;41}42function MM_swapImage() { //v3.043 var i,j = 0,x,a = MM_swapImage.arguments;44 document.MM_sr = new Array;45 for (i = 0; i < (a.length - 2); i += 3)46 if ((x = MM_findObj(a[i])) != null) {47 document.MM_sr[j++] = x;48 if (!x.oSrc) x.oSrc = x.src;49 x.src = a[i + 2];50 }51}52//Òþ²ØÕû¸öÊÓͼÇø53function hideViewArea() {54 top.main.cols = "6,*";55 top.viewFrame.viewArea.cols = "0,6";56 var imageId = top.viewFrame.sizeControlFrame.document.getElementById("image");57 //var imgSrc = "<a href=" + "javascript:showViewArea();" + "><img src='default/images/showRight.gif' name='leftImage' width='7' height='50' border='0' id='leftImage' onMouseOver=" + " MM_swapImage('leftImage','','default/images/showRightOver.gif',1)" + " onMouseOut=" + " MM_swapImgRestore()" + "></a>";58 var imgSrc = "<a href=" + "javascript:showViewArea();" + "><img src='../" + "images/frame/showRight.gif' name='leftImage' width='7' height='50' border='0' id='leftImage' onMouseOver=" + " MM_swapImage('leftImage','','../" + "images/frame/showRightOver.gif',1)" + " onMouseOut=" + " MM_swapImgRestore()" + "></a>";59 imageId.innerHTML = imgSrc;60}61//ÏÔʾÕû¸öÊÓͼÇø62function showViewArea() {63 top.main.cols = "180,*";64 top.viewFrame.viewArea.cols = "170,6";65 var imageId = top.viewFrame.sizeControlFrame.document.getElementById("image");66 var imgSrc = "<a href=" + "javascript:hideViewArea();" + "><img src='../" + "images/frame/hideLeft.gif' name='leftImage' width='7' height='50' border='0' id='leftImage' onMouseOver=" + " MM_swapImage('leftImage','','../" + "images/frame/hideLeftOver.gif',1)" + " onMouseOut=" + " MM_swapImgRestore()" + "></a>";67 imageId.innerHTML = imgSrc;68}69//²Ëµ¥×ªÏòʱ°ÑÒ³Ãæ±êÌâÌáµ½headFrameÖÐÈ¥£¬È»ºóÔڸıäÖ÷Ò³ÃæµÄhrefµØÖ·70function toURL(name, url) {71 //°ÑÒ³Ãæ±êÌâÌá½»µ½HeadÒ³ÃæÖÐ72 //top.headFrame.pageTitle.value = name;73 //Çå¿Õµ¼º½À¸£¬²¢Òþ²Ø74 //clearNavList();75 //ÌøתҳÃæ76 parent.rightFrame.location.href = url;77}78//²¼¾Ö¿ò¼ÜÒ³ÃæÖÐÌáÈ¡headFrameÖÐÌâµÄÖµ79function getPageTitle() {80 var pageTitleStr = top.headFrame.pageTitle.value;81 var pageTitleId = document.getElementById("pageTitle");82 pageTitleId.innerHTML = pageTitleStr;83}84//µ¼º½À¸ÉϵÄ×ÊÁÏÈë¿Ú85function navToURL(url) {86 // top.headFrame.isShowNav.value = 'true';87 top.rightFrame.location.href = url;88}89/** -----------------µ¼º½À¸Ê¹Óõĺ¯Êý--------------------- **/90//checks browser and sets up layers accordingly91//var path = "default/images/navigate/";92var path = rootpath + "/frame/" + "default/images/navigate/";93//imgArray ÊÇÒ»¸ö¶þάÊý×飺[imgName,on_img_src,off_img_src]94var imgArray = [95 ["img1",path + "tab1_on.gif", path + "tab1_off.gif"] ,96 ["img2",path + "tab2_on.gif", path + "tab2_off.gif"] ]97//ÏÔʾµ¼º½À¸ÖеĵÚÒ»¸öÃæ°å£¬²¢Òþ²ØÆäËûÃæ°å98function showOne() {99 initnavigate();100 updateTabs('img1');101 showLayer('one');102 hideLayer('two');103 showNavigateView();104}105//ÏÔʾµ¼º½À¸Öеĵڶþ¸öÃæ°å£¬²¢Òþ²ØÆäËûÃæ°å106function showTwo() {107 initnavigate();108 updateTabs('img2');109 showLayer('two');110 hideLayer('one');111 showNavigateView();112}113function showLayer(layerName) {114 if (top.viewFrame.navigateFrame.document.layers) {115 eval(layerRef + layerName + '.style.display="block"');116 } else {117 eval('top.viewFrame.navigateFrame.document.getElementById(' + "'" + layerName + "'" + ').style.display = "block"');118 }119}120function hideLayer(layerName) {121 if (top.viewFrame.navigateFrame.document.layers) {122 eval(layerRef + layerName + '.style.display="none"');123 } else {124 eval('top.viewFrame.navigateFrame.document.getElementById(' + "'" + layerName + "'" + ').style.display = "none"');125 }126}127function initnavigate() {128 if (top.viewFrame.navigateFrame.document.layers) {129 layerRef = "top.viewFrame.navigateFrame.document.layers.";130 }131 if (top.viewFrame.navigateFrame.document.images) {132 }133}134function updateTabs(imgName) {135 with (top.viewFrame.navigateFrame) {136 if (document.images) {137 for (var i = 0; i < imgArray.length; i++) {138 if (imgArray[i][0] == imgName) {139 document.all(imgArray[i][0]).src = imgArray[i][1];140 } else {141 document.all(imgArray[i][0]).src = imgArray[i][2];142 }143 }144 }145 }146}147/**-------------------´íÎóÌáʾʹÓõĺ¯Êý-----------------**/148//¾Û½¹µ½´íÎóÓòÖÐ149function errorFocus(errId) {150 top.mainFrame.document.all(errId).focus();151}152//Ìî³ä´íÎóÐÅÏ¢µ½´íÎóÌáʾÃæ°åÖÐ153function fillError() {154 var tdiv = top.viewFrame.navigateFrame.document.getElementById('error_id');155 //Ϊ½â¾ö»ú¹¹¹ÜÀí£¨aaf£©ÖеÄjs´íÎó£¬ÔÚ2006Äê3ÔÂ31ÈÕ±»ÆÈÔڴ˽øÐÐÐÞ¸Ä156 //ÔÀ´´úÂëΪ£ºtdiv.innerHTML = top.mainFrame.document.all("__errorInfo").innerHTML;157 //wangpu158 tdiv.innerHTML = document.all("__errorInfo").innerHTML;159}160//Ìî³äµ¼º½ÁÐ±íµ½µ¼º½Ãæ°åÖÐ161function fillNavList() {162 var tdiv = top.viewFrame.navigateFrame.document.getElementById('nav_id');163 tdiv.innerHTML = top.mainFrame.document.all("__nav_id").innerHTML;164}165//Ìî³äµ¼º½ÁÐ±í£¬²¢ÏÔʾµ¼º½Áбí166function fillNavAndShow() {167 //Ìî³äµ¼º½À¸µ¼º½ÄÚÈÝ168 fillNavList();169 //ÏÔʾµ¼º½À¸170 showOne();171 //ÉèÖõ¼º½À¸×´Ì¬ÎªÒþ²Ø״̬172 top.headFrame.isShowNav.value = "true";173}174//Çå¿Õµ¼º½À¸ÁÐ±í£¬²¢Òþ²Ø175function clearNavList() {176 var tdiv = top.viewFrame.navigateFrame.document.getElementById('nav_id');177 tdiv.innerHTML = "";178 //ÉèÖõ¼º½À¸×´Ì¬ÎªÒþ²Ø״̬179 top.headFrame.isShowNav.value = "false";180 //Òþ²Øµ¼º½À¸181 hideNavigateView();182}183//´Ó´íÎóÌáʾÃæ°åÖÐÇå¿Õ´íÎóÐÅÏ¢,²¢ÏÔʾµ¼º½Ãæ°å184function clearError() {185 var tdiv = top.viewFrame.navigateFrame.document.getElementById('error_id');186 tdiv.innerHTML = "";187 if (top.headFrame.isShowNav.value == "true") {188 //ÏÔʾµ¼º½Ãæ°å189 showOne();190 } else {//Òþ²Øµ¼º½À¸191 hideNavigateView();192 }193}194function fillJsErrorAndShow(errs) {195 var tdiv = top.viewFrame.navigateFrame.document.getElementById('error_id');196 var strHtml = "<TABLE cellSpacing=0 cellPadding=0 width='100%' align=center border=0>";197 for (var i = 0; i < errs.length; i++) {198 strHtml += "<TR>";199 strHtml += "<TD><IMG src='" + rootpath + "/frame/default/images/navigate/error_light.gif'></TD>";200 strHtml += "<TD class='TD_guide_line_test'><A href=\"javascript:errorFocus('" + errs[i][0] + "');\">" + errs[i][1] + "</A></TD>";201 strHtml += "</TR>";202 }203 strHtml += "</TABLE>";204 tdiv.innerHTML = strHtml;205 showTwo();206 window.attachEvent("onunload", clearError);207}208//ÏÔʾµÈ´ýÒ³Ãæ209function _showWait() {210 var win = top.headFrame;211 if (win == null)return;212 if (win._wait != null)return;213 win._wait = win.showModelessDialog(rootpath + "/page/frame/Loading.jsp", window, "dialogTop:550px;dialogLeft:750px;dialogHeight: 100px; dialogWidth: 200px; center: yes; help: no; scroll: no; status: no;");214 ;215}216//Òþ²ØµÈ´ýÒ³Ãæ217function _hiddenWait() {218 var win = top.headFrame;219 if (win == null)return;220 if (win._wait != null) {221 if (!win._wait.closed)win._wait.close();222 win._wait = null;223 }224}225//ÏÈÇ壬ºóÌíʼþ£¬·ÀÖ¹Ìí¼ÓÖظ´Ê¼þ226//Çåʼþ227//window.detachEvent("onload",_hiddenWait);228//window.detachEvent("onunload",_showWait);229////Ìí¼Óʼþ230//window.attachEvent("onload",_hiddenWait);...
BindingsTestRunner.js
Source:BindingsTestRunner.js
...81 if (evalSourceURL) {82 evalSource += '//# sourceURL=' + evalSourceURL;83 }84 return TestRunner.evaluateInPageAsync(evalSource);85 function navigateFrame(frameId, url) {86 const frame = document.getElementById(frameId);87 frame.src = url;88 return new Promise(x => frame.onload = x);89 }90};91BindingsTestRunner.attachShadowDOM = function(id, templateSelector, evalSourceURL) {92 let evalSource = `(${createShadowDOM.toString()})('${id}', '${templateSelector}')`;93 if (evalSourceURL) {94 evalSource += '//# sourceURL=' + evalSourceURL;95 }96 return TestRunner.evaluateInPageAnonymously(evalSource);97 function createShadowDOM(id, templateSelector) {98 const shadowHost = document.createElement('div');99 shadowHost.setAttribute('id', id);...
docs.js
Source:docs.js
...19function navigateToUrl(url)20{21 //we should not trigger a search, since the user got here via the tree22 shouldSearch = false;23 navigateFrame(url);24}25//Navigate the frame directly, without touching other state (triggers iframeLoaded)26function navigateFrame(url)27{28 if(url.charAt(0) == "#")29 url = url.substring(1);30 var target = "html/" + url + ".htm";31 document.getElementById("content_frame").src = target;32}33//Respond to a change in the hash by navigating if needed, only user can CHANGE the topic this way34function locationHashChanged() {35 var topic = window.location.hash.substring(1);36 var current = getCurrentTopic();37 if(current != topic)38 {39 //new topic means triggered by user40 navigateFrame(topic);41 $("#tree").jstree("search", window.location.hash);42 }43}44//scroll the tree to a target node (after a search for that node triggered by iframe navigate)45function scrollTree() {46 //check if there's a scroll point set47 var scrollto = $("#sidebar").attr("scrollto");48 if(scrollto == null || scrollto.length == 0)49 return;50 51 //find the ndoe if it exists52 var node = document.getElementById("node_" + scrollto);53 if(node == null)54 return;55 //select and open the node, since its children are now relevant56 $("#tree").jstree("open_node", node);57 $("#tree").jstree("select_node", node, true);58 59 //okay we have a target, scroll to it60 var offset = node.offsetTop;61 if(offset == 0)62 {63 //node has not been positioned, try and use its parents instead64 path = $("#tree").jstree("get_path", node, true);65 path.pop();66 while(path.length > 0 && offset == 0)67 {68 var parentId = path.pop();69 offset = document.getElementById(parentId).offsetTop;70 }71 }72 document.getElementById("sidebar").scrollTop = offset;73 //clear the scroll point ttribute74 $("#sidebar").attr("scrollto", "");75}76//Respond to the iframe being loaded -- if new page, change location hash and search tree77function iframeLoaded() {78 var loc = getCurrentLocation(); 79 //ignore the initial blank load80 if(loc.host != document.location.host)81 return;82 //strip off the html/ and path name from the location, then add the hash83 var target = "#" + getCurrentTopic();84 //if this is true, a link inside the iframe was clicked and the hash is updated to match85 if(target != window.location.hash)86 {87 window.location.hash = target;88 if(shouldSearch)89 $("#tree").jstree("search", target);90 shouldSearch = true;91 }92}93function iframeFirstLoad()94{95 //nothing happens on the first real page load, subsequent loads go through the update logic above96 var content_frame = document.getElementById("content_frame");97 if(content_frame.src != null && content_frame.src.length > 0)98 content_frame.onload = iframeLoaded;99}100function configureTreeView()101{102 $("#tree").jstree({103 "core" : { "animation": 00 },104 "plugins" : [ "themes", "json_data", "ui", "search" ],105 "themes" : { "theme" : "classic", "icons" : false },106 "ui" : {107 "select_limit": 1,108 "selected_parent_close" : "select_parent",109 "initially_select": [ "node_0" ]110 },111 "json_data" : {112 "ajax" : {113 "url" : "topic.php",114 "data" : function (n) {115 var queryString = {};116 if(n.attr)117 queryString.id = n.attr("nodeId");118 return queryString;119 },120 "success" : function (data) {121 //patch the data up to match what jsTree expects122 for(i = 0; i < data.length; ++i)123 {124 data[i].data = data[i].Title;125 data[i].attr = {126 "id": "node_" + data[i].Id, 127 "nodeId" : data[i].Id,128 "topic": data[i].Url129 };130 if(data[i].TopicId != null)131 data[i].state = "closed";132 }133 //if nothing is in the iframe, use this to fill it134 var loc = getCurrentLocation(); 135 if(loc.host != document.location.host && window.location.hash.length < 2)136 navigateFrame(data[0].attr.topic);137 138 return data;139 }140 }141 },142 "search" : {143 "ajax" : {144 "url": "search.php",145 "data": function(n) {146 var queryString = { "url": n.substring(1) };147 return queryString;148 },149 "success": function(data) {150 if(data.length == 0)...
utils.js
Source:utils.js
...83 * @param {string} url84 */85 navigateFrame: async function (page, frameId, url) {86 await page.evaluate(navigateFrame, frameId, url);87 function navigateFrame(frameId, url) {88 const frame = document.getElementById(frameId);89 frame.src = url;90 return new Promise((x) => (frame.onload = x));91 }92 },93 /**94 * @param {!Frame} frame95 * @param {string=} indentation96 * @returns {Array<string>}97 */98 dumpFrames: function (frame, indentation) {99 indentation = indentation || '';100 let description = frame.url().replace(/:\d{4}\//, ':<PORT>/');101 if (frame.name()) description += ' (' + frame.name() + ')';...
frame-utils.js
Source:frame-utils.js
...46 * @param {string} url47 */48 navigateFrame: async function(page, frameId, url) {49 await page.evaluate(navigateFrame, frameId, url);50 function navigateFrame(frameId, url) {51 const frame = document.getElementById(frameId);52 frame.src = url;53 return new Promise(x => frame.onload = x);54 }55 },56 /**57 * @param {!Frame} frame58 * @param {string=} indentation59 * @return {string}60 */61 dumpFrames: function(frame, indentation) {62 indentation = indentation || '';63 let result = indentation + frame.url();64 for (const child of frame.childFrames())...
navigator-frame-navigate.js
Source:navigator-frame-navigate.js
...12 TestRunner.markStep('attachFrame');13 await BindingsTestRunner.attachFrame('frame', './resources/magic-frame.html');14 SourcesTestRunner.dumpNavigatorView(sourcesNavigator, false);15 TestRunner.markStep('navigateFrame');16 await BindingsTestRunner.navigateFrame('frame', './resource/empty-frame.html');17 SourcesTestRunner.dumpNavigatorView(sourcesNavigator, false);18 TestRunner.completeTest();...
bindings-frame-navigate.js
Source:bindings-frame-navigate.js
...9 TestRunner.markStep('attachFrame');10 await BindingsTestRunner.attachFrame('frame', './resources/magic-frame.html', '_test_attachFrame.js');11 snapshot = BindingsTestRunner.dumpWorkspace(snapshot);12 TestRunner.markStep('navigateFrame');13 await BindingsTestRunner.navigateFrame('frame', './resources/empty-frame.html', '_test_navigateFrame');14 snapshot = BindingsTestRunner.dumpWorkspace(snapshot);15 TestRunner.completeTest();...
Using AI Code Generation
1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch({headless: false});4 const page = await browser.newPage();5 await page.waitFor(2000);6 await page.waitFor(2000);7 await page.waitFor(2000);8 await page.goBack();9 await page.waitFor(2000);10 await page.goBack();11 await page.waitFor(2000);12 await page.goForward();13 await page.waitFor(2000);14 await page.goForward();15 await page.waitFor(2000);16 await browser.close();17})();18Puppeteer | click() method19Puppeteer | type() method20Puppeteer | waitFor() method21Puppeteer | waitForSelector() method22Puppeteer | waitForXPath() method23Puppeteer | waitForFunction() method24Puppeteer | waitForNavigation() method25Puppeteer | waitForRequest() method26Puppeteer | waitForResponse() method27Puppeteer | waitForTimeout() method28Puppeteer | waitForFileChooser() method29Puppeteer | waitForSelector() method30Puppeteer | waitForXPath() method31Puppeteer | waitForFunction() method32Puppeteer | waitForNavigation() method33Puppeteer | waitForRequest() method34Puppeteer | waitForResponse() method35Puppeteer | waitForTimeout() method36Puppeteer | waitForFileChooser() method
Using AI Code Generation
1const puppeteer = require('puppeteer');2const devices = require('puppeteer/DeviceDescriptors');3(async () => {4 const browser = await puppeteer.launch();5 const page = await browser.newPage();6 await page.emulate(devices['iPhone 6']);7 await page.screenshot({path: 'google.png'});8 await browser.close();9})();10const puppeteer = require('puppeteer');11(async () => {12 const browser = await puppeteer.launch();13 await browser.close();14})();15const puppeteer = require('puppeteer');16(async () => {17 const browser = await puppeteer.launch({18 });19 await browser.close();20})();
Using AI Code Generation
1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch();4 const page = await browser.newPage();5 await page.evaluate(() => {6 });7 await browser.close();8})();9const puppeteer = require('puppeteer');10(async () => {11 const browser = await puppeteer.launch();12 const page = await browser.newPage();13 await browser.close();14})();15const puppeteer = require('puppeteer');16(async () => {17 const browser = await puppeteer.launch();18 const page = await browser.newPage();19 await browser.close();20})();21const puppeteer = require('puppeteer');22(async () => {23 const browser = await puppeteer.launch();24 const page = await browser.newPage();25 await Promise.all([26 ]);27 await browser.close();28})();29const puppeteer = require('puppeteer');30(async () => {31 const browser = await puppeteer.launch();32 const page = await browser.newPage();33 await page.waitForSelector('form[action="/search"]');34 await browser.close();35})();
Using AI Code Generation
1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch();4 const page = await browser.newPage();5 await page.waitForSelector('input[name=q]');6 await page.type('input[name=q]', 'puppeteer');7 await page.click('input[name=btnK]');8 await page.waitForNavigation();9 console.log(page.url());10 await browser.close();11})();12page.goto(url, [options])13page.waitForNavigation([options])14page.waitForSelector(selector, [options])
Using AI Code Generation
1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch({headless: false});4 const page = await browser.newPage();5 await page.waitForSelector('#search');6 await page.type('#search', 'puppeteer');7 await page.click('button');8 await page.waitForSelector('#results');9 await page.evaluate(() => {10 const results = document.querySelector('#results');11 console.log(results.innerHTML);12 });13 await browser.close();14})();15const puppeteer = require('puppeteer');16(async () => {17 const browser = await puppeteer.launch({headless: false});18 const page = await browser.newPage();19 await page.waitForSelector('#search');20 await page.type('#search', 'puppeteer');21 await page.click('button');22 await page.waitForSelector('#results');23 await page.evaluate(() => {24 const results = document.querySelector('#results');25 console.log(results.innerHTML);26 });27 await browser.close();28})();29const puppeteer = require('puppeteer');30(async () => {31 const browser = await puppeteer.launch({headless: false});32 const page = await browser.newPage();33 await page.waitForSelector('#search');34 await page.type('#search', 'puppeteer');35 await page.click('button');36 await page.waitForNavigation();37 await page.evaluate(() => {38 const results = document.querySelector('#results');39 console.log(results.innerHTML);40 });41 await browser.close();42})();43const puppeteer = require('puppeteer');44(async () => {45 const browser = await puppeteer.launch({headless: false});46 const page = await browser.newPage();47 await page.waitForSelector('#search');48 await page.type('#search', 'puppeteer');49 await page.click('button');50 await page.waitForSelector('#results');51 await page.evaluate(() => {52 const results = document.querySelector('#results');53 console.log(results.innerHTML);54 });
Using AI Code Generation
1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch();4 const page = await browser.newPage();5 await page.goBack();6 await page.goBack();7 await page.goForward();8 await page.goBack();9 await page.goBack();10 await page.goForward();11 await page.goForward();12 await page.goBack();
Using AI Code Generation
1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch();4 const page = await browser.newPage();5 await page.waitFor(2000);6 await page.screenshot({path: 'google.png'});7 await browser.close();8})();
Using AI Code Generation
1(async () => {2 const browser = await puppeteer.launch();3 const page = await browser.newPage();4 await page.waitForSelector('h1');5 await page.evaluate(() => {6 document.querySelector('h1').innerHTML = 'Hello World!';7 });8 await page.screenshot({path: 'example.png'});9 await browser.close();10})();11(async () => {12 const browser = await puppeteer.launch({headless: false});13 const page = await browser.newPage();14 await page.waitForSelector('h1');15 await page.evaluate(() => {16 document.querySelector('h1').innerHTML = 'Hello World!';17 });18 await page.screenshot({path: 'example.png'});19 await browser.close();20})();21(async () => {22 const browser = await puppeteer.launch({headless: false});23 const page = await browser.newPage();24 await page.waitForSelector('h1');25 await page.evaluate(() => {26 document.querySelector('h1').innerHTML = 'Hello World!';27 });28 await page.screenshot({path: 'example.png'});29 await browser.close();30})();31(async () => {32 const browser = await puppeteer.launch({headless: false});33 const page = await browser.newPage();34 await page.waitForSelector('h1');35 await page.evaluate(() => {36 document.querySelector('h1').innerHTML = 'Hello World!';37 });38 await page.screenshot({path: 'example.png'});39 await browser.close();40})();41(async () => {42 const browser = await puppeteer.launch({headless: false});43 const page = await browser.newPage();44 await page.waitForSelector('h1');45 await page.evaluate(() => {46 document.querySelector('h1').innerHTML = 'Hello World!';47 });48 await page.screenshot({path: 'example.png'});49 await browser.close();50})();
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!