How to use innerText method in Playwright Internal

Best JavaScript code snippet using playwright-internal

loader.js

Source:loader.js Github

copy

Full Screen

1// Global Variables2var ReadyToLoadData;3var CurrentGame;4var JSONData;5var FirstLoad;6// Called on initialisation7function OnBodyLoad() {8 FirstLoad = true;9 // Switch loading depending on local or web mode10 document.getElementById('input').style.display = config.Local ? "block" : "none" ;11 if (! config.Local) {12 LoadContent();13 }14 15 document.getElementById('debug').style.display = config.Debug ? "block" : "none" ; 16 CurrentGame = 0;17 18 // Set animation speed19 document.getElementById("Table1").setAttribute("style", "--looptime: " + config.LoopTime) ;20 document.getElementById("Table2").setAttribute("style", "--looptime: " + config.LoopTime) ;21 22 // set animation event handlers23 var element = document.getElementById("Table1");24 element.addEventListener("animationiteration", AniLoop, false);25 element.addEventListener("webkitAnimationIteration", AniLoop, false);26}27// Called each time an entry has finished scrolling28function AniLoop(event) {29 // Switch Over Animation Direction Horizontal <--> vertical30 document.getElementById("Table1").classList.toggle("tickerTable1h") ;31 document.getElementById("Table1").classList.toggle("tickerTable1v") ;32 document.getElementById("Table2").classList.toggle("tickerTable2h") ;33 document.getElementById("Table2").classList.toggle("tickerTable2v") ; 34 35 // So, if we're in web mode or have entered filename, refresh our data36 if (ReadyToLoadData) {37 if (document.getElementById("Table1").classList.contains("tickerTable1v") ) {38 // We've just finished a horizontal scroll, about to start a vertical one39 // Refresh data and move on to the next event - load new event into bottom row so it can scroll into view40 LoadContent();41 document.getElementById("debug").innerText = "Showing " + CurrentGame ;42 CurrentGame += 2;43 } else {44 // We've just finished a vertical scroll, about to start a horizontal one45 // Copy data in bottom row to top one - the horizontal scroll will flip back to show the 46 // top row.47 CopyEvent34to12();48 }49 } else {50 // heartbeat51 document.getElementById("debug").innerText = document.getElementById("debug").innerText == "DEBUG" ? "debug" : "DEBUG" ;52 }53 }54// Called from two places: 55// 1. the first time we're ready to load - varies depending on mode56// 2. When we reach the end of the scroll, if we've been called before (ReadyToLoadData = true)57function LoadContent() {58 if (config.Local) {59 loadFile();60 } else {61 NetLoadFile();62 }63 ReadyToLoadData = true;64 }65 66// Loads a LOCAL file (used in debug mode)67function loadFile() {68 var input, file, fr;69 if (typeof window.FileReader !== 'function') {70 alert("The file API isn't supported on this browser yet.");71 return;72 }73 input = document.getElementById('fileinput');74 if (!input) {75 alert("Um, couldn't find the fileinput element.");76 }77 else if (!input.files) {78 alert("This browser doesn't seem to support the `files` property of file inputs.");79 }80 else if (!input.files[0]) {81 alert("Please select a file before clicking 'Load'");82 }83 else {84 ShowLoading(true);85 file = input.files[0];86 fr = new FileReader();87 fr.onload = function(e) {88 var lines = e.target.result;89 JSONData = JSON.parse(lines); 90 ShowLoading(false);91 }92 fr.readAsText(file);93 if (JSONData != null) {94 ExtractJsonData(0);95 ExtractJsonData(1);96 }97 }98 }99 100// Loads the data file - production (network) version101function NetLoadFile() {102 ShowLoading(true);103 var JSONDoc = config.RemoteServer + config.RemotePath;104 xmlhttp = new XMLHttpRequest();105 xmlhttp.open("get", JSONDoc, true ) ;106 107 // Approach is as follows:108 // If we've never loaded the doc at all, then extract the data as soon as we've done the load.109 // If we have previously loaded the doc, then this is a refresh, so no need to wait for doc to load, 110 // just update from the most recent one received. This synchronises the update with scrolling and111 // prevents updates mid-scroll.112 113 xmlhttp.onreadystatechange = function() {114 if (xmlhttp.readyState == 4) { // State 4 = DONE - operation complete115 JSONData = JSON.parse(xmlhttp.response); 116 ShowLoading(false);117 if (FirstLoad) {118 FirstLoad = false;119 ExtractJsonData(0);120 ExtractJsonData(1);121 }122 }123 };124 xmlhttp.send() ;125 if (JSONData != null) {126 ExtractJsonData(0);127 ExtractJsonData(1);128 }129 }130 131// Parse the JSON data file, find the Event to display132// Parameter is which line (Section) to display to133function ExtractJsonData(Sec) {134 var MarketsWithGames = 0;135 // Go through finding events with some markets136 for (i = 0; i < JSONData.events.length; i++) {137 if ( config.Debug ) {138 console.log("E" + i + ": " + JSONData.events[i].participantnameaway + " @ " + JSONData.events[i].participantnamehome);139 }140 if ( JSONData.events[i].markets != null) {141 142 // see if this is the "n"th market with games, where "n" is the current one to display143 if ( MarketsWithGames == (CurrentGame + Sec)) {144 if (Sec == 1) {145 ExtractEvent(0, JSONData.events[i]);146 } else {147 ExtractEvent(1, JSONData.events[i]);148 }149 150 // Now found one, no need to continue151 return;152 } else {153 // we have games, but this is not yet the one we need154 MarketsWithGames += 1;155 }156 }157 }158 159 // If we got here, we have insuffient events to reach the counter. 160 // If we have ANY events with markets, reset counter and have another go161 if (MarketsWithGames > 0) {162 CurrentGame = 0;163 ExtractJsonData(Sec);164 }165 166}167// Extract a single event's data into display grid168// Line indicates which line of the grid to extract to: 0/1169// Event is a node in the parsed JSON indicating the current event to extract from 170function ExtractEvent(Line, Event) {171 172 // Prefixes for element ID's to locate which output grid cell to put data into 173 var IDR1 = ((Line == 0) ? "L3" : "L7");174 var IDR2 = ((Line == 0) ? "L4" : "L8");175 176 // Set the team names177 document.getElementById(IDR1 + 'T').innerText = Event.participantnameaway;178 document.getElementById(IDR2 + 'T').innerText = Event.participantnamehome;179 document.getElementById(IDR1 + 'T2').innerText = Event.participantnameaway;180 document.getElementById(IDR2 + 'T2').innerText = Event.participantnamehome;181 182 // Now find the Points, Moneyline and totals markets183 for (j = 0; j < Event.markets.length; j++) {184 var Market = Event.markets[j]185 if ( config.Debug ) {186 console.log("M" + j + ": " + Market.name);187 }188 if ( Market.gameperiod == "1+") {189 if ( Market.big3markettype == "ML") {190 // Money line191 document.getElementById(IDR1 + 'M').innerText = Market.selections[0].priceus;192 document.getElementById(IDR2 + 'M').innerText = Market.selections[1].priceus;193 document.getElementById(IDR1 + 'M2').innerText = Market.selections[0].priceus;194 document.getElementById(IDR2 + 'M2').innerText = Market.selections[1].priceus;195 } else if ( Market.big3markettype == "PS") {196 // Points spread197 CMH = Market.selections[0].currentmatchhandicap;198 if ( CMH > 0 ) {199 document.getElementById(IDR1 + 'P').innerText = "+" + Market.selections[0].currentmatchhandicap;200 document.getElementById(IDR2 + 'P').innerText = "-" + Market.selections[1].currentmatchhandicap;201 document.getElementById(IDR1 + 'P2').innerText = "+" + Market.selections[0].currentmatchhandicap;202 document.getElementById(IDR2 + 'P2').innerText = "-" + Market.selections[1].currentmatchhandicap;203 } else {204 document.getElementById(IDR1 + 'P').innerText = "" + Market.selections[0].currentmatchhandicap;205 document.getElementById(IDR2 + 'P').innerText = "+" + -Market.selections[1].currentmatchhandicap;206 document.getElementById(IDR1 + 'P2').innerText = "" + Market.selections[0].currentmatchhandicap;207 document.getElementById(IDR2 + 'P2').innerText = "+" + -Market.selections[1].currentmatchhandicap;208 }209 } else if ( Market.big3markettype == "TP") {210 // Total Points211 document.getElementById(IDR1 + 'OU').innerText = "O/U " + Market.selections[0].currentmatchhandicap;212 document.getElementById(IDR1 + 'OU2').innerText = "O/U " + Market.selections[0].currentmatchhandicap;213 }214 }215 }216}217function CopyEvent34to12() {218 // There might be a more elegant way of doing this, but is it worth it?219 220 // name221 document.getElementById('L1T').innerText = document.getElementById('L3T').innerText ;222 document.getElementById('L2T').innerText = document.getElementById('L4T').innerText ; 223 document.getElementById('L1T2').innerText = document.getElementById('L3T2').innerText ;224 document.getElementById('L2T2').innerText = document.getElementById('L4T2').innerText ; 225 document.getElementById('L5T').innerText = document.getElementById('L7T').innerText ;226 document.getElementById('L6T').innerText = document.getElementById('L8T').innerText ; 227 document.getElementById('L5T2').innerText = document.getElementById('L7T2').innerText ;228 document.getElementById('L6T2').innerText = document.getElementById('L8T2').innerText ; 229 // Money line230 document.getElementById('L1M').innerText = document.getElementById('L3M').innerText ; 231 document.getElementById('L2M').innerText = document.getElementById('L4M').innerText ; 232 document.getElementById('L1M2').innerText = document.getElementById('L3M2').innerText ; 233 document.getElementById('L2M2').innerText = document.getElementById('L4M2').innerText ; 234 document.getElementById('L5M').innerText = document.getElementById('L7M').innerText ; 235 document.getElementById('L6M').innerText = document.getElementById('L8M').innerText ; 236 document.getElementById('L5M2').innerText = document.getElementById('L7M2').innerText ; 237 document.getElementById('L6M2').innerText = document.getElementById('L8M2').innerText ; 238 // Points spread239 document.getElementById('L1P').innerText = document.getElementById('L3P').innerText ; 240 document.getElementById('L2P').innerText = document.getElementById('L4P').innerText ; 241 document.getElementById('L1P2').innerText = document.getElementById('L3P2').innerText ; 242 document.getElementById('L2P2').innerText = document.getElementById('L4P2').innerText ; 243 document.getElementById('L5P').innerText = document.getElementById('L7P').innerText ; 244 document.getElementById('L6P').innerText = document.getElementById('L8P').innerText ; 245 document.getElementById('L5P2').innerText = document.getElementById('L7P2').innerText ; 246 document.getElementById('L6P2').innerText = document.getElementById('L8P2').innerText ; 247 // Total Points248 document.getElementById('L1OU').innerText = document.getElementById('L3OU').innerText ; 249 document.getElementById('L1OU2').innerText = document.getElementById('L3OU2').innerText ; 250 document.getElementById('L5OU').innerText = document.getElementById('L7OU').innerText ; 251 document.getElementById('L5OU2').innerText = document.getElementById('L7OU2').innerText ; 252}253// Display little symbol to show we're working 254function ShowLoading(Show) {255 document.getElementById('loading').style.display = Show ? "block" : "none" ;256 }...

Full Screen

Full Screen

skrypcik.js

Source:skrypcik.js Github

copy

Full Screen

1// const buttons = Array.from(document.querySelectorAll(".button"));2const buttons = document.querySelectorAll(".button");3const display = document.querySelector(".display");4const equals = document.querySelector(".equals");5const operators = document.querySelectorAll(".operator");67let firstOperand = null;8let secondOperand = null;9let sign = "";10let result = null;11let dotCounter = 0;1213buttons.forEach(button => button.addEventListener('click', (e) => {1415 let stringWithPlus = display.innerText.split("+");16 if (stringWithPlus.length >= 2 ) {17 equals.classList.add("ready");18 operators.forEach(operator => operator.classList.add("blocked"));19 }20 let stringWithMinus = display.innerText.split("-");21 if (stringWithMinus.length >= 2 ) {22 equals.classList.add("ready");23 operators.forEach(operator => operator.classList.add("blocked"));24 }25 let stringWithSlash = display.innerText.split("/");26 if (stringWithSlash.length >= 2 ) {27 equals.classList.add("ready");28 operators.forEach(operator => operator.classList.add("blocked"));29 }30 let stringWithStar = display.innerText.split("*");31 if (stringWithStar.length >= 2 ) {32 equals.classList.add("ready");33 operators.forEach(operator => operator.classList.add("blocked"));34 }35 // if (stringToCountArrayS[1] != "") {36 // equals.classList.add("ready");37 // }3839 switch(e.target.innerText) {40 case 'AC':4142 equals.classList.remove("ready");43 operators.forEach(operator => operator.classList.remove("blocked"));4445 clearDisplay();46 firstOperand = null;47 secondOperand = null;48 sign = "";49 break;50 case '/':51 dotCounter = 0;52 if (display.innerText.length == 0) return;53 54 // if (display.innerText.split("")[display.innerText.split("").length-1] == "+") return;55 // if (display.innerText.split("")[display.innerText.split("").length-1] == "-") return;56 // if (display.innerText.split("")[display.innerText.split("").length-1] == "/") return;57 // if (display.innerText.split("")[display.innerText.split("").length-1] == "*") return;58 if (display.innerText.includes("+")) return;59 if (display.innerText.includes("-")) return;60 if (display.innerText.includes("/")) return;61 if (display.innerText.includes("*")) return;6263 sign = "divide";64 // clearDisplay();65 display.innerText += e.target.innerText;66 break;67 case '*':68 dotCounter = 0;69 if (display.innerText.length == 0) return;70 71 // if (display.innerText.split("")[display.innerText.split("").length-1] == "+") return;72 // if (display.innerText.split("")[display.innerText.split("").length-1] == "-") return;73 // if (display.innerText.split("")[display.innerText.split("").length-1] == "/") return;74 // if (display.innerText.split("")[display.innerText.split("").length-1] == "*") return;75 if (display.innerText.includes("+")) return;76 if (display.innerText.includes("-")) return;77 if (display.innerText.includes("/")) return;78 if (display.innerText.includes("*")) return;7980 sign = "multiply";81 // clearDisplay();82 display.innerText += e.target.innerText;83 break;84 case '-':85 dotCounter = 0;86 if (display.innerText.length == 0) return;87 88 // if (display.innerText.split("")[display.innerText.split("").length-1] == "+") return;89 // if (display.innerText.split("")[display.innerText.split("").length-1] == "-") return;90 // if (display.innerText.split("")[display.innerText.split("").length-1] == "/") return;91 // if (display.innerText.split("")[display.innerText.split("").length-1] == "*") return;92 if (display.innerText.includes("+")) return;93 if (display.innerText.includes("-")) return;94 if (display.innerText.includes("/")) return;95 if (display.innerText.includes("*")) return;9697 sign = "substract";98 // clearDisplay();99 display.innerText += e.target.innerText;100 break;101 case '+':102 dotCounter = 0;103 if (display.innerText.length == 0) return;104 105 // if (display.innerText.split("")[display.innerText.split("").length-1] == "+") return;106 // if (display.innerText.split("")[display.innerText.split("").length-1] == "-") return;107 // if (display.innerText.split("")[display.innerText.split("").length-1] == "/") return;108 // if (display.innerText.split("")[display.innerText.split("").length-1] == "*") return;109110 sign = "add";111 if (display.innerText.includes("+")) return;112 if (display.innerText.includes("-")) return;113 if (display.innerText.includes("/")) return;114 if (display.innerText.includes("*")) return;115116 // let stringToCountArray = display.innerText.split("+");117 // if (stringToCountArray[1] != "") {118 // equals.classList.add("ready");119 // }120121 // clearDisplay();122 display.innerText += e.target.innerText;123 break;124125 case "=":126 // if (!display.innerText.includes("+")) {127 // if (display.innerText.includes(".") ) {128 // return;129 // }130 // }131 // if (!display.innerText.includes("-")) {132 // if (display.innerText.includes(".") ) {133 // return;134 // }135 // }136 // if (!display.innerText.includes("*")) {137 // if (display.innerText.includes(".") ) {138 // return;139 // }140 // }141 // if (!display.innerText.includes("/")) {142 // if (display.innerText.includes(".") ) {143 // return;144 // }145 // }146147 dotCounter = 0;148149 if (display.innerText.includes("+")) {150 let stringToCountArray = display.innerText.split("+");151 firstOperand = stringToCountArray[0];152 secondOperand = stringToCountArray[1];153 display.innerText = calculate(firstOperand,secondOperand,sign);154 }155 if (display.innerText.includes("-")) {156 let stringToCountArray = display.innerText.split("-");157 firstOperand = stringToCountArray[0];158 secondOperand = stringToCountArray[1];159 display.innerText = calculate(firstOperand,secondOperand,sign);160 }161 if (display.innerText.includes("*")) {162 let stringToCountArray = display.innerText.split("*");163 firstOperand = stringToCountArray[0];164 secondOperand = stringToCountArray[1];165 display.innerText = calculate(firstOperand,secondOperand,sign);166 }167 if (display.innerText.includes("/")) {168 let stringToCountArray = display.innerText.split("/");169 firstOperand = stringToCountArray[0];170 secondOperand = stringToCountArray[1];171 display.innerText = calculate(firstOperand,secondOperand,sign);172 }173 ///////////////////////////////////////////////174 equals.classList.remove("ready");175 operators.forEach(operator => operator.classList.remove("blocked"));176 /////////////////////////////////////////////////177 break;178 case ".":179180 if (!display.innerText.includes("+") &&181 !display.innerText.includes("-") &&182 !display.innerText.includes("*") &&183 !display.innerText.includes("/")) {184 if (display.innerText.includes(".") ) {185 return;186 }187 }188 // if (!display.innerText.includes("-")) {189 // if (display.innerText.includes(".") ) {190 // return;191 // }192 // }193 // if (!display.innerText.includes("*")) {194 // if (display.innerText.includes(".") ) {195 // return;196 // }197 // }198 // if (!display.innerText.includes("/")) {199 // if (display.innerText.includes(".") ) {200 // return;201 // }202 // }203204 // if (display.innerText.includes(".")) return;205 if (dotCounter > 0) return;206 dotCounter++;207/////////////////////////////////////////////////////////208 if (display.innerText.includes("+")){209 if (display.innerText.split("+")[1].includes(".")) return;210 }211 if (display.innerText.includes("-")){212 if (display.innerText.split("-")[1].includes(".")) return;213 }214 if (display.innerText.includes("/")){215 if (display.innerText.split("/")[1].includes(".")) return;216 }217 if (display.innerText.includes("*")){218 if (display.innerText.split("*")[1].includes(".")) return;219 }220 if (display.innerText[display.innerText.length-1] == ".") return;221222223////////////////////////////////////////////////////224225 if (display.innerText == '') {226 display.innerText = `0${e.target.innerText}`;227 } else if (display.innerText[display.innerText.length-1] == "+") {228 display.innerText += `0${e.target.innerText}`;229 } else if (display.innerText[display.innerText.length-1] == "-") {230 display.innerText += `0${e.target.innerText}`;231 } else if (display.innerText[display.innerText.length-1] == "/") {232 display.innerText += `0${e.target.innerText}`;233 }234 else if (display.innerText[display.innerText.length-1] == "*") {235 display.innerText += `0${e.target.innerText}`;236 }237 else display.innerText += e.target.innerText;238 239 break;240 default:241 display.innerText += e.target.innerText;242 }243}))244245const clearDisplay = () => {246 display.innerText = '';247 dotCounter = 0;248}249250const calculate = (firstOperand,secondOperand,sign) => {251 if (sign == "divide") {252 if(secondOperand == 0) {253 return "ERROR!!!";254 }255 return Number(firstOperand) / Number(secondOperand);256 }257 if (sign == "multiply") {258 259 return Number(firstOperand) * Number(secondOperand);260 }261 if (sign == "add") {262 result = Number(firstOperand) + Number(secondOperand);263 return result;264 }265 if (sign == "substract") {266 return Number(firstOperand) - Number(secondOperand);267 } ...

Full Screen

Full Screen

app.js

Source:app.js Github

copy

Full Screen

1drawBoard(3,3,100,5)2let damierClicks=document.getElementById('damier-input');3let countClicks = 0 ;4damierClicks.addEventListener('click',countNrOfClicks)5damierClicks.addEventListener('click',giveResult)6let resetClick=document.getElementById('reset')7resetClick.addEventListener('click',clearDrawboard)8let playSquare1=document.getElementById('square1') ;9playSquare1.addEventListener('click',gameInput1);10let playSquare2=document.getElementById('square2') ;11playSquare2.addEventListener('click',gameInput2);12let playSquare3=document.getElementById('square3') ;13playSquare3.addEventListener('click',gameInput3);14let playSquare4=document.getElementById('square4') ;15playSquare4.addEventListener('click',gameInput4);16let playSquare5=document.getElementById('square5') ;17playSquare5.addEventListener('click',gameInput5);18let playSquare6=document.getElementById('square6') ;19playSquare6.addEventListener('click',gameInput6);20let playSquare7=document.getElementById('square7') ;21playSquare7.addEventListener('click',gameInput7);22let playSquare8=document.getElementById('square8') ;23playSquare8.addEventListener('click',gameInput8);24let playSquare9=document.getElementById('square9') ;25playSquare9.addEventListener('click',gameInput9);26function drawBoard(nrlines,nrcolumns,size,borderwidth)27 { 28 let damier = document.createElement('div')29 damier.id= 'damier-input'30 let numberID = 131 for (let iLines = 0; iLines < nrlines; ++iLines)32 {33 let x = size + iLines * (size + borderwidth)34 for (let iColumns = 0 ; iColumns < nrcolumns ; ++iColumns)35 {36 let y =size + iColumns * (size + borderwidth )37 let square1= drawSquare(x,y,borderwidth,numberID)38 damier.appendChild(square1)39 numberID = numberID + 140 }41 }42 document.body.append(damier)43 return damier }44 function drawSquare(x,y,borderwidth,numberID){45 let square = document.createElement('div');46 square.classList.add("square")47 square.style.borderWidth = borderwidth + "px";48 square.style.top = y + "px";49 square.style.left=x + "px";50 square.id = "square" + numberID51 document.body.appendChild(square);52 return square;53 54 }55function countNrOfClicks () {countClicks = countClicks + 1}56function gameInput1() {if (countClicks%2 ===0) {playSquare1.innerText = 'X', playSquare1.style.color='blue',result.innerText='Player 2 : your turn',result.style.color='red'} else {playSquare1.innerText = 'O',playSquare1.style.color='red',result.innerText='Player 1 : your turn',result.style.color='blue'}}57function gameInput2() {if (countClicks%2 ===0) {playSquare2.innerText = 'X', playSquare2.style.color='blue',result.innerText='Player 2 : your turn',result.style.color='red'} else {playSquare2.innerText = 'O',playSquare2.style.color='red',result.innerText='Player 1 : your turn',result.style.color='blue'}}58function gameInput3() {if (countClicks%2 ===0) {playSquare3.innerText = 'X', playSquare3.style.color='blue',result.innerText='Player 2 : your turn',result.style.color='red'} else {playSquare3.innerText = 'O',playSquare3.style.color='red',result.innerText='Player 1 : your turn',result.style.color='blue'}}59function gameInput4() {if (countClicks%2 ===0) {playSquare4.innerText = 'X', playSquare4.style.color='blue',result.innerText='Player 2 : your turn',result.style.color='red'} else {playSquare4.innerText = 'O',playSquare4.style.color='red',result.innerText='Player 1 : your turn',result.style.color='blue'}}60function gameInput5() {if (countClicks%2 ===0) {playSquare5.innerText = 'X', playSquare5.style.color='blue',result.innerText='Player 2 : your turn',result.style.color='red'} else {playSquare5.innerText = 'O',playSquare5.style.color='red',result.innerText='Player 1 : your turn',result.style.color='blue'}}61function gameInput6() {if (countClicks%2 ===0) {playSquare6.innerText = 'X', playSquare6.style.color='blue',result.innerText='Player 2 : your turn',result.style.color='red'} else {playSquare6.innerText = 'O',playSquare6.style.color='red',result.innerText='Player 1 : your turn',result.style.color='blue'}}62function gameInput7() {if (countClicks%2 ===0) {playSquare7.innerText = 'X', playSquare7.style.color='blue',result.innerText='Player 2 : your turn',result.style.color='red'} else {playSquare7.innerText = 'O',playSquare7.style.color='red',result.innerText='Player 1 : your turn',result.style.color='blue'}}63function gameInput8() {if (countClicks%2 ===0) {playSquare8.innerText = 'X', playSquare8.style.color='blue',result.innerText='Player 2 : your turn',result.style.color='red'} else {playSquare8.innerText = 'O',playSquare8.style.color='red',result.innerText='Player 1 : your turn',result.style.color='blue'}}64function gameInput9() {if (countClicks%2 ===0) {playSquare9.innerText = 'X', playSquare9.style.color='blue',result.innerText='Player 2 : your turn',result.style.color='red'} else {playSquare9.innerText = 'O',playSquare9.style.color='red',result.innerText='Player 1 : your turn',result.style.color='blue'}}65let result = document.getElementById('resultDynamic')66function giveResult()67{ if ((playSquare1.innerText=='X' && playSquare2.innerText=='X' && playSquare3.innerText=='X') ||68 (playSquare1.innerText=='X' && playSquare4.innerText=='X' && playSquare7.innerText=='X') ||69 (playSquare2.innerText=='X' && playSquare5.innerText=='X' && playSquare8.innerText=='X') || 70 (playSquare3.innerText=='X' && playSquare6.innerText=='X' && playSquare9.innerText=='X') || 71 (playSquare4.innerText=='X' && playSquare5.innerText=='X' && playSquare6.innerText=='X') ||72 (playSquare7.innerText=='X' && playSquare8.innerText=='X' && playSquare9.innerText=='X') ||73 (playSquare1.innerText=='X' && playSquare5.innerText=='X' && playSquare9.innerText=='X') ||74 (playSquare3.innerText=='X' && playSquare5.innerText=='X' && playSquare7.innerText=='X')) 75 {result.innerText='Player 1 wins!',result.style.color='blue'}76 { if ((playSquare1.innerText=='O' && playSquare2.innerText=='O' && playSquare3.innerText=='O') ||77 (playSquare1.innerText=='O' && playSquare4.innerText=='O' && playSquare7.innerText=='O') ||78 (playSquare2.innerText=='O' && playSquare5.innerText=='O' && playSquare8.innerText=='O') || 79 (playSquare3.innerText=='O' && playSquare6.innerText=='O' && playSquare9.innerText=='O') || 80 (playSquare4.innerText=='O' && playSquare5.innerText=='O' && playSquare6.innerText=='O') ||81 (playSquare7.innerText=='O' && playSquare8.innerText=='O' && playSquare9.innerText=='O') ||82 (playSquare1.innerText=='O' && playSquare5.innerText=='O' && playSquare9.innerText=='O') ||83 (playSquare3.innerText=='O' && playSquare5.innerText=='O' && playSquare7.innerText=='O')) 84 {result.innerText='Player 2 wins!',result.style.color='red'} 85 {if (playSquare1.innerText!='' && playSquare2.innerText!='' && playSquare3.innerText!='' &&86 playSquare1.innerText!='' && playSquare4.innerText!='' && playSquare7.innerText!='' &&87 playSquare2.innerText!='' && playSquare5.innerText!='' && playSquare8.innerText!='' && 88 playSquare3.innerText!='' && playSquare6.innerText!='' && playSquare9.innerText!='' && 89 playSquare4.innerText!='' && playSquare5.innerText!='' && playSquare6.innerText!='' &&90 playSquare7.innerText!='' && playSquare8.innerText!='' && playSquare9.innerText!='' &&91 playSquare1.innerText!='' && playSquare5.innerText!='' && playSquare9.innerText!='' &&92 playSquare3.innerText!='' && playSquare5.innerText!='' && playSquare7.innerText!='')93 {result.innerText='Draw!',result.style.color='black'} }94 }95}96function clearDrawboard ()97{ playSquare1.innerText = '';98 playSquare2.innerText = '';99 playSquare3.innerText = '';100 playSquare4.innerText = '';101 playSquare5.innerText = '';102 playSquare6.innerText = '';103 playSquare7.innerText = '';104 playSquare8.innerText = '';105 playSquare9.innerText = '';106 result.innerText='Player 1 : your turn';107 result.style.color='blue';...

Full Screen

Full Screen

_content_amenities.js

Source:_content_amenities.js Github

copy

Full Screen

1let dropdownsAmenities = document.querySelectorAll('.dropdown.dropdown_content_amenities')2dropdownsAmenities.forEach(dropdown => {3 let inputValue = dropdown.querySelector('.dropdown__input-placeholder'),4 items = dropdown.querySelectorAll('.dropdown__item'),5 commonCount = 0,6 values = [],7 btnClear = dropdown.querySelector('.dropdown__menu-btn-clear')8 if(btnClear){9 btnClear.addEventListener('click', () => {10 commonCount = 011 values = []12 inputValue.innerText = 'Выберите удобства'13 14 items.forEach(item => {15 item.querySelector('.dropdown__item-num').innerText = 016 })17 })18 }19 items.forEach((item,index) => {20 21 let itemNum = item.querySelector('.dropdown__item-num'),22 itemText = item.querySelector('.dropdown__item-text').innerHTML23 item.addEventListener('click', event => {24 event.stopPropagation()25 switch (event.target.id) {26 case 'dropdown__item-btn-reduce': 27 if(itemNum.innerText <= 0) break // Если счетчик равен 0, то ничего не делать28 itemNum.innerText--29 commonCount--30 itemNum.innerText = itemNum.innerText31 if (commonCount === 0) {32 inputValue.innerText = 'Выберите удобства'33 values = []34 break35 }36 if (itemText.toLowerCase() === 'спальни'){37 if(itemNum.innerText == '0'){38 values[index] = ''39 } else if(itemNum.innerText === 1){40 values[index] = `${itemNum.innerText} спальня`41 } else if(itemNum.innerText > 1 && itemNum.innerText < 5){42 values[index] = `${itemNum.innerText} спальни`43 } else {44 values[index] = `${itemNum.innerText} спален`45 }46 } else if (itemText.toLowerCase() === 'кровати'){47 if(itemNum.innerText == '0'){48 values[index] = ''49 } else if(itemNum.innerText === 1){50 values[index] = `${itemNum.innerText} кровать`51 } else if(itemNum.innerText > 1 && itemNum.innerText < 5){52 values[index] = `${itemNum.innerText} кровати`53 } else {54 values[index] = `${itemNum.innerText} кроватей`55 }56 } else if (itemText.toLowerCase() === 'ванные комнаты'){57 if(itemNum.innerText == '0'){58 values[index] = ''59 } else if(itemNum.innerText === 1){60 values[index] = `${itemNum.innerText} ванная комната`61 } else if(itemNum.innerText > 1 && itemNum.innerText < 5){62 values[index] = `${itemNum.innerText} ванные комнаты`63 } else {64 values[index] = `${itemNum.innerText} ванных комнат`65 }66 } 67 inputValue.innerText = values.filter(value => !!value).join(', ')68 break69 case 'dropdown__item-btn-add':70 itemNum.innerText++71 commonCount++72 itemNum.innerText = itemNum.innerText 73 if (itemText.toLowerCase() === 'спальни'){74 if(itemNum.innerText == 1){75 console.log('wirk');76 values[index] = `${itemNum.innerText} спальня`77 } else if(itemNum.innerText > 1 && itemNum.innerText < 5){78 values[index] = `${itemNum.innerText} спальни`79 } else {80 values[index] = `${itemNum.innerText} спален`81 }82 } else if (itemText.toLowerCase() === 'кровати'){83 if(itemNum.innerText == 1){84 values[index] = `${itemNum.innerText} кровать`85 } else if(itemNum.innerText > 1 && itemNum.innerText < 5){86 values[index] = `${itemNum.innerText} кровати`87 } else {88 values[index] = `${itemNum.innerText} кроватей`89 }90 } else if (itemText.toLowerCase() === 'ванные комнаты'){91 if(itemNum.innerText == 1){92 values[index] = `${itemNum.innerText} ванная комната`93 } else if(itemNum.innerText > 1 && itemNum.innerText < 5){94 values[index] = `${itemNum.innerText} ванные комнаты`95 } else {96 values[index] = `${itemNum.innerText} ванных комнат`97 }98 } 99 inputValue.innerText = values.filter(value => !!value).join(', ')100 break101 }102 103 })104 })...

Full Screen

Full Screen

scrapy.js

Source:scrapy.js Github

copy

Full Screen

1/*https://www.cnblogs.com/justdoitba/p/7634895.html */2function _x(STR_XPATH) {3 var xresult = document.evaluate(STR_XPATH, document, null, XPathResult.ANY_TYPE, null);4 var xnodes = [];5 var xres;6 while (xres = xresult.iterateNext()) {7 xnodes.push(xres);8 }9 return xnodes;10}11let nodeArr = _x('/html/body/div[4]/div/div[1]/div[2]/p');12let len = nodeArr.length;13newArr = Array(); 14for(let i=0;i<len;i++){15 if(nodeArr[i].innerText.indexOf('、')==-1&&nodeArr[i].innerText.indexOf('A.')==-1&&nodeArr[i].innerText.indexOf('B.')==-1&&nodeArr[i].innerText.indexOf('C.')==-1&&nodeArr[i].innerText.indexOf('D.')==-1){16 continue;17 }18 newArr.push(nodeArr[i]);19}20titleArr = Array();21ansAArr = Array();22ansBArr = Array();23ansCArr = Array();24ansDArr = Array();25len = newArr.length;26for(let i=0;i<len;i++){27 if(newArr[i].innerText.indexOf('A、')==-1&&newArr[i].innerText.indexOf('B、')==-1&&newArr[i].innerText.indexOf('C、')==-1&&newArr[i].innerText.indexOf('D、')==-1&&newArr[i].innerText.indexOf('E、')==-1&&newArr[i].innerText.indexOf('F、')==-1&&newArr[i].innerText.indexOf('A.')==-1&&newArr[i].innerText.indexOf('B.')==-1&&newArr[i].innerText.indexOf('C.')==-1&&newArr[i].innerText.indexOf('D.')==-1&&newArr[i].innerText.indexOf('E.')==-1){28 titleArr.push(newArr[i]);29 }else{30 if(newArr[i].innerText.indexOf('A、')!=-1||newArr[i].innerText.indexOf('A.')!=-1)31 ansAArr.push(newArr[i]);32 if(newArr[i].innerText.indexOf('B、')!=-1||newArr[i].innerText.indexOf('B.')!=-1)33 ansBArr.push(newArr[i]);34 if(newArr[i].innerText.indexOf('C、')!=-1||newArr[i].innerText.indexOf('C.')!=-1)35 ansCArr.push(newArr[i]);36 if(newArr[i].innerText.indexOf('D、')!=-1||newArr[i].innerText.indexOf('D.')!=-1)37 ansDArr.push(newArr[i]);38 }39}40//titleArr里有50题41correctArr = Array();42for(let i=0;i<titleArr.length;i++){43 if($($(ansAArr[i]).find('span')[0]).css('color') == 'rgb(255, 0, 0)'){44 correctArr.push(1);45 }else if($($(ansBArr[i]).find('span')[0]).css('color') == 'rgb(255, 0, 0)'){46 correctArr.push(2);47 }else if($($(ansCArr[i]).find('span')[0]).css('color') == 'rgb(255, 0, 0)'){48 correctArr.push(3);49 }else if($($(ansDArr[i]).find('span')[0]).css('color') == 'rgb(255, 0, 0)'){50 correctArr.push(4);51 }else{52 correctArr.push(1);53 }54}55let sqlArr = Array();56let sql = '';57let title;58let ansA;59let ansB;60let ansC;61let ansD;62for(let i=0;i<titleArr.length;i++){63 let length = $(titleArr[i]).find('span').length;64 for(let j =1;j<length;j++){65 if(j==1){66 title = $(titleArr[i]).find('span')[j].innerText;67 }else{68 title += $(titleArr[i]).find('span')[j].innerText;69 }70 }71 length = $(ansAArr[i]).find('span').length;72 for(let j =1;j<length;j++){73 if(j==1){74 ansA = $(ansAArr[i]).find('span')[j].innerText;75 }else{76 ansA += $(ansAArr[i]).find('span')[j].innerText;77 }78 }79 length = $(ansBArr[i]).find('span').length;80 for(let j =1;j<length;j++){81 if(j==1){82 ansB = $(ansBArr[i]).find('span')[j].innerText;83 }else{84 ansB += $(ansBArr[i]).find('span')[j].innerText;85 }86 }87 length = $(ansCArr[i]).find('span').length;88 for(let j =1;j<length;j++){89 if(j==1){90 ansC = $(ansCArr[i]).find('span')[j].innerText;91 }else{92 ansC += $(ansCArr[i]).find('span')[j].innerText;93 }94 }95 length = $(ansDArr[i]).find('span').length;96 for(let j =1;j<length;j++){97 if(j==1){98 ansD = $(ansDArr[i]).find('span')[j].innerText;99 }else{100 ansD += $(ansDArr[i]).find('span')[j].innerText;101 }102 }103 /*104 ansAArr[i] = $(ansAArr[i]).find('span')[1].innerText;105 ansBArr[i] = $(ansBArr[i]).find('span')[1].innerText;106 ansCArr[i] = $(ansCArr[i]).find('span')[1].innerText;107 ansDArr[i] = $(ansDArr[i]).find('span')[1].innerText;108 */109 sqlArr.push("call add_exercises(1,'"+title+"','"+ansA+"','"+ansB+"','"+ansC+"','"+ansD+"',"+correctArr[i]+",'reason is that.....');");110 sql +="call add_exercises(1,'"+title+"','"+ansA+"','"+ansB+"','"+ansC+"','"+ansD+"',"+correctArr[i]+",'reason is that.....');"...

Full Screen

Full Screen

main.js

Source:main.js Github

copy

Full Screen

1let button = document.querySelectorAll('.btn')23let turn = 1;4let click = 0;56let one = document.getElementById('one');7let two = document.getElementById('two');8let three = document.getElementById('three');9let four = document.getElementById('four');10let five = document.getElementById('five');11let six = document.getElementById('six');12let seven = document.getElementById('seven');13let eight = document.getElementById('eight');14let nine = document.getElementById('nine');1516let reload = document.getElementById('reload')17reload.addEventListener('click', () => {18 for (btn of button) {19 btn.innerText = '';20 }21 document.getElementById('gameInfo').innerHTML = '<br><br>';22 turn = 1;23 click = 0;24});2526function clear(){27 setTimeout(() => {28 for (btn of button) {29 btn.innerText = '';30 }31 document.getElementById('gameInfo').innerHTML = '<br><br>';32 turn = 1;33 click = 0;34 }, 2500);35}3637button.forEach(btn => {38 btn.addEventListener('click', function type(x) {39 let btnTxt = x.target.innerText;40 // console.log(btnTxt)4142 if (btnTxt == '') {43 if (turn == 1) {44 if(click == 8) {45 document.getElementById('gameInfo').innerHTML = '<br><p>OOPS! Game Over.</p>'46 }47 btn.innerText = 'O';48 turn = 2;49 click++50 } else {51 btn.innerText = 'X';52 turn = 1;53 click++54 }55 56 if(one.innerText == 'O' && two.innerText == 'O' && three.innerText == 'O' || one.innerText == 'O' && five.innerText == 'O' && nine.innerText == 'O' || three.innerText == 'O' && five.innerText == 'O' && seven.innerText == 'O' || four.innerText == 'O' && five.innerText == 'O' && six.innerText == 'O' || seven.innerText == 'O' && eight.innerText == 'O' && nine.innerText == 'O' || one.innerText == 'O' && four.innerText == 'O' && seven.innerText == 'O' || two.innerText == 'O' && five.innerText == 'O' && eight.innerText == 'O' || three.innerText == 'O' && six.innerText == 'O' && nine.innerText == 'O') {57 document.getElementById('gameInfo').innerHTML = '<br><p>Wow! Player 1 makes A match, Player 1 Wins.</p>';58 clear()59 } 60 if(one.innerText == 'X' && two.innerText == 'X' && three.innerText == 'X' || one.innerText == 'X' && five.innerText == 'X' && nine.innerText == 'X' || three.innerText == 'X' && five.innerText == 'X' && seven.innerText == 'X' || four.innerText == 'X' && five.innerText == 'X' && six.innerText == 'X' || seven.innerText == 'X' && eight.innerText == 'X' && nine.innerText == 'X' || one.innerText == 'X' && four.innerText == 'X' && seven.innerText == 'X' || two.innerText == 'X' && five.innerText == 'X' && eight.innerText == 'X' || three.innerText == 'X' && six.innerText == 'X' && nine.innerText == 'X') {61 document.getElementById('gameInfo').innerHTML = '<br><p>Wow! Player 2 makes A match, Player 2 Wins.</p>';62 clear()63 } 64 } else {65 alert('Already Clicked.')66 }67 }); ...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1// console.log(eval("2%2"));2let displayArea = document.getElementById("display");3function isOperator(buttonText) {4 if (5 buttonText == "+" ||6 buttonText == "-" ||7 buttonText == "/" ||8 buttonText == "%" ||9 buttonText == "*"10 ) {11 return true;12 } else {13 return false;14 }15}16// function buttonClicked(buttonText) {17// if (displayArea.innerText.length >= 24) {18// return;19// }20// if (buttonText != 'CLR' && buttonText != 'DEL' && buttonText != '=') {21// if (displayArea.innerText === "0") {22// if (buttonText != "00" && buttonText != "0") {23// //Dont do anything when 0 and 00 is pressed24// if (buttonText == "." || isOperator(buttonText))25// //if button clicked is . or any operator then show it a 0 + button clicked e.g (0.5 , 0 + )26// displayArea.innerText = display.innerText + buttonText;27// else displayArea.innerText = buttonText;28// }29// } else {30// if (isOperator(displayArea.innerText[displayArea.innerText.length - 1]) && isOperator(buttonText)) {31// displayArea.innerText = displayArea.innerText.slice(0, -1) + buttonText; // Ignoring last operator and adding curr pressed32// } else {33// displayArea.innerText = displayArea.innerText + buttonText;34// }35// }36// } else {37// if (buttonText === 'CLR') {38// displayArea.innerText = '0';39// }40// else if (buttonText === 'DEL') {41// displayArea.innerText = displayArea.innerText.slice(0, -1);42// }43// else if (buttonText === '=') {44// try {45// displayArea.innerText = eval(displayArea.innerText);46// }47// catch (error) {48// display.innerText = "0";49// }50// }51// }52// }53function buttonClicked(buttonText) {54 if (displayArea.innerText.length >= 24) {55 displayArea.innerText = '0';56 return;57 }58 if (buttonText === 'CLR') {59 displayArea.innerText = '0';60 return;61 }62 if (buttonText === 'DEL') {63 displayArea.innerText = displayArea.innerText.slice(0, -1);64 return;65 }66 if (buttonText === '=') {67 try {68 displayArea.innerText = eval(displayArea.innerText);69 }70 catch (error) {71 display.innerText = "0";72 }73 return;74 }75 if (displayArea.innerText === "0") {76 if (buttonText == "00" || buttonText == "0")77 return;78 //Dont do anything when 0 and 00 is pressed79 if (buttonText == "." || isOperator(buttonText)) {80 //if button clicked is . or any operator then show it a 0 + button clicked e.g (0.5 , 0 + )81 displayArea.innerText = display.innerText + buttonText;82 return;83 }84 displayArea.innerText = buttonText;85 }86 else {87 if (isOperator(displayArea.innerText[displayArea.innerText.length - 1]) && isOperator(buttonText)) {88 displayArea.innerText = displayArea.innerText.slice(0, -1) + buttonText; // Ignoring last operator and adding curr pressed89 return;90 }91 displayArea.innerText = displayArea.innerText + buttonText;92 }...

Full Screen

Full Screen

calcul.js

Source:calcul.js Github

copy

Full Screen

1// 숫자 클릭 시 casioHead와2// 연산 클릭 시 casioHead에 출력3// = 클릭 시 연산 결과값 casioHead와 casioInput에 출력4const btn_num = document.querySelectorAll('.casio_num');5const numli = document.querySelector('#casioHead');6const btn_oper = document.querySelectorAll('.casio_oper');7const numResult = document.querySelector('#casioInput');8let num1 = '';9let num2 = '';10let oper;11for (let i = 0; i < btn_num.length; i++) {12 btn_num[i].onclick = function () {13 if (14 btn_num[i].innerText == '*' ||15 btn_num[i].innerText == '/' ||16 btn_num[i].innerText == '+' ||17 btn_num[i].innerText == '-'18 ) {19 if (oper) {20 return;21 } else if (num1) {22 oper = btn_num[i].innerText;23 numli.innerText += oper;24 console.log(oper);25 } else {26 alert('숫자부터 입력하세요');27 }28 } else if (oper === '*' || oper === '/' || oper === '+' || oper === '-') {29 num2 = num2 + btn_num[i].innerText;30 numli.innerText += btn_num[i].innerText;31 console.log(num2);32 } else {33 if (numResult.innerText) {34 numResult.innerText = '';35 numli.innerText = '';36 num1 = btn_num[i].innerText;37 numli.innerText = num1;38 } else {39 num1 = num1 + btn_num[i].innerText;40 numli.innerText = num1;41 console.log(num1);42 }43 }44 };45}46//계산 class47class Calcul {48 constructor(num1, num2) {49 this.num1 = Number(num1);50 this.num2 = Number(num2);51 }52 sum() {53 return this.num1 + this.num2;54 }55 minus() {56 return this.num1 - this.num2;57 }58 division() {59 return this.num1 / this.num2;60 }61 multi() {62 return this.num1 * this.num2;63 }64}65//계산 버튼66document.querySelector('#casioResult').onclick = function () {67 if (numResult.innerText) {68 num1 = numResult.innerText;69 }70 const result = new Calcul(num1, num2);71 console.log(result);72 if (oper === '+') {73 numResult.innerText = result.sum();74 numli.innerText = result.sum();75 oper = '';76 num2 = '';77 } else if (oper === '-') {78 numResult.innerText = result.minus();79 numli.innerText = result.minus();80 oper = '';81 num2 = '';82 } else if (oper === '*') {83 numResult.innerText = result.multi();84 numli.innerText = result.multi();85 oper = '';86 num2 = '';87 } else if (oper === '/') {88 numResult.innerText = result.division();89 numli.innerText = result.division();90 oper = '';91 num2 = '';92 }93};94//reset 버튼95document.querySelector('#casioReset').onclick = function () {96 numResult.innerText = '';97 numli.innerText = '';98 num1 = '';99 num2 = '';100 oper = '';...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch({ headless: false });4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.click('text="Today\'s Deals"');7 await page.waitForTimeout(5000)8 await page.click('text="Mobiles"');9 await page.waitForTimeout(5000)10 await page.click('text="Samsung"');11 await page.waitForTimeout(5000)12 await page.click('text="Samsung Galaxy M31 (Ocean Blue, 6GB RAM, 128GB Storage)"');13 await page.waitForTimeout(5000)14 await page.click('text="Add to Cart"');15 await page.waitForTimeout(5000)16 await page.click('text="Cart"');17 await page.waitForTimeout(5000)18 await page.click('text="Delete"');19 await page.waitForTimeout(5000)20 await page.click('text="Continue shopping"');21 await page.waitForTimeout(5000)22 await page.click('text="Mobiles"');23 await page.waitForTimeout(5000)24 await page.click('text="Apple"');25 await page.waitForTimeout(5000)26 await page.click('text="Apple iPhone 11 (Black, 64 GB)"');27 await page.waitForTimeout(5000)28 await page.click('text="Add to Cart"');29 await page.waitForTimeout(5000)30 await page.click('text="Cart"');31 await page.waitForTimeout(5000)32 await page.click('text="Delete"');33 await page.waitForTimeout(5000)34 await page.click('text="Continue shopping"');35 await page.waitForTimeout(5000)36 await page.click('text="Mobiles"');37 await page.waitForTimeout(5000)38 await page.click('text="OnePlus"');39 await page.waitForTimeout(5000)40 await page.click('text="OnePlus Nord (Gray Onyx, 12GB RAM, 256GB Storage)"');41 await page.waitForTimeout(5000)42 await page.click('text="Add to Cart"');43 await page.waitForTimeout(5000)44 await page.click('text="Cart"');45 await page.waitForTimeout(5000)46 await page.click('

Full Screen

Using AI Code Generation

copy

Full Screen

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

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch({ headless: false });4 const page = await browser.newPage();5 console.log(await page.innerText('.navbar__inner'));6 await browser.close();7})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 await page.fill('#new-todo', 'Learn Playwright');6 await page.press('#new-todo', 'Enter');7 await page.click('text=Learn Playwright >> .. >> .toggle');8 const list = await page.$$('ul.todo-list li');9 for (const item of list) {10 const content = await item.innerText();11 console.log(content);12 }13 await browser.close();14})();15const { chromium } = require('playwright');16(async () => {17 const browser = await chromium.launch();18 const page = await browser.newPage();19 await page.fill('#new-todo', 'Learn Playwright');20 await page.press('#new-todo', 'Enter');21 await page.click('text=Learn Playwright >> .. >> .toggle');22 const list = await page.$$('ul.todo-list li');23 for (const item of list) {24 const content = await item.innerText();25 console.log(content);26 }27 await browser.close();28})();29const { chromium } = require('playwright');30(async () => {31 const browser = await chromium.launch();32 const page = await browser.newPage();33 await page.fill('#new-todo', 'Learn Playwright');34 await page.press('#new-todo', 'Enter');35 await page.click('text=Learn Playwright >> .. >> .toggle');36 const list = await page.$$('ul.todo-list li');37 for (const item of list) {38 const content = await item.innerText();39 console.log(content);40 }41 await browser.close();42})();43const { chromium } = require('playwright');44(async () => {45 const browser = await chromium.launch();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 const text = await page.innerText('#main-content > div > div:nth-child(1) > div:nth-child(1) > div > div:nth-child(1) > div > div > div > div > div > div > div > div > div > h1');6 console.log(text);7 await browser.close();8})();9const { chromium } = require('playwright');10(async () => {11 const browser = await chromium.launch();12 const page = await browser.newPage();13 const text = await page.innerText('#main-content > div > div:nth-child(1) > div:nth-child(1) > div > div:nth-child(1) > div > div > div > div > div > div > div > div > div > h1');14 console.log(text);15 await browser.close();16})();17const { chromium } = require('playwright');18(async () => {19 const browser = await chromium.launch();20 const page = await browser.newPage();21 const text = await page.innerText('#main-content > div > div:nth-child(1) > div:nth-child(1) > div > div:nth-child(1) > div > div > div > div > div > div > div > div > div > h1');22 console.log(text);23 await browser.close();24})();25const { chromium } = require('playwright');26(async () => {27 const browser = await chromium.launch();28 const page = await browser.newPage();29 const text = await page.innerText('#main-content > div > div:nth-child(1) > div:nth-child(1) > div >

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 const innerText = await page.innerText('.navbar__inner');6 console.log(innerText);7 await browser.close();8})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch({headless: false});4 const page = await browser.newPage();5 await page.type('input[aria-label="Search"]', 'Playwright');6 await page.keyboard.press('Enter');7 await page.waitForSelector('text=Playwright');8 const element = await page.$('text=Playwright');9 console.log(await element.innerText());10 await browser.close();11})();12const { chromium } = require('playwright');13(async () => {14 const browser = await chromium.launch({headless: false});15 const page = await browser.newPage();16 await page.type('input[aria-label="Search"]', 'Playwright');17 await page.keyboard.press('Enter');18 await page.waitForSelector('text=Playwright');19 await page.click('text=Playwright');20 await browser.close();21})();22const { chromium } = require('playwright');23(async () => {24 const browser = await chromium.launch({headless: false});25 const page = await browser.newPage();26 await page.type('input[aria-label="Search"]', 'Playwright');27 await page.keyboard.press('Enter');28 await page.waitForSelector('text=Playwright');29 const element = await page.$('text=Playwright');30 console.log(await element.isElementPresent());31 await browser.close();32})();33const { chromium } = require('playwright');34(async () => {35 const browser = await chromium.launch({headless: false});36 const page = await browser.newPage();37 await page.type('input[aria-label="Search"]', 'Playwright');38 await page.keyboard.press('

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 const elementHandle = await page.$('#js-link-box-en');6 const text = await elementHandle.innerText();7 console.log(text);8 await browser.close();9})();10const { chromium } = require('playwright');11(async () => {12 const browser = await chromium.launch();13 const page = await browser.newPage();14 const elementHandle = await page.$('#js-link-box-en');15 const text = await elementHandle.innerHTML();16 console.log(text);17 await browser.close();18})();19const { chromium } = require('playwright');20(async () => {21 const browser = await chromium.launch();22 const page = await browser.newPage();23 const elementHandle = await page.$('#js-link-box-en');24 const text = await elementHandle.innerText();25 console.log(text);26 await browser.close();27})();28const { chromium } = require('playwright');29(async () => {30 const browser = await chromium.launch();31 const page = await browser.newPage();32 const elementHandle = await page.$('#js-link-box-en');33 const text = await elementHandle.innerHTML();34 console.log(text);35 await browser.close();36})();37const { chromium } = require('playwright');38(async () => {39 const browser = await chromium.launch();40 const page = await browser.newPage();41 const elementHandle = await page.$('#js-link-box-en');42 const text = await elementHandle.innerText();43 console.log(text);44 await browser.close();45})();46const { chromium } = require('playwright');47(async () => {48 const browser = await chromium.launch();49 const page = await browser.newPage();50 const elementHandle = await page.$('#js

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal 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