How to use selection method in wpt

Best JavaScript code snippet using wpt

selection_test.js

Source:selection_test.js Github

copy

Full Screen

1/* ***** BEGIN LICENSE BLOCK *****2 * Distributed under the BSD license:3 *4 * Copyright (c) 2010, Ajax.org B.V.5 * All rights reserved.6 * 7 * Redistribution and use in source and binary forms, with or without8 * modification, are permitted provided that the following conditions are met:9 * * Redistributions of source code must retain the above copyright10 * notice, this list of conditions and the following disclaimer.11 * * Redistributions in binary form must reproduce the above copyright12 * notice, this list of conditions and the following disclaimer in the13 * documentation and/or other materials provided with the distribution.14 * * Neither the name of Ajax.org B.V. nor the15 * names of its contributors may be used to endorse or promote products16 * derived from this software without specific prior written permission.17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE21 * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.28 *29 * ***** END LICENSE BLOCK ***** */30if (typeof process !== "undefined") {31 require("amd-loader");32}33define(function(require, exports, module) {34"use strict";35var EditSession = require("./edit_session").EditSession;36var assert = require("./test/assertions");37module.exports = {38 createSession : function(rows, cols) {39 var line = new Array(cols + 1).join("a");40 var text = new Array(rows).join(line + "\n") + line;41 return new EditSession(text);42 },43 "test: move cursor to end of file should place the cursor on last row and column" : function() {44 var session = this.createSession(200, 10);45 var selection = session.getSelection();46 selection.moveCursorFileEnd();47 assert.position(selection.getCursor(), 199, 10);48 },49 "test: moveCursor to start of file should place the cursor on the first row and column" : function() {50 var session = this.createSession(200, 10);51 var selection = session.getSelection();52 selection.moveCursorFileStart();53 assert.position(selection.getCursor(), 0, 0);54 },55 "test: move selection lead to end of file" : function() {56 var session = this.createSession(200, 10);57 var selection = session.getSelection();58 selection.moveCursorTo(100, 5);59 selection.selectFileEnd();60 var range = selection.getRange();61 assert.position(range.start, 100, 5);62 assert.position(range.end, 199, 10);63 },64 "test: move selection lead to start of file" : function() {65 var session = this.createSession(200, 10);66 var selection = session.getSelection();67 selection.moveCursorTo(100, 5);68 selection.selectFileStart();69 var range = selection.getRange();70 assert.position(range.start, 0, 0);71 assert.position(range.end, 100, 5);72 },73 "test: move cursor word right" : function() {74 var session = new EditSession([75 "ab",76 " Juhu Kinners (abc, 12)",77 " cde"78 ].join("\n"));79 80 var selection = session.getSelection();81 session.$selectLongWords = true;82 selection.moveCursorDown();83 assert.position(selection.getCursor(), 1, 0);84 selection.moveCursorWordRight();85 assert.position(selection.getCursor(), 1, 5);86 selection.moveCursorWordRight();87 assert.position(selection.getCursor(), 1, 13);88 selection.moveCursorWordRight();89 assert.position(selection.getCursor(), 1, 18);90 selection.moveCursorWordRight();91 assert.position(selection.getCursor(), 1, 22);92 // wrap line93 selection.moveCursorWordRight();94 assert.position(selection.getCursor(), 2, 4);95 96 selection.moveCursorWordRight();97 assert.position(selection.getCursor(), 2, 4);98 },99 "test: select word right if cursor in word" : function() {100 var session = new EditSession("Juhu Kinners");101 var selection = session.getSelection();102 selection.moveCursorTo(0, 2);103 selection.moveCursorWordRight();104 assert.position(selection.getCursor(), 0, 4);105 },106 "test: moveCursor word left" : function() {107 var session = new EditSession([108 "ab",109 " Juhu Kinners (abc, 12)",110 " cde"111 ].join("\n"));112 var selection = session.getSelection();113 session.$selectLongWords = true;114 selection.moveCursorDown();115 selection.moveCursorLineEnd();116 assert.position(selection.getCursor(), 1, 23);117 selection.moveCursorWordLeft();118 assert.position(selection.getCursor(), 1, 20);119 selection.moveCursorWordLeft();120 assert.position(selection.getCursor(), 1, 15);121 selection.moveCursorWordLeft();122 assert.position(selection.getCursor(), 1, 6);123 selection.moveCursorWordLeft();124 assert.position(selection.getCursor(), 1, 1);125 // wrap line126 selection.moveCursorWordLeft();127 assert.position(selection.getCursor(), 0, 0);128 selection.moveCursorWordLeft();129 assert.position(selection.getCursor(), 0, 0);130 },131 "test: moveCursor word left with umlauts" : function() {132 var session = new EditSession(" Fuß Füße");133 session.$selectLongWords = true;134 var selection = session.getSelection();135 selection.moveCursorTo(0, 9)136 selection.moveCursorWordLeft();137 assert.position(selection.getCursor(), 0, 5);138 selection.moveCursorWordLeft();139 assert.position(selection.getCursor(), 0, 1);140 },141 "test: select word left if cursor in word" : function() {142 var session = new EditSession("Juhu Kinners");143 var selection = session.getSelection();144 session.$selectLongWords = true;145 selection.moveCursorTo(0, 8);146 selection.moveCursorWordLeft();147 assert.position(selection.getCursor(), 0, 5);148 },149 "test: select word right and select" : function() {150 var session = new EditSession("Juhu Kinners");151 var selection = session.getSelection();152 selection.moveCursorTo(0, 0);153 selection.selectWordRight();154 var range = selection.getRange();155 assert.position(range.start, 0, 0);156 assert.position(range.end, 0, 4);157 },158 "test: select word left and select" : function() {159 var session = new EditSession("Juhu Kinners");160 var selection = session.getSelection();161 selection.moveCursorTo(0, 3);162 selection.selectWordLeft();163 var range = selection.getRange();164 assert.position(range.start, 0, 0);165 assert.position(range.end, 0, 3);166 },167 "test: select word with cursor in word should select the word" : function() {168 var session = new EditSession("Juhu Kinners 123");169 var selection = session.getSelection();170 selection.moveCursorTo(0, 8);171 selection.selectWord();172 var range = selection.getRange();173 assert.position(range.start, 0, 5);174 assert.position(range.end, 0, 12);175 },176 "test: select word with cursor in word including right whitespace should select the word" : function() {177 var session = new EditSession("Juhu Kinners 123");178 var selection = session.getSelection();179 selection.moveCursorTo(0, 8);180 selection.selectAWord();181 var range = selection.getRange();182 assert.position(range.start, 0, 5);183 assert.position(range.end, 0, 18);184 },185 "test: select word with cursor betwen white space and word should select the word" : function() {186 var session = new EditSession("Juhu Kinners");187 var selection = session.getSelection();188 session.$selectLongWords = true;189 selection.moveCursorTo(0, 4);190 selection.selectWord();191 var range = selection.getRange();192 assert.position(range.start, 0, 0);193 assert.position(range.end, 0, 4);194 selection.moveCursorTo(0, 5);195 selection.selectWord();196 var range = selection.getRange();197 assert.position(range.start, 0, 5);198 assert.position(range.end, 0, 12);199 },200 "test: select word with cursor in white space should select white space" : function() {201 var session = new EditSession("Juhu Kinners");202 var selection = session.getSelection();203 session.$selectLongWords = true;204 selection.moveCursorTo(0, 5);205 selection.selectWord();206 var range = selection.getRange();207 assert.position(range.start, 0, 4);208 assert.position(range.end, 0, 6);209 },210 "test: moving cursor should fire a 'changeCursor' event" : function() {211 var session = new EditSession("Juhu Kinners");212 var selection = session.getSelection();213 session.$selectLongWords = true;214 selection.moveCursorTo(0, 5);215 var called = false;216 selection.addEventListener("changeCursor", function() {217 called = true;218 });219 selection.moveCursorTo(0, 6);220 assert.ok(called);221 },222 "test: calling setCursor with the same position should not fire an event": function() {223 var session = new EditSession("Juhu Kinners");224 var selection = session.getSelection();225 session.$selectLongWords = true;226 selection.moveCursorTo(0, 5);227 var called = false;228 selection.addEventListener("changeCursor", function() {229 called = true;230 });231 selection.moveCursorTo(0, 5);232 assert.notOk(called);233 },234 "test: moveWordright should move past || and [": function() {235 var session = new EditSession("||foo[");236 var selection = session.getSelection();237 session.$selectLongWords = true;238 // Move behind ||foo239 selection.moveCursorWordRight();240 assert.position(selection.getCursor(), 0, 5);241 // Move behind [242 selection.moveCursorWordRight();243 assert.position(selection.getCursor(), 0, 6);244 },245 "test: moveWordLeft should move past || and [": function() {246 var session = new EditSession("||foo[");247 var selection = session.getSelection();248 session.$selectLongWords = true;249 selection.moveCursorTo(0, 6);250 // Move behind [foo251 selection.moveCursorWordLeft();252 assert.position(selection.getCursor(), 0, 2);253 // Move behind ||254 selection.moveCursorWordLeft();255 assert.position(selection.getCursor(), 0, 0);256 },257 "test: move cursor to line start should move cursor to end of the indentation first": function() {258 var session = new EditSession("12\n Juhu\n12");259 var selection = session.getSelection();260 selection.moveCursorTo(1, 6);261 selection.moveCursorLineStart();262 assert.position(selection.getCursor(), 1, 4);263 },264 "test: move cursor to line start when the cursor is at the end of the indentation should move cursor to column 0": function() {265 var session = new EditSession("12\n Juhu\n12");266 var selection = session.getSelection();267 selection.moveCursorTo(1, 4);268 selection.moveCursorLineStart();269 assert.position(selection.getCursor(), 1, 0);270 },271 "test: move cursor to line start when the cursor is at column 0 should move cursor to the end of the indentation": function() {272 var session = new EditSession("12\n Juhu\n12");273 var selection = session.getSelection();274 selection.moveCursorTo(1, 0);275 selection.moveCursorLineStart();276 assert.position(selection.getCursor(), 1, 4);277 },278 // Eclipse style279 "test: move cursor to line start when the cursor is before the initial indentation should move cursor to the end of the indentation": function() {280 var session = new EditSession("12\n Juhu\n12");281 var selection = session.getSelection();282 selection.moveCursorTo(1, 2);283 selection.moveCursorLineStart();284 assert.position(selection.getCursor(), 1, 4);285 },286 "test go line up when in the middle of the first line should go to document start": function() {287 var session = new EditSession("juhu kinners");288 var selection = session.getSelection();289 selection.moveCursorTo(0, 4);290 selection.moveCursorUp();291 assert.position(selection.getCursor(), 0, 0);292 },293 "test: (wrap) go line up when in the middle of the first line should go to document start": function() {294 var session = new EditSession("juhu kinners");295 session.setWrapLimitRange(5, 5);296 session.adjustWrapLimit(80);297 var selection = session.getSelection();298 selection.moveCursorTo(0, 4);299 selection.moveCursorUp();300 assert.position(selection.getCursor(), 0, 0);301 },302 "test go line down when in the middle of the last line should go to document end": function() {303 var session = new EditSession("juhu kinners");304 var selection = session.getSelection();305 selection.moveCursorTo(0, 4);306 selection.moveCursorDown();307 assert.position(selection.getCursor(), 0, 12);308 },309 "test (wrap) go line down when in the middle of the last line should go to document end": function() {310 var session = new EditSession("juhu kinners");311 session.setWrapLimitRange(8, 8);312 session.adjustWrapLimit(80);313 var selection = session.getSelection();314 selection.moveCursorTo(0, 10);315 selection.moveCursorDown();316 assert.position(selection.getCursor(), 0, 12);317 },318 "test go line up twice and then once down when in the second should go back to the previous column": function() {319 var session = new EditSession("juhu\nkinners");320 var selection = session.getSelection();321 selection.moveCursorTo(1, 4);322 selection.moveCursorUp();323 selection.moveCursorUp();324 selection.moveCursorDown();325 assert.position(selection.getCursor(), 1, 4);326 },327 "test (keyboard navigation) when curLine is not EOL and targetLine is all whitespace new column should be current column": function() {328 var session = new EditSession("function (a) {\n \n}");329 var selection = session.getSelection();330 selection.moveCursorTo(2, 0);331 selection.moveCursorUp();332 assert.position(selection.getCursor(), 1, 0);333 },334 "test (keyboard navigation) when curLine is EOL and targetLine is shorter than current column, new column should be targetLine's EOL": function() {335 var session = new EditSession("function (a) {\n \n}");336 var selection = session.getSelection();337 selection.moveCursorTo(0, 14);338 selection.moveCursorDown();339 assert.position(selection.getCursor(), 1, 4);340 },341 "test fromJSON/toJSON": function() {342 var session = new EditSession("function (a) {\n \n}");343 var selection = session.getSelection();344 selection.moveCursorTo(0, 14);345 selection.moveCursorDown();346 assert.position(selection.getCursor(), 1, 4);347 var data = selection.toJSON();348 data = JSON.parse(JSON.stringify(data))349 selection.moveCursorDown(); 350 assert.position(selection.getCursor(), 2, 1);351 352 assert.ok(!selection.isEqual(data));353 354 selection.fromJSON(data);355 assert.position(selection.getCursor(), 1, 4);356 assert.ok(selection.isEqual(data));357 }358};359});360if (typeof module !== "undefined" && module === require.main) {361 require("asyncjs").test.testcase(module.exports).exec()...

Full Screen

Full Screen

selection.js

Source:selection.js Github

copy

Full Screen

1/** 2 * Selection Handles Plugin3 *4 *5 * Options6 * show - True enables the handles plugin.7 * drag - Left and Right drag handles8 * scroll - Scrolling handle9 */10(function () {11function isLeftClick (e, type) {12 return (e.which ? (e.which === 1) : (e.button === 0 || e.button === 1));13}14function boundX(x, graph) {15 return Math.min(Math.max(0, x), graph.plotWidth - 1);16}17function boundY(y, graph) {18 return Math.min(Math.max(0, y), graph.plotHeight);19}20var21 D = Flotr.DOM,22 E = Flotr.EventAdapter,23 _ = Flotr._;24Flotr.addPlugin('selection', {25 options: {26 pinchOnly: null, // Only select on pinch27 mode: null, // => one of null, 'x', 'y' or 'xy'28 color: '#B6D9FF', // => selection box color29 fps: 20 // => frames-per-second30 },31 callbacks: {32 'flotr:mouseup' : function (event) {33 var34 options = this.options.selection,35 selection = this.selection,36 pointer = this.getEventPosition(event);37 if (!options || !options.mode) return;38 if (selection.interval) clearInterval(selection.interval);39 if (this.multitouches) {40 selection.updateSelection();41 } else42 if (!options.pinchOnly) {43 selection.setSelectionPos(selection.selection.second, pointer);44 }45 selection.clearSelection();46 if(selection.selecting && selection.selectionIsSane()){47 selection.drawSelection();48 selection.fireSelectEvent();49 this.ignoreClick = true;50 }51 },52 'flotr:mousedown' : function (event) {53 var54 options = this.options.selection,55 selection = this.selection,56 pointer = this.getEventPosition(event);57 if (!options || !options.mode) return;58 if (!options.mode || (!isLeftClick(event) && _.isUndefined(event.touches))) return;59 if (!options.pinchOnly) selection.setSelectionPos(selection.selection.first, pointer);60 if (selection.interval) clearInterval(selection.interval);61 this.lastMousePos.pageX = null;62 selection.selecting = false;63 selection.interval = setInterval(64 _.bind(selection.updateSelection, this),65 1000 / options.fps66 );67 },68 'flotr:destroy' : function (event) {69 clearInterval(this.selection.interval);70 }71 },72 // TODO This isn't used. Maybe it belongs in the draw area and fire select event methods?73 getArea: function() {74 var s = this.selection.selection,75 first = s.first,76 second = s.second;77 return {78 x1: Math.min(first.x, second.x),79 x2: Math.max(first.x, second.x),80 y1: Math.min(first.y, second.y),81 y2: Math.max(first.y, second.y)82 };83 },84 selection: {first: {x: -1, y: -1}, second: {x: -1, y: -1}},85 prevSelection: null,86 interval: null,87 /**88 * Fires the 'flotr:select' event when the user made a selection.89 */90 fireSelectEvent: function(name){91 var a = this.axes,92 s = this.selection.selection,93 x1, x2, y1, y2;94 name = name || 'select';95 x1 = a.x.p2d(s.first.x);96 x2 = a.x.p2d(s.second.x);97 y1 = a.y.p2d(s.first.y);98 y2 = a.y.p2d(s.second.y);99 E.fire(this.el, 'flotr:'+name, [{100 x1:Math.min(x1, x2), 101 y1:Math.min(y1, y2), 102 x2:Math.max(x1, x2), 103 y2:Math.max(y1, y2),104 xfirst:x1, xsecond:x2, yfirst:y1, ysecond:y2105 }, this]);106 },107 /**108 * Allows the user the manually select an area.109 * @param {Object} area - Object with coordinates to select.110 */111 setSelection: function(area, preventEvent){112 var options = this.options,113 xa = this.axes.x,114 ya = this.axes.y,115 vertScale = ya.scale,116 hozScale = xa.scale,117 selX = options.selection.mode.indexOf('x') != -1,118 selY = options.selection.mode.indexOf('y') != -1,119 s = this.selection.selection;120 121 this.selection.clearSelection();122 s.first.y = boundY((selX && !selY) ? 0 : (ya.max - area.y1) * vertScale, this);123 s.second.y = boundY((selX && !selY) ? this.plotHeight - 1: (ya.max - area.y2) * vertScale, this);124 s.first.x = boundX((selY && !selX) ? 0 : area.x1, this);125 s.second.x = boundX((selY && !selX) ? this.plotWidth : area.x2, this);126 127 this.selection.drawSelection();128 if (!preventEvent)129 this.selection.fireSelectEvent();130 },131 /**132 * Calculates the position of the selection.133 * @param {Object} pos - Position object.134 * @param {Event} event - Event object.135 */136 setSelectionPos: function(pos, pointer) {137 var mode = this.options.selection.mode,138 selection = this.selection.selection;139 if(mode.indexOf('x') == -1) {140 pos.x = (pos == selection.first) ? 0 : this.plotWidth; 141 }else{142 pos.x = boundX(pointer.relX, this);143 }144 if (mode.indexOf('y') == -1) {145 pos.y = (pos == selection.first) ? 0 : this.plotHeight - 1;146 }else{147 pos.y = boundY(pointer.relY, this);148 }149 },150 /**151 * Draws the selection box.152 */153 drawSelection: function() {154 this.selection.fireSelectEvent('selecting');155 var s = this.selection.selection,156 octx = this.octx,157 options = this.options,158 plotOffset = this.plotOffset,159 prevSelection = this.selection.prevSelection;160 161 if (prevSelection &&162 s.first.x == prevSelection.first.x &&163 s.first.y == prevSelection.first.y && 164 s.second.x == prevSelection.second.x &&165 s.second.y == prevSelection.second.y) {166 return;167 }168 octx.save();169 octx.strokeStyle = this.processColor(options.selection.color, {opacity: 0.8});170 octx.lineWidth = 1;171 octx.lineJoin = 'miter';172 octx.fillStyle = this.processColor(options.selection.color, {opacity: 0.4});173 this.selection.prevSelection = {174 first: { x: s.first.x, y: s.first.y },175 second: { x: s.second.x, y: s.second.y }176 };177 var x = Math.min(s.first.x, s.second.x),178 y = Math.min(s.first.y, s.second.y),179 w = Math.abs(s.second.x - s.first.x),180 h = Math.abs(s.second.y - s.first.y);181 octx.fillRect(x + plotOffset.left+0.5, y + plotOffset.top+0.5, w, h);182 octx.strokeRect(x + plotOffset.left+0.5, y + plotOffset.top+0.5, w, h);183 octx.restore();184 },185 /**186 * Updates (draws) the selection box.187 */188 updateSelection: function(){189 if (!this.lastMousePos.pageX) return;190 this.selection.selecting = true;191 if (this.multitouches) {192 this.selection.setSelectionPos(this.selection.selection.first, this.getEventPosition(this.multitouches[0]));193 this.selection.setSelectionPos(this.selection.selection.second, this.getEventPosition(this.multitouches[1]));194 } else195 if (this.options.selection.pinchOnly) {196 return;197 } else {198 this.selection.setSelectionPos(this.selection.selection.second, this.lastMousePos);199 }200 this.selection.clearSelection();201 202 if(this.selection.selectionIsSane()) {203 this.selection.drawSelection();204 }205 },206 /**207 * Removes the selection box from the overlay canvas.208 */209 clearSelection: function() {210 if (!this.selection.prevSelection) return;211 212 var prevSelection = this.selection.prevSelection,213 lw = 1,214 plotOffset = this.plotOffset,215 x = Math.min(prevSelection.first.x, prevSelection.second.x),216 y = Math.min(prevSelection.first.y, prevSelection.second.y),217 w = Math.abs(prevSelection.second.x - prevSelection.first.x),218 h = Math.abs(prevSelection.second.y - prevSelection.first.y);219 220 this.octx.clearRect(x + plotOffset.left - lw + 0.5,221 y + plotOffset.top - lw,222 w + 2 * lw + 0.5,223 h + 2 * lw + 0.5);224 225 this.selection.prevSelection = null;226 },227 /**228 * Determines whether or not the selection is sane and should be drawn.229 * @return {Boolean} - True when sane, false otherwise.230 */231 selectionIsSane: function(){232 var s = this.selection.selection;233 return Math.abs(s.second.x - s.first.x) >= 5 || 234 Math.abs(s.second.y - s.first.y) >= 5;235 }236});...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var client = wpt('www.webpagetest.org');3 if (err) return console.error(err);4 console.log(data.data.userUrl);5 console.log(data.data.summary);6 console.log(data.data.median.firstView.TTFB);7 console.log(data.data.median.firstView.fullyLoaded);8 console.log(data.data.median.firstView.SpeedIndex);9 console.log(data.data.median.firstView.render);10 console.log(data.data.median.firstView.lastVisualChange);11 console.log(data.data.median.firstView.visualComplete85);12 console.log(data.data.median.firstView.visualComplete95);13 console.log(data.data.median.firstView.visualComplete99);14 console.log(data.data.median.firstView.SpeedIndex);

Full Screen

Using AI Code Generation

copy

Full Screen

1var WebPageTest = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'A.6b7e6e1f6f7d0d8e61b07c6b9f9d4f6e');3 console.log(data);4});5var WebPageTest = require('webpagetest');6var wpt = new WebPageTest('www.webpagetest.org', 'A.6b7e6e1f6f7d0d8e61b07c6

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptdriver = require('wptdriver');2wptdriver.selection('test', function(err, data) {3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 }8});9### wptdriver.selections(callback)10* `callback` - callback function with signature `function(err, data)`11var wptdriver = require('wptdriver');12wptdriver.selections(function(err, data) {13 if (err) {14 console.log(err);15 } else {16 console.log(data);17 }18});19### wptdriver.status(callback)20* `callback` - callback function with signature `function(err, data)`21var wptdriver = require('wptdriver');22wptdriver.status(function(err, data) {23 if (err) {24 console.log(err);25 } else {26 console.log(data);27 }28});29### wptdriver.test(options, callback)30 * `runs` - number of runs (optional)31 * `timeout` - test timeout in seconds (optional)32 * `pollResults` - poll results flag (optional)33 * `pollResultsInterval` - poll results interval in seconds (optional)34 * `fvonly` - first view only flag (optional)35 * `script` - script to run (optional)36 * `scriptParameters` - script parameters (optional)37 * `browser` - browser to use (optional)38 * `browserVersion` - browser version to use (optional)39 * `private` - private test flag (optional)40 * `block` - block traffic flag (optional)41 * `blockAds` - block ads flag (optional)42 * `blockThirdParty` - block third party flag (optional)43 * `blockVideo` - block video flag (optional)

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptdriver = require('wptdriver');2wptdriver.selection('test', function(err, data) {3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 }8});9### wptdriver.selections(callback)10* `callback` - callback function with signature `function(err, data)`11var wptdriver = require('wptdriver');12wptdriver.selections(function(err, data) {13 if (err) {14 console.log(err);15 } else {16 console.log(data);17 }18});19### wptdriver.status(callback)20* `callback` - callback function with signature `function(err, data)`21var wptdriver = require('wptdriver');22wptdriver.status(function(err, data) {23 if (err) {24 console.log(err);25 } else {26 console.log(data);27 }28});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var options = {3};4var webPageTest = new wpt(options);5webPageTest.runTest(url, function(err, data) {6 if (err) return console.error(err);7 console.log('Test status:', data.statusText);8 if (data.statusCode === 200) {9 var testId = data.data.testId;10 console.log('Test ID:', testId);11 webPageTest.getTestResults(testId, function(err, data) {12 if (err) return console.error(err);13 console.log('Test results:', data);14 });15 }16});17### wptdriver.test(options, callback)18 * `runs` - number of runs (optional)19 * `timeout` - test timeout in seconds (optional)20 * `pollResults` - poll results flag (optional)21 * `pollResultsInterval` - poll results interval in seconds (optional)22 * `fvonly` - first view only flag (optional)23 * `script` - script to run (optional)24 * `scriptParameters` - script parameters (optional)25 * `browser` - browser to use (optional)26 * `browserVersion` - browser version to use (optional)27 * `private` - private test flag (optional)28 * `block` - block traffic flag (optional)29 * `blockAds` - block ads flag (optional)30 * `blockThirdParty` - block third party flag (optional)31 * `blockVideo` - block video flag (optional)

Full Screen

Using AI Code Generation

copy

Full Screen

1var page = require('webpage').create(),2 system = require('system'),3 address;4if (system.args.length === 1) {5 console.log('Usage: test.js <some URL>');6 phantom.exit(1);7} else {8 address = system.args[1];9 page.open(address, function (status) {10 if (status !== 'success') {11 console.log('FAIL to load the address');12 } else {13 var title = page.evaluate(function () {14 return document.title;15 });16 console.log('Page title is ' + title);17 }18 phantom.exit();19 });20}

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var options = {3};4var webPageTest = new wpt(options);5webPageTest.runTest(url, function(err, data) {6 if (err) return console.error(err);7 console.log('Test status:', data.statusText);8 if (data.statusCode === 200) {9 var testId = data.data.testId;10 console.log('Test ID:', testId);11 webPageTest.getTestResults(testId, function(err, data) {12 if (err) return console.error(err);13 console.log('Test results:', data);14 });15 }16});

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