How to use pixel method in wpt

Best JavaScript code snippet using wpt

canvas-putImageData.js

Source:canvas-putImageData.js Github

copy

Full Screen

1description("This test ensures that putImageData works correctly, the end result should be a 100x100px green square.");2function fillRect(imageData, x, y, width, height, r, g, b, a)3{4 var bytesPerRow = imageData.width * 4;5 var data =imageData.data;6 for (var i = 0; i < height; i++) {7 var rowOrigin = (y+i) * bytesPerRow;8 rowOrigin += x * 4;9 for (var j = 0; j < width; j++) {10 var position = rowOrigin + j * 4;11 data[position + 0] = r;12 data[position + 1] = g;13 data[position + 2] = b;14 data[position + 3] = a;15 }16 }17}18function dataToArray(data) {19 var result = new Array(data.length)20 for (var i = 0; i < data.length; i++)21 result[i] = data[i];22 return result;23}24function getPixel(x, y) {25 var data = context.getImageData(x,y,1,1);26 if (!data) // getImageData failed, which should never happen27 return [-1,-1,-1,-1];28 return dataToArray(data.data);29}30function pixelShouldBe(x, y, colour) {31 shouldBe("getPixel(" + [x, y] +")", "["+colour+"]");32}33var canvas = document.getElementById("canvas");34var context = canvas.getContext("2d");35if (!context.createImageData)36 context.createImageData = function(w,h) { 37 var data = this.getImageData(0, 0, w, h);38 for (var i = 0; i < data.data.length; i++)39 data.data[i] = 0;40 }41var buffer = context.createImageData(100,100);42// Fill top left corner43fillRect(buffer, 0, 0, 50, 50, 0, 128,0,255);44context.putImageData(buffer, 0, 0);45pixelShouldBe( 0, 0, [0, 128,0,255]);46pixelShouldBe(25, 25, [0, 128,0,255]);47pixelShouldBe(49, 0, [0, 128,0,255]);48pixelShouldBe( 0, 49, [0, 128,0,255]);49pixelShouldBe(49, 49, [0, 128,0,255]);50pixelShouldBe(50, 0, [0, 0, 0, 0]);51pixelShouldBe( 0, 50, [0, 0, 0, 0]);52pixelShouldBe(50, 50, [0, 0, 0, 0]);53// Test positioned drawing -- make bottom right green54context.putImageData(buffer, 0, 50);55pixelShouldBe( 0, 50, [0, 128,0,255]);56pixelShouldBe(25, 75, [0, 128,0,255]);57pixelShouldBe(49, 50, [0, 128,0,255]);58pixelShouldBe( 0, 99, [0, 128,0,255]);59pixelShouldBe(49, 99, [0, 128,0,255]);60// Test translation doesn't effect putImageData61context.translate(50, -50);62context.putImageData(buffer, 50, 50);63pixelShouldBe(50, 50, [0, 128,0,255]);64pixelShouldBe(75, 75, [0, 128,0,255]);65pixelShouldBe(99, 99, [0, 128,0,255]);66pixelShouldBe(50, 49, [0, 0, 0, 0]);67context.translate(-50, 50);68// Test dirty rect handling69buffer = context.createImageData(50,50);70fillRect(buffer, 0, 0, 50, 50, 0, 128, 0, 255);71context.putImageData(buffer, 50, 0);72fillRect(buffer, 0, 0, 50, 50, 255, 0, 0, 255);73context.putImageData(buffer, 50, 0, 15, 15, 20, 20);74context.fillStyle="rgb(0,128,0)";75context.fillRect(65, 15, 20, 20);76var points = [0, 5, 15, 25, 35, 45];77for (var x = 0; x < points.length; x++)78 for (var y = 0; y < points.length; y++)79 pixelShouldBe(points[x] + 50, points[y], [0, 128, 0, 255]);80// Test drawing outside the canvas border81fillRect(buffer, 0, 0, 50, 50, 255, 0, 0, 255);82context.putImageData(buffer, -50, 0);83pixelShouldBe(0, 25, [0, 128,0,255]);84context.putImageData(buffer, 100, 0);85pixelShouldBe(99, 25, [0, 128,0,255]);86context.putImageData(buffer, 0, -50);87pixelShouldBe(25, 0, [0, 128,0,255]);88context.putImageData(buffer, 0, 100);89pixelShouldBe(25, 99, [0, 128,0,255]);90// test drawing with non-intersecting dirty rect91context.putImageData(buffer, 50, 0, 50, 0, 100, 100);92context.putImageData(buffer, 50, 0, -50, 0, 50, 100);93context.putImageData(buffer, 50, 0, 0, 50, 100, 100);94context.putImageData(buffer, 50, 0, 50, -50, 100, 100);95for (var x = 0; x < points.length; x++)96 for (var y = 0; y < points.length; y++)97 pixelShouldBe(points[x] + 50, points[y], [0, 128, 0, 255]);98// Test drawing to region intersect edge of canvas99buffer = context.createImageData(100, 100);100fillRect(buffer, 0, 0, 100, 100, 0, 128, 0, 255);101fillRect(buffer, 10, 10, 80, 80, 255, 0, 0, 255);102//left edge103context.putImageData(buffer, -90, 0);104pixelShouldBe(0, 25, [0, 128,0,255]);105pixelShouldBe(0, 50, [0, 128,0,255]);106pixelShouldBe(0, 75, [0, 128,0,255]);107//right edge108context.putImageData(buffer, 90, 0);109pixelShouldBe(99, 25, [0, 128,0,255]);110pixelShouldBe(99, 50, [0, 128,0,255]);111pixelShouldBe(99, 75, [0, 128,0,255]);112//top edge113context.putImageData(buffer, 0, -90);114pixelShouldBe(25, 0, [0, 128,0,255]);115pixelShouldBe(50, 0, [0, 128,0,255]);116pixelShouldBe(75, 0, [0, 128,0,255]);117//bottom edge118context.putImageData(buffer, 0, 90);119pixelShouldBe(25, 99, [0, 128,0,255]);120pixelShouldBe(50, 99, [0, 128,0,255]);121pixelShouldBe(75, 99, [0, 128,0,255]);122// Test drawing with only part of the dirty region intersecting the window123// left edge124context.putImageData(buffer, 0, 0, -90, 0, 100, 100);125pixelShouldBe(0, 25, [0, 128,0,255]);126pixelShouldBe(0, 50, [0, 128,0,255]);127pixelShouldBe(0, 75, [0, 128,0,255]);128pixelShouldBe(10, 25, [0, 128,0,255]);129pixelShouldBe(10, 50, [0, 128,0,255]);130pixelShouldBe(10, 75, [0, 128,0,255]);131//right edge132context.putImageData(buffer, 0, 0, 90, 0, 100, 100);133pixelShouldBe(99, 25, [0, 128,0,255]);134pixelShouldBe(99, 50, [0, 128,0,255]);135pixelShouldBe(99, 75, [0, 128,0,255]);136pixelShouldBe(89, 25, [0, 128,0,255]);137pixelShouldBe(89, 50, [0, 128,0,255]);138pixelShouldBe(89, 75, [0, 128,0,255]);139// top edge140context.putImageData(buffer, 0, 0, 0, -90, 100, 100);141pixelShouldBe(25, 0, [0, 128,0,255]);142pixelShouldBe(50, 0, [0, 128,0,255]);143pixelShouldBe(75, 0, [0, 128,0,255]);144pixelShouldBe(25, 10, [0, 128,0,255]);145pixelShouldBe(50, 10, [0, 128,0,255]);146pixelShouldBe(75, 10, [0, 128,0,255]);147//bottom edge148context.putImageData(buffer, 0, 0, 0, 90, 100, 100);149pixelShouldBe(25, 99, [0, 128,0,255]);150pixelShouldBe(50, 99, [0, 128,0,255]);151pixelShouldBe(75, 99, [0, 128,0,255]);152pixelShouldBe(25, 89, [0, 128,0,255]);153pixelShouldBe(50, 89, [0, 128,0,255]);154pixelShouldBe(75, 89, [0, 128,0,255]);155// Test clamping of dx/dy156var smallbuffer = context.createImageData(10, 10);157fillRect(smallbuffer, 0, 0, 10, 10, 255, 0, 0, 255);158context.putImageData(smallbuffer, 1.5, 1);159pixelShouldBe(11, 11, [0, 128,0,255]);160fillRect(smallbuffer, 0, 0, 10, 10, 0, 128, 0, 255);161context.putImageData(smallbuffer, 1.5, 1);162pixelShouldBe(1, 1, [0, 128,0,255]);163// test clamping of dirtyX/Y/Width/Height164fillRect(smallbuffer, 0, 0, 10, 10, 0, 128, 0, 255);165context.fillStyle = "red";166context.fillRect(1, 1, 9, 9);167context.putImageData(smallbuffer, 1, 1, 0.5, 0.5, 8.5, 8.5);168pixelShouldBe(1, 1, [0, 128,0,255]);169pixelShouldBe(10, 10, [0, 128,0,255]);170context.fillRect(1, 1, 9, 9);171context.putImageData(smallbuffer, 1, 1, 0.25, 0.25, 9, 9);172pixelShouldBe(1, 1, [0, 128,0,255]);173pixelShouldBe(10, 10, [0, 128,0,255]);174context.fillRect(1, 1, 8, 8);175context.putImageData(smallbuffer, 1, 1, 0.0, 0.0, 8.5, 8.5);176pixelShouldBe(1, 1, [0, 128,0,255]);177pixelShouldBe(9, 9, [0, 128,0,255]);178context.fillRect(1, 1, 8, 8);179context.putImageData(smallbuffer, 1, 1, 0.0, 0.0, 8.25, 8.25);180pixelShouldBe(1, 1, [0, 128,0,255]);181pixelShouldBe(9, 9, [0, 128,0,255]);182context.fillRect(1, 1, 7, 7);183context.putImageData(smallbuffer, 1, 1, 0.5, 0.5, 7.9, 7.9);184pixelShouldBe(1, 1, [0, 128,0,255]);185pixelShouldBe(9, 9, [0, 128,0,255]);186shouldThrow("context.putImageData({}, 0, 0)", "'Error: TYPE_MISMATCH_ERR: DOM Exception 17'");187shouldThrow("context.putImageData(buffer, NaN, 0, 0, 0, 0, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");188shouldThrow("context.putImageData(buffer, 0, NaN, 0, 0, 0, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");189shouldThrow("context.putImageData(buffer, 0, 0, NaN, 0, 0, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");190shouldThrow("context.putImageData(buffer, 0, 0, 0, NaN, 0, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");191shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, NaN, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");192shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, 0, NaN)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");193shouldThrow("context.putImageData(buffer, Infinity, 0, 0, 0, 0, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");194shouldThrow("context.putImageData(buffer, 0, Infinity, 0, 0, 0, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");195shouldThrow("context.putImageData(buffer, 0, 0, Infinity, 0, 0, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");196shouldThrow("context.putImageData(buffer, 0, 0, 0, Infinity, 0, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");197shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, Infinity, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");198shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, 0, Infinity)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");199shouldThrow("context.putImageData(buffer, undefined, 0, 0, 0, 0, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");200shouldThrow("context.putImageData(buffer, 0, undefined, 0, 0, 0, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");201shouldThrow("context.putImageData(buffer, 0, 0, undefined, 0, 0, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");202shouldThrow("context.putImageData(buffer, 0, 0, 0, undefined, 0, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");203shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, undefined, 0)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");204shouldThrow("context.putImageData(buffer, 0, 0, 0, 0, 0, undefined)", "'Error: NOT_SUPPORTED_ERR: DOM Exception 9'");205// Ensure we don't mess up bounds clipping checks206var rectcanvas = document.createElement("canvas");207rectcanvas.width = 20;208rectcanvas.height = 10;209var rectbuffer = rectcanvas.getContext("2d");210rectbuffer.putImageData(smallbuffer, 10, 0);211var rectcanvas = document.createElement("canvas");212rectcanvas.width = 10;213rectcanvas.height = 20;214var rectbuffer = rectcanvas.getContext("2d");215rectbuffer.putImageData(smallbuffer, 0, 10);...

Full Screen

Full Screen

shaded-relief.js

Source:shaded-relief.js Github

copy

Full Screen

1// NOCOMPILE2goog.require('ol.Map');3goog.require('ol.View');4goog.require('ol.layer.Image');5goog.require('ol.layer.Tile');6goog.require('ol.source.Raster');7goog.require('ol.source.TileJSON');8goog.require('ol.source.XYZ');9/**10 * Generates a shaded relief image given elevation data. Uses a 3x311 * neighborhood for determining slope and aspect.12 * @param {Array.<ImageData>} inputs Array of input images.13 * @param {Object} data Data added in the "beforeoperations" event.14 * @return {ImageData} Output image.15 */16function shade(inputs, data) {17 var elevationImage = inputs[0];18 var width = elevationImage.width;19 var height = elevationImage.height;20 var elevationData = elevationImage.data;21 var shadeData = new Uint8ClampedArray(elevationData.length);22 var dp = data.resolution * 2;23 var maxX = width - 1;24 var maxY = height - 1;25 var pixel = [0, 0, 0, 0];26 var twoPi = 2 * Math.PI;27 var halfPi = Math.PI / 2;28 var sunEl = Math.PI * data.sunEl / 180;29 var sunAz = Math.PI * data.sunAz / 180;30 var cosSunEl = Math.cos(sunEl);31 var sinSunEl = Math.sin(sunEl);32 var pixelX, pixelY, x0, x1, y0, y1, offset,33 z0, z1, dzdx, dzdy, slope, aspect, cosIncidence, scaled;34 for (pixelY = 0; pixelY <= maxY; ++pixelY) {35 y0 = pixelY === 0 ? 0 : pixelY - 1;36 y1 = pixelY === maxY ? maxY : pixelY + 1;37 for (pixelX = 0; pixelX <= maxX; ++pixelX) {38 x0 = pixelX === 0 ? 0 : pixelX - 1;39 x1 = pixelX === maxX ? maxX : pixelX + 1;40 // determine elevation for (x0, pixelY)41 offset = (pixelY * width + x0) * 4;42 pixel[0] = elevationData[offset];43 pixel[1] = elevationData[offset + 1];44 pixel[2] = elevationData[offset + 2];45 pixel[3] = elevationData[offset + 3];46 z0 = data.vert * (pixel[0] + pixel[1] * 2 + pixel[2] * 3);47 // determine elevation for (x1, pixelY)48 offset = (pixelY * width + x1) * 4;49 pixel[0] = elevationData[offset];50 pixel[1] = elevationData[offset + 1];51 pixel[2] = elevationData[offset + 2];52 pixel[3] = elevationData[offset + 3];53 z1 = data.vert * (pixel[0] + pixel[1] * 2 + pixel[2] * 3);54 dzdx = (z1 - z0) / dp;55 // determine elevation for (pixelX, y0)56 offset = (y0 * width + pixelX) * 4;57 pixel[0] = elevationData[offset];58 pixel[1] = elevationData[offset + 1];59 pixel[2] = elevationData[offset + 2];60 pixel[3] = elevationData[offset + 3];61 z0 = data.vert * (pixel[0] + pixel[1] * 2 + pixel[2] * 3);62 // determine elevation for (pixelX, y1)63 offset = (y1 * width + pixelX) * 4;64 pixel[0] = elevationData[offset];65 pixel[1] = elevationData[offset + 1];66 pixel[2] = elevationData[offset + 2];67 pixel[3] = elevationData[offset + 3];68 z1 = data.vert * (pixel[0] + pixel[1] * 2 + pixel[2] * 3);69 dzdy = (z1 - z0) / dp;70 slope = Math.atan(Math.sqrt(dzdx * dzdx + dzdy * dzdy));71 aspect = Math.atan2(dzdy, -dzdx);72 if (aspect < 0) {73 aspect = halfPi - aspect;74 } else if (aspect > halfPi) {75 aspect = twoPi - aspect + halfPi;76 } else {77 aspect = halfPi - aspect;78 }79 cosIncidence = sinSunEl * Math.cos(slope) +80 cosSunEl * Math.sin(slope) * Math.cos(sunAz - aspect);81 offset = (pixelY * width + pixelX) * 4;82 scaled = 255 * cosIncidence;83 shadeData[offset] = scaled;84 shadeData[offset + 1] = scaled;85 shadeData[offset + 2] = scaled;86 shadeData[offset + 3] = elevationData[offset + 3];87 }88 }89 return new ImageData(shadeData, width, height);90}91var elevation = new ol.source.XYZ({92 url: 'https://{a-d}.tiles.mapbox.com/v3/aj.sf-dem/{z}/{x}/{y}.png',93 crossOrigin: 'anonymous'94});95var raster = new ol.source.Raster({96 sources: [elevation],97 operationType: 'image',98 operation: shade99});100var map = new ol.Map({101 target: 'map',102 layers: [103 new ol.layer.Tile({104 source: new ol.source.TileJSON({105 url: 'http://api.tiles.mapbox.com/v3/tschaub.miapgppd.jsonp'106 })107 }),108 new ol.layer.Image({109 opacity: 0.3,110 source: raster111 })112 ],113 view: new ol.View({114 extent: [-13675026, 4439648, -13580856, 4580292],115 center: [-13615645, 4497969],116 minZoom: 10,117 maxZoom: 16,118 zoom: 13119 })120});121var controlIds = ['vert', 'sunEl', 'sunAz'];122var controls = {};123controlIds.forEach(function(id) {124 var control = document.getElementById(id);125 var output = document.getElementById(id + 'Out');126 control.addEventListener('input', function() {127 output.innerText = control.value;128 raster.changed();129 });130 output.innerText = control.value;131 controls[id] = control;132});133raster.on('beforeoperations', function(event) {134 // the event.data object will be passed to operations135 var data = event.data;136 data.resolution = event.resolution;137 for (var id in controls) {138 data[id] = Number(controls[id].value);139 }...

Full Screen

Full Screen

box.js

Source:box.js Github

copy

Full Screen

1// FIXME add rotation2goog.provide('ol.render.Box');3goog.require('goog.Disposable');4goog.require('goog.asserts');5goog.require('ol.geom.Polygon');6/**7 * @constructor8 * @extends {goog.Disposable}9 * @param {string} className CSS class name.10 */11ol.render.Box = function(className) {12 /**13 * @type {ol.geom.Polygon}14 * @private15 */16 this.geometry_ = null;17 /**18 * @type {HTMLDivElement}19 * @private20 */21 this.element_ = /** @type {HTMLDivElement} */ (document.createElement('div'));22 this.element_.style.position = 'absolute';23 this.element_.className = 'ol-box ' + className;24 /**25 * @private26 * @type {ol.Map}27 */28 this.map_ = null;29 /**30 * @private31 * @type {ol.Pixel}32 */33 this.startPixel_ = null;34 /**35 * @private36 * @type {ol.Pixel}37 */38 this.endPixel_ = null;39};40goog.inherits(ol.render.Box, goog.Disposable);41/**42 * @inheritDoc43 */44ol.render.Box.prototype.disposeInternal = function() {45 this.setMap(null);46 goog.base(this, 'disposeInternal');47};48/**49 * @private50 */51ol.render.Box.prototype.render_ = function() {52 var startPixel = this.startPixel_;53 var endPixel = this.endPixel_;54 goog.asserts.assert(startPixel, 'this.startPixel_ must be truthy');55 goog.asserts.assert(endPixel, 'this.endPixel_ must be truthy');56 var px = 'px';57 var style = this.element_.style;58 style.left = Math.min(startPixel[0], endPixel[0]) + px;59 style.top = Math.min(startPixel[1], endPixel[1]) + px;60 style.width = Math.abs(endPixel[0] - startPixel[0]) + px;61 style.height = Math.abs(endPixel[1] - startPixel[1]) + px;62};63/**64 * @param {ol.Map} map Map.65 */66ol.render.Box.prototype.setMap = function(map) {67 if (this.map_) {68 this.map_.getOverlayContainer().removeChild(this.element_);69 var style = this.element_.style;70 style.left = style.top = style.width = style.height = 'inherit';71 }72 this.map_ = map;73 if (this.map_) {74 this.map_.getOverlayContainer().appendChild(this.element_);75 }76};77/**78 * @param {ol.Pixel} startPixel Start pixel.79 * @param {ol.Pixel} endPixel End pixel.80 */81ol.render.Box.prototype.setPixels = function(startPixel, endPixel) {82 this.startPixel_ = startPixel;83 this.endPixel_ = endPixel;84 this.createOrUpdateGeometry();85 this.render_();86};87/**88 * Creates or updates the cached geometry.89 */90ol.render.Box.prototype.createOrUpdateGeometry = function() {91 goog.asserts.assert(this.startPixel_,92 'this.startPixel_ must be truthy');93 goog.asserts.assert(this.endPixel_,94 'this.endPixel_ must be truthy');95 goog.asserts.assert(this.map_, 'this.map_ must be truthy');96 var startPixel = this.startPixel_;97 var endPixel = this.endPixel_;98 var pixels = [99 startPixel,100 [startPixel[0], endPixel[1]],101 endPixel,102 [endPixel[0], startPixel[1]]103 ];104 var coordinates = pixels.map(this.map_.getCoordinateFromPixel, this.map_);105 // close the polygon106 coordinates[4] = coordinates[0].slice();107 if (!this.geometry_) {108 this.geometry_ = new ol.geom.Polygon([coordinates]);109 } else {110 this.geometry_.setCoordinates([coordinates]);111 }112};113/**114 * @return {ol.geom.Polygon} Geometry.115 */116ol.render.Box.prototype.getGeometry = function() {117 return this.geometry_;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./lib/webpagetest');2var fs = require('fs');3var util = require('util');4var wpt = new WebPageTest('www.webpagetest.org');5var options = {runs: 1, location: 'Dulles_MotoG', connectivity: '3G'};6var testId;7var testResults;8wpt.runTest(url, options, function(err, data) {9 if (err) return console.error(err);10 console.log(data);11 testId = data.data.testId;

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2wpt = new wpt('APIKEY');3wpt.getLocations(function(err, locations) {4 if (!err) {5 console.log(locations);6 }7});8 if (!err) {9 console.log(data);10 }11});12}, function(err, data) {13 if (!err) {14 console.log(data);15 }16});17}, function(err, data) {18 if (!err) {19 console.log(data);20 }21});22wpt.getTestStatus('140309_2Y_2', function(err, data) {23 if (!err) {24 console.log(data);25 }26});27wpt.getTestResults('140309_2Y_2', function(err, data) {28 if (!err) {29 console.log(data);30 }31});32wpt.getTestResults('140309_2Y_2', {33}, function(err, data) {34 if (!err) {35 console.log(data);36 }37});38wpt.getTestResults('140309_2Y_2', {39}, function(err, data) {40 if (!err) {41 console.log(data);42 }43});44wpt.getTestResults('140309_2Y_2

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var options = {3};4var wpt = new WebPageTest('www.webpagetest.org', 'A.9a0d8c7a8a2a2a1d0f2e2c2d2e2a2a2a2');5wpt.runTest(testUrl, {6}, function(err, data) {7 if (err) return console.error(err);8 console.log('Test submitted. Polling for results...');9 wpt.getTestResults(data.data.testId, function(err, data) {10 if (err) return console.error(err);11 console.log('Got results for %s', data.data.testUrl);12 console.log('First View (ms): %d', data.data.average.firstView.loadTime);13 console.log('Repeat View (ms): %d', data.data.average.repeatView.loadTime);14 });15});16var wpt = require('webpagetest');17var options = {18};19var wpt = new WebPageTest('www.webpagetest.org', 'A.9a0d8c7a8a2a2a1d0f2e2c2d2e2a2a2a2');20wpt.runTest(testUrl, {21}, function(err, data) {22 if (err)

Full Screen

Automation Testing Tutorials

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

LambdaTest Learning Hubs:

YouTube

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

Run wpt 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