Best JavaScript code snippet using wpt
webrtc-rawrtc.js
Source:webrtc-rawrtc.js
1'use strict';2class Peer {3 constructor() {4 this.pc = null;5 this.localMid = null;6 this.localCandidates = [];7 this.localParameters = null;8 this.localDescription = null;9 this.remoteParameters = null;10 this.remoteDescription = null;11 var _waitGatheringComplete = {};12 _waitGatheringComplete.promise = new Promise((resolve, reject) => {13 _waitGatheringComplete.resolve = resolve;14 _waitGatheringComplete.reject = reject;15 });16 this._waitGatheringComplete = _waitGatheringComplete;17 this.dc = {}18 }19 createPeerConnection() {20 if (this.pc) {21 console.warn('RTCPeerConnection already created');22 return this.pc;23 }24 var self = this;25 // Create peer connection26 var pc = new RTCPeerConnection({27 iceServers: [{28 urls: 'stun:stun.l.google.com:19302'29 }]30 });31 // Bind peer connection events32 pc.onnegotiationneeded = function(event) {33 console.log('Negotiation needed')34 };35 pc.onicecandidate = function(event) {36 if (event.candidate) {37 console.log('Gathered candidate:', event.candidate);38 self.localCandidates.push(event.candidate);39 } else {40 console.log('Gathering complete');41 self._waitGatheringComplete.resolve();42 }43 };44 pc.onicecandidateerror = function(event) {45 console.error('ICE candidate error:', event.errorText);46 };47 pc.onsignalingstatechange = function(event) {48 console.log('Signaling state changed to:', pc.signalingState);49 };50 pc.oniceconnectionstatechange = function(event) {51 console.log('ICE connection state changed to:', pc.iceConnectionState);52 };53 pc.onicegatheringstatechange = function(event) {54 console.log('ICE gathering state changed to:', pc.iceGatheringState);55 };56 pc.onconnectionstatechange = function(event) {57 console.log('Connection state changed to:', pc.connectionState);58 };59 pc.ondatachannel = function(event) {60 self.createDataChannel(event.channel);61 };62 this.pc = pc;63 return pc;64 }65 createDataChannel(dc) {66 // Create data channel67 dc = (typeof dc !== 'undefined') ? dc : this.pc.createDataChannel('example-channel', {68 ordered: true69 });70 // Bind data channel events71 dc.onopen = function(event) {72 console.log('Data channel', dc.label, '(', dc.id, ')', 'open');73 // Send 'hello'74 dc.send('Hello from WebRTC on', navigator.userAgent);75 };76 dc.onbufferedamountlow = function(event) {77 console.log('Data channel', dc.label, '(', dc.id, ')', 'buffered amount low');78 };79 dc.onerror = function(event) {80 console.error('Data channel', dc.label, '(', dc.id, ')', 'error:', event);81 };82 dc.onclose = function(event) {83 console.log('Data channel', dc.label, '(', dc.id, ')', 'closed');84 };85 dc.onmessage = function(event) {86 var length = event.data.size || event.data.byteLength || event.data.length;87 console.info('Data channel', dc.label, '(', dc.id, ')', 'message size:', length);88 };89 // Store channel90 this.dc[dc.label] = dc;91 return dc;92 }93 getLocalParameters() {94 return new Promise((resolve, reject) => {95 var error;96 var self = this;97 if (!this.localDescription) {98 error = 'Must create offer/answer';99 console.error(error);100 reject(error);101 return;102 }103 // Initialise parameters104 var parameters = {105 iceParameters: null,106 iceCandidates: [],107 dtlsParameters: null,108 sctpParameters: null,109 };110 // Split sections111 var sections = SDPUtils.splitSections(this.localDescription.sdp);112 var session = sections.shift();113 // Go through media sections114 sections.forEach(function(mediaSection, sdpMLineIndex) {115 // TODO: Ignore anything else but data transports116 // Get mid117 // TODO: This breaks with multiple transceivers118 if (!self.localMid) {119 var mid = SDPUtils.matchPrefix(mediaSection, 'a=mid:');120 if (mid.length > 0) {121 self.localMid = mid[0].substr(6);122 }123 }124 // Get ICE parameters125 if (!parameters.iceParameters) {126 parameters.iceParameters = SDPUtils.getIceParameters(mediaSection, session);127 }128 // Get DTLS parameters129 if (!parameters.dtlsParameters) {130 parameters.dtlsParameters = SDPUtils.getDtlsParameters(mediaSection, session);131 }132 // Get SCTP parameters133 if (!parameters.sctpParameters) {134 parameters.sctpParameters = SDPUtils.getSctpCapabilities(mediaSection, session);135 parameters.sctpParameters.port = SDPUtils.getSctpPort(mediaSection, session);136 }137 });138 // ICE lite parameter139 if (!parameters.iceParameters140 || !parameters.dtlsParameters141 || !parameters.sctpParameters) {142 error = 'Could not retrieve required parameters from local description';143 console.error(error);144 reject(error);145 return;146 }147 parameters.iceParameters.iceLite =148 SDPUtils.matchPrefix(session, 'a=ice-lite').length > 0;149 // Get ICE candidates150 this._waitGatheringComplete.promise.then(() => {151 // Add ICE candidates152 for (var sdpCandidate of self.localCandidates) {153 var candidate = SDPUtils.parseCandidate(sdpCandidate.candidate);154 parameters.iceCandidates.push(candidate);155 }156 // Add ICE candidate complete sentinel157 // parameters.iceCandidates.push({complete: true}); // TODO158 // Done159 resolve(parameters);160 });161 });162 }163 setRemoteParameters(parameters, type, localMid = null) {164 return new Promise((resolve, reject) => {165 if (this.remoteDescription) {166 resolve(this.remoteDescription);167 return;168 }169 if (!this.pc) {170 console.error('Must create RTCPeerConnection instance');171 return;172 }173 if (!localMid) {174 localMid = this.localMid;175 }176 this.remoteParameters = parameters;177 // Translate DTLS role178 // TODO: This somehow didn't make it into SDPUtils179 var setupType;180 switch (parameters.dtlsParameters.role) {181 case 'client':182 setupType = 'active';183 break;184 case 'server':185 setupType = 'passive';186 break;187 default:188 // We map 'offer' to 'controlling' and 'answer' to 'controlled',189 // so rawrtc will take 'server' if offering and 'client' if answering190 // as specified by the ORTC spec191 switch (type) {192 case 'offer':193 // WebRTC requires actpass in offer194 setupType = 'actpass';195 break;196 case 'answer':197 setupType = 'active';198 break;199 }200 break;201 }202 // Write session section203 var sdp = SDPUtils.writeSessionBoilerplate();204 sdp += 'a=group:BUNDLE ' + localMid + '\r\n';205 sdp += 'a=ice-options:trickle\r\n';206 if (parameters.iceParameters.iceLite) {207 sdp += 'a=ice-lite\r\n';208 }209 // Write media section210 // TODO: Replace211 // sdp += 'm=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\n'; // (03)212 sdp += 'm=application 9 DTLS/SCTP ' + parameters.sctpParameters.port + '\r\n'; // (01)213 sdp += 'c=IN IP4 0.0.0.0\r\n';214 sdp += 'a=mid:' + localMid + '\r\n';215 sdp += 'a=sendrecv\r\n';216 // SCTP part217 sdp += SDPUtils.writeSctpCapabilities(parameters.sctpParameters);218 sdp += SDPUtils.writeSctpPort(parameters.sctpParameters.port);219 sdp += 'a=sctpmap:' + parameters.sctpParameters.port + ' webrtc-datachannel 65535\r\n'; // (01)220 // DTLS part221 sdp += SDPUtils.writeDtlsParameters(parameters.dtlsParameters, setupType);222 // ICE part223 sdp += 'a=connection:new\r\n'; // (03)224 sdp += SDPUtils.writeIceParameters(parameters.iceParameters);225 // Done226 console.log('Remote description:\n' + sdp);227 // Set remote description228 this.pc.setRemoteDescription({type: type, sdp: sdp})229 .then(() => {230 console.log('Remote description:\n' + this.pc.remoteDescription.sdp);231 this.remoteDescription = this.pc.remoteDescription;232 // Add ICE candidates233 for (var iceCandidate of parameters.iceCandidates) {234 // Add component which ORTC doesn't have235 // Note: We choose RTP as it doesn't actually matter for us236 iceCandidate.component = 1; // RTP237 // Create238 var candidate = new RTCIceCandidate({239 candidate: SDPUtils.writeCandidate(iceCandidate),240 sdpMLineIndex: 0, // TODO: Fix241 sdpMid: localMid // TODO: Fix242 });243 // Add244 console.log(candidate.candidate);245 this.pc.addIceCandidate(candidate)246 .then(() => {247 console.log('Added remote candidate', candidate);248 });249 }250 // It's trickle ICE, no need to wait for candidates to be added251 resolve();252 })253 .catch((error) => {254 reject(error);255 });256 });257 }258 start() {}259}260class ControllingPeer extends Peer {261 getLocalParameters() {262 return new Promise((resolve, reject) => {263 if (!this.pc) {264 var error = 'Must create RTCPeerConnection instance';265 console.error(error);266 reject(error);267 return;268 }269 var getLocalParameters = () => {270 // Return parameters271 super.getLocalParameters()272 .then((parameters) => {273 this.localParameters = parameters;274 resolve(parameters);275 })276 .catch((error) => {277 reject(error);278 });279 };280 // Create offer281 if (!this.localDescription) {282 this.pc.createOffer()283 .then((description) => {284 return this.pc.setLocalDescription(description);285 })286 .then(() => {287 console.log('Local description:\n' + this.pc.localDescription.sdp);288 this.localDescription = this.pc.localDescription;289 getLocalParameters();290 })291 .catch((error) => {292 reject(error);293 });294 } else {295 getLocalParameters();296 }297 });298 }299 setRemoteParameters(parameters, localMid = null) {300 return super.setRemoteParameters(parameters, 'answer', localMid);301 }302}303class ControlledPeer extends Peer {304 getLocalParameters() {305 return new Promise((resolve, reject) => {306 var error;307 if (!this.pc) {308 error = 'Must create RTCPeerConnection instance';309 console.error(error);310 reject(error);311 return;312 }313 if (!this.remoteDescription) {314 error = 'Must have remote description';315 console.error(error);316 reject(error);317 return;318 }319 var getLocalParameters = () => {320 // Return parameters321 super.getLocalParameters()322 .then((parameters) => {323 resolve(parameters);324 })325 .catch((error) => {326 reject(error);327 });328 };329 // Create answer330 if (!this.localDescription) {331 this.pc.createAnswer()332 .then((description) => {333 return this.pc.setLocalDescription(description);334 })335 .then(() => {336 console.log('Local description:\n' + this.pc.localDescription.sdp);337 this.localDescription = this.pc.localDescription;338 getLocalParameters();339 });340 } else {341 getLocalParameters();342 }343 });344 }345 setRemoteParameters(parameters, localMid = null) {346 return super.setRemoteParameters(parameters, 'offer', localMid);347 }...
webrtc_rawrtc.js
Source:webrtc_rawrtc.js
1'use strict';2class Peer {3 constructor() {4 this.pc = null;5 this.localMid = null;6 this.localCandidates = [];7 this.localParameters = null;8 this.localDescription = null;9 this.remoteParameters = null;10 this.remoteDescription = null;11 var _waitGatheringComplete = {};12 _waitGatheringComplete.promise = new Promise((resolve, reject) => {13 _waitGatheringComplete.resolve = resolve;14 _waitGatheringComplete.reject = reject;15 });16 this._waitGatheringComplete = _waitGatheringComplete;17 this.dc = {}18 }19 createPeerConnection() {20 if (this.pc) {21 console.warn('RTCPeerConnection already created');22 return this.pc;23 }24 var self = this;25 // Create peer connection26 var pc = new RTCPeerConnection({27 iceServers: [{28 urls: 'stun:stun.l.google.com:19302'29 }]30 });31 // Bind peer connection events32 pc.onnegotiationneeded = function(event) {33 console.log('Negotiation needed')34 };35 pc.onicecandidate = function(event) {36 if (event.candidate) {37 console.log('Gathered candidate:', event.candidate);38 self.localCandidates.push(event.candidate);39 } else {40 console.log('Gathering complete');41 self._waitGatheringComplete.resolve();42 }43 };44 pc.onicecandidateerror = function(event) {45 console.error('ICE candidate error:', event.errorText);46 };47 pc.onsignalingstatechange = function(event) {48 console.log('Signaling state changed to:', pc.signalingState);49 };50 pc.oniceconnectionstatechange = function(event) {51 console.log('ICE connection state changed to:', pc.iceConnectionState);52 };53 pc.onicegatheringstatechange = function(event) {54 console.log('ICE gathering state changed to:', pc.iceGatheringState);55 };56 pc.onconnectionstatechange = function(event) {57 console.log('Connection state changed to:', pc.connectionState);58 };59 pc.ondatachannel = function(event) {60 self.createDataChannel(event.channel);61 };62 this.pc = pc;63 return pc;64 }65 createDataChannel(dc) {66 // Create data channel67 dc = (typeof dc !== 'undefined') ? dc : this.pc.createDataChannel('example-channel', {68 ordered: true69 });70 // Bind data channel events71 dc.onopen = function(event) {72 console.log('Data channel', dc.label, '(', dc.id, ')', 'open');73 // Send 'hello'74 dc.send('Hello from WebRTC on', navigator.userAgent);75 };76 dc.onbufferedamountlow = function(event) {77 console.log('Data channel', dc.label, '(', dc.id, ')', 'buffered amount low');78 };79 dc.onerror = function(event) {80 console.error('Data channel', dc.label, '(', dc.id, ')', 'error:', event);81 };82 dc.onclose = function(event) {83 console.log('Data channel', dc.label, '(', dc.id, ')', 'closed');84 };85 dc.onmessage = function(event) {86 var length = event.data.size || event.data.byteLength || event.data.length;87 console.info('Data channel', dc.label, '(', dc.id, ')', 'message size:', length);88 };89 // Store channel90 this.dc[dc.label] = dc;91 return dc;92 }93 getLocalParameters() {94 return new Promise((resolve, reject) => {95 var error;96 var self = this;97 if (!this.localDescription) {98 error = 'Must create offer/answer';99 console.error(error);100 reject(error);101 return;102 }103 // Initialise parameters104 var parameters = {105 iceParameters: null,106 iceCandidates: [],107 dtlsParameters: null,108 sctpParameters: null,109 };110 // Split sections111 var sections = SDPUtils.splitSections(this.localDescription.sdp);112 var session = sections.shift();113 // Go through media sections114 sections.forEach(function(mediaSection, sdpMLineIndex) {115 // TODO: Ignore anything else but data transports116 // Get mid117 // TODO: This breaks with multiple transceivers118 if (!self.localMid) {119 var mid = SDPUtils.matchPrefix(mediaSection, 'a=mid:');120 if (mid.length > 0) {121 self.localMid = mid[0].substr(6);122 }123 }124 // Get ICE parameters125 if (!parameters.iceParameters) {126 parameters.iceParameters = SDPUtils.getIceParameters(mediaSection, session);127 }128 // Get DTLS parameters129 if (!parameters.dtlsParameters) {130 parameters.dtlsParameters = SDPUtils.getDtlsParameters(mediaSection, session);131 }132 // Get SCTP parameters133 if (!parameters.sctpParameters) {134 parameters.sctpParameters = SDPUtils.getSctpCapabilities(mediaSection, session);135 parameters.sctpParameters.port = SDPUtils.getSctpPort(mediaSection, session);136 }137 });138 // ICE lite parameter139 if (!parameters.iceParameters140 || !parameters.dtlsParameters141 || !parameters.sctpParameters) {142 error = 'Could not retrieve required parameters from local description';143 console.error(error);144 reject(error);145 return;146 }147 parameters.iceParameters.iceLite =148 SDPUtils.matchPrefix(session, 'a=ice-lite').length > 0;149 // Get ICE candidates150 this._waitGatheringComplete.promise.then(() => {151 // Add ICE candidates152 for (var sdpCandidate of self.localCandidates) {153 var candidate = SDPUtils.parseCandidate(sdpCandidate.candidate);154 parameters.iceCandidates.push(candidate);155 }156 // Add ICE candidate complete sentinel157 // parameters.iceCandidates.push({complete: true}); // TODO158 // Done159 resolve(parameters);160 });161 });162 }163 setRemoteParameters(parameters, type, localMid = null) {164 return new Promise((resolve, reject) => {165 if (this.remoteDescription) {166 resolve(this.remoteDescription);167 return;168 }169 if (!this.pc) {170 console.error('Must create RTCPeerConnection instance');171 return;172 }173 if (!localMid) {174 localMid = this.localMid;175 }176 this.remoteParameters = parameters;177 // Translate DTLS role178 // TODO: This somehow didn't make it into SDPUtils179 var setupType;180 switch (parameters.dtlsParameters.role) {181 case 'client':182 setupType = 'active';183 break;184 case 'server':185 setupType = 'passive';186 break;187 default:188 // We map 'offer' to 'controlling' and 'answer' to 'controlled',189 // so rawrtc will take 'server' if offering and 'client' if answering190 // as specified by the ORTC spec191 switch (type) {192 case 'offer':193 // WebRTC requires actpass in offer194 setupType = 'actpass';195 break;196 case 'answer':197 setupType = 'active';198 break;199 }200 break;201 }202 // Write session section203 var sdp = SDPUtils.writeSessionBoilerplate();204 sdp += 'a=group:BUNDLE ' + localMid + '\r\n';205 sdp += 'a=ice-options:trickle\r\n';206 if (parameters.iceParameters.iceLite) {207 sdp += 'a=ice-lite\r\n';208 }209 // Write media section210 // TODO: Replace211 // sdp += 'm=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\n'; // (03)212 sdp += 'm=application 9 DTLS/SCTP ' + parameters.sctpParameters.port + '\r\n'; // (01)213 sdp += 'c=IN IP4 0.0.0.0\r\n';214 sdp += 'a=mid:' + localMid + '\r\n';215 sdp += 'a=sendrecv\r\n';216 // SCTP part217 sdp += SDPUtils.writeSctpCapabilities(parameters.sctpParameters);218 sdp += SDPUtils.writeSctpPort(parameters.sctpParameters.port);219 sdp += 'a=sctpmap:' + parameters.sctpParameters.port + ' webrtc-datachannel 65535\r\n'; // (01)220 // DTLS part221 sdp += SDPUtils.writeDtlsParameters(parameters.dtlsParameters, setupType);222 // ICE part223 sdp += 'a=connection:new\r\n'; // (03)224 sdp += SDPUtils.writeIceParameters(parameters.iceParameters);225 // Done226 console.log('Remote description:\n' + sdp);227 // Set remote description228 this.pc.setRemoteDescription({type: type, sdp: sdp})229 .then(() => {230 console.log('Remote description:\n' + this.pc.remoteDescription.sdp);231 this.remoteDescription = this.pc.remoteDescription;232 // Add ICE candidates233 for (var iceCandidate of parameters.iceCandidates) {234 // Add component which ORTC doesn't have235 // Note: We choose RTP as it doesn't actually matter for us236 iceCandidate.component = 1; // RTP237 // Create238 var candidate = new RTCIceCandidate({239 candidate: SDPUtils.writeCandidate(iceCandidate),240 sdpMLineIndex: 0, // TODO: Fix241 sdpMid: localMid // TODO: Fix242 });243 // Add244 console.log(candidate.candidate);245 this.pc.addIceCandidate(candidate)246 .then(() => {247 console.log('Added remote candidate', candidate);248 });249 }250 // It's trickle ICE, no need to wait for candidates to be added251 resolve();252 })253 .catch((error) => {254 reject(error);255 });256 });257 }258 start() {}259}260class ControllingPeer extends Peer {261 getLocalParameters() {262 return new Promise((resolve, reject) => {263 if (!this.pc) {264 var error = 'Must create RTCPeerConnection instance';265 console.error(error);266 reject(error);267 return;268 }269 var getLocalParameters = () => {270 // Return parameters271 super.getLocalParameters()272 .then((parameters) => {273 this.localParameters = parameters;274 resolve(parameters);275 })276 .catch((error) => {277 reject(error);278 });279 };280 // Create offer281 if (!this.localDescription) {282 this.pc.createOffer()283 .then((description) => {284 return this.pc.setLocalDescription(description);285 })286 .then(() => {287 console.log('Local description:\n' + this.pc.localDescription.sdp);288 this.localDescription = this.pc.localDescription;289 getLocalParameters();290 })291 .catch((error) => {292 reject(error);293 });294 } else {295 getLocalParameters();296 }297 });298 }299 setRemoteParameters(parameters, localMid = null) {300 return super.setRemoteParameters(parameters, 'answer', localMid);301 }302}303class ControlledPeer extends Peer {304 getLocalParameters() {305 return new Promise((resolve, reject) => {306 var error;307 if (!this.pc) {308 error = 'Must create RTCPeerConnection instance';309 console.error(error);310 reject(error);311 return;312 }313 if (!this.remoteDescription) {314 error = 'Must have remote description';315 console.error(error);316 reject(error);317 return;318 }319 var getLocalParameters = () => {320 // Return parameters321 super.getLocalParameters()322 .then((parameters) => {323 resolve(parameters);324 })325 .catch((error) => {326 reject(error);327 });328 };329 // Create answer330 if (!this.localDescription) {331 this.pc.createAnswer()332 .then((description) => {333 return this.pc.setLocalDescription(description);334 })335 .then(() => {336 console.log('Local description:\n' + this.pc.localDescription.sdp);337 this.localDescription = this.pc.localDescription;338 getLocalParameters();339 });340 } else {341 getLocalParameters();342 }343 });344 }345 setRemoteParameters(parameters, localMid = null) {346 return super.setRemoteParameters(parameters, 'offer', localMid);347 }...
Using AI Code Generation
1var wpt = require('webpagetest');2var fs = require('fs');3var util = require('util');4var config = JSON.parse(fs.readFileSync('config.json', 'utf8'));5var wptServer = config.wptServer;6var wptKey = config.wptKey;7var wpt = new WebPageTest(wptServer, wptKey);8var location = 'Dulles:Chrome';9var runs = 1;10var firstViewOnly = true;11var connectivity = 'Cable';12var bwIn = 1000;13var bwOut = 1000;14var latency = 0;15var plr = 0;16var video = false;17var pollResults = 5;18var timeout = 60;19var script = null;20var label = null;21var requests = null;22var login = null;23var password = null;24var fvonly = null;25var notify = null;26var private = null;27var block = null;28var tcpdump = null;29var timeline = null;30var netlog = null;31var trace = null;32var har = null;33var spof = null;34var spofUrl = null;35var spofTimeout = null;36var spofWait = null;37var spofPoll = null;38var spofIgnore = null;39var spofInclude = null;40var spofFull = null;41var spofVideo = null;42var spofVideoFull = null;43var spofVideoFrames = null;44var spofVideoMin = null;45var spofVideoMax = null;46var spofVideoStep = null;47var spofVideoTime = null;48var spofVideoRender = null;49var spofVideoCPU = null;50var spofVideoMem = null;51var spofVideoPower = null;52var spofVideoNetwork = null;53var spofVideoThrottle = null;54var spofVideoThrottleRate = null;55var spofVideoThrottleBurst = null;56var spofVideoThrottleLatency = null;57var spofVideoThrottlePacketLoss = null;58var spofVideoThrottleDownload = null;59var spofVideoThrottleUpload = null;60var spofVideoThrottleClient = null;
Using AI Code Generation
1var wptools = require('wptools');2var wiki = new wptools('Albert Einstein');3wiki.localMid(function(mid) {4 console.log(mid);5});6var wptools = require('wptools');7var wiki = new wptools('Albert Einstein');8wiki.getInfobox(function(info) {9 console.log(info);10});11var wptools = require('wptools');12var wiki = new wptools('Albert Einstein');13wiki.getImages(function(images) {14 console.log(images);15});16var wptools = require('wptools');17var wiki = new wptools('Albert Einstein');18wiki.getCategories(function(categories) {19 console.log(categories);20});21var wptools = require('wptools');22var wiki = new wptools('Albert Einstein');23wiki.getLinks(function(links) {24 console.log(links);25});26var wptools = require('wptools');27var wiki = new wptools('Albert Einstein');28wiki.getReferences(function(references) {29 console.log(references);30});31var wptools = require('wptools');32var wiki = new wptools('Albert Einstein');33wiki.getCoordinates(function(coordinates) {34 console.log(coordinates);35});36var wptools = require('wptools');37var wiki = new wptools('Albert Einstein');38wiki.getExtract(function(extract) {39 console.log(extract);40});
Using AI Code Generation
1var wpt = require('webpagetest');2var test = new wpt('www.webpagetest.org', 'A.6a1d1a0c6b9acff2c1e2a9b7d2b0f8e7');3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 test.getTestStatus(data.data.testId, function(err, data) {8 if (err) {9 console.log(err);10 } else {11 console.log(data);12 }13 });14 }15});
Using AI Code Generation
1var wpt = require('./lib/webpagetest');2var options = {3};4var wpt = new wpt(options);5var parameters = {6};7wpt.runTest(url, parameters, function(err, data) {8 if (err) return console.log(err);9 console.log('Test submitted. Polling for results.');10 wpt.getTestResults(data.data.testId, function(err, data) {11 if (err) return console.log(err);12 console.log('Test completed. View your test at %s', data.data.userUrl);13 });14});
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!!