How to use ManualUI method in wpt

Best JavaScript code snippet using wpt

runner.js

Source:runner.js Github

copy

Full Screen

...260 this.meter.setAttribute("aria-valuemax", total);261 this.meter.textContent = this.meter.style.width = (progress * 100).toFixed(1) + "%";262 }263};264function ManualUI(elem, runner) {265 this.elem = elem;266 this.runner = runner;267 this.pass_button = this.elem.querySelector("button.pass");268 this.fail_button = this.elem.querySelector("button.fail");269 this.ref_buttons = this.elem.querySelector(".reftestUI");270 this.ref_type = this.ref_buttons.querySelector(".refType");271 this.test_button = this.ref_buttons.querySelector("button.test");272 this.ref_button = this.ref_buttons.querySelector("button.ref");273 this.hide();274 this.runner.test_start_callbacks.push(this.on_test_start.bind(this));275 this.runner.test_pause_callbacks.push(this.hide.bind(this));276 this.runner.done_callbacks.push(this.on_done.bind(this));277 this.pass_button.onclick = function() {278 this.disable_buttons();279 this.runner.on_result("PASS", "", []);280 }.bind(this);281 this.fail_button.onclick = function() {282 this.disable_buttons();283 this.runner.on_result("FAIL", "", []);284 }.bind(this);285}286ManualUI.prototype = {287 show: function() {288 this.elem.style.display = "block";289 setTimeout(this.enable_buttons.bind(this), 200);290 },291 hide: function() {292 this.elem.style.display = "none";293 },294 show_ref: function() {295 this.ref_buttons.style.display = "block";296 this.test_button.onclick = function() {297 this.runner.load(this.runner.current_test.url);298 }.bind(this);299 this.ref_button.onclick = function() {300 this.runner.load(this.runner.current_test.ref_url);301 }.bind(this);302 },303 hide_ref: function() {304 this.ref_buttons.style.display = "none";305 },306 disable_buttons: function() {307 this.pass_button.disabled = true;308 this.fail_button.disabled = true;309 },310 enable_buttons: function() {311 this.pass_button.disabled = false;312 this.fail_button.disabled = false;313 },314 on_test_start: function(test) {315 if (test.type == "manual" || test.type == "reftest") {316 this.show();317 } else {318 this.hide();319 }320 if (test.type == "reftest") {321 this.show_ref();322 this.ref_type.textContent = test.ref_type === "==" ? "equal" : "unequal";323 } else {324 this.hide_ref();325 }326 },327 on_done: function() {328 this.hide();329 }330};331function TestControl(elem, runner) {332 this.elem = elem;333 this.path_input = this.elem.querySelector(".path");334 this.pause_button = this.elem.querySelector("button.togglePause");335 this.start_button = this.elem.querySelector("button.toggleStart");336 this.type_checkboxes = Array.prototype.slice.call(337 this.elem.querySelectorAll("input[type=checkbox].test-type"));338 this.type_checkboxes.forEach(function(elem) {339 elem.addEventListener("click", function() {340 this.start_button.disabled = this.get_test_types().length < 1;341 }.bind(this),342 false);343 }.bind(this));344 this.timeout_input = this.elem.querySelector(".timeout_multiplier");345 this.render_checkbox = this.elem.querySelector(".render");346 this.runner = runner;347 this.runner.done_callbacks.push(this.on_done.bind(this));348 this.set_start();349}350TestControl.prototype = {351 set_start: function() {352 this.start_button.disabled = this.get_test_types().length < 1;353 this.pause_button.disabled = true;354 this.start_button.textContent = "Start";355 this.path_input.disabled = false;356 this.type_checkboxes.forEach(function(elem) {357 elem.disabled = false;358 });359 this.start_button.onclick = function() {360 var path = this.get_path();361 var test_types = this.get_test_types();362 var settings = this.get_testharness_settings();363 this.runner.start(path, test_types, settings);364 this.set_stop();365 this.set_pause();366 }.bind(this);367 },368 set_stop: function() {369 clearTimeout(this.runner.timeout);370 this.pause_button.disabled = false;371 this.start_button.textContent = "Stop";372 this.path_input.disabled = true;373 this.type_checkboxes.forEach(function(elem) {374 elem.disabled = true;375 });376 this.start_button.onclick = function() {377 this.runner.stop_flag = true;378 this.runner.done();379 }.bind(this);380 },381 set_pause: function() {382 this.pause_button.textContent = "Pause";383 this.pause_button.onclick = function() {384 this.runner.pause();385 this.set_resume();386 }.bind(this);387 },388 set_resume: function() {389 this.pause_button.textContent = "Resume";390 this.pause_button.onclick = function() {391 this.runner.unpause();392 this.set_pause();393 }.bind(this);394 },395 get_path: function() {396 return this.path_input.value;397 },398 get_test_types: function() {399 return this.type_checkboxes.filter(function(elem) {400 return elem.checked;401 }).map(function(elem) {402 return elem.value;403 });404 },405 get_testharness_settings: function() {406 return {timeout_multiplier: parseFloat(this.timeout_input.value),407 output: this.render_checkbox.checked};408 },409 on_done: function() {410 this.set_pause();411 this.set_start();412 }413};414function Results(runner) {415 this.test_results = null;416 this.runner = runner;417 this.runner.start_callbacks.push(this.on_start.bind(this));418}419Results.prototype = {420 on_start: function() {421 this.test_results = [];422 },423 set: function(test, status, message, subtests) {424 this.test_results.push({"test":test,425 "subtests":subtests,426 "status":status,427 "message":message});428 },429 count: function() {430 return this.test_results.length;431 },432 to_json: function() {433 var data = {434 "results": this.test_results.map(function(result) {435 var rv = {"test":(result.test.hasOwnProperty("ref_url") ?436 [result.test.url, result.test.ref_type, result.test.ref_url] :437 result.test.url),438 "subtests":result.subtests,439 "status":result.status,440 "message":result.message};441 return rv;442 })443 };444 return JSON.stringify(data, null, 2);445 }446};447function Runner(manifest_path) {448 this.server = location.protocol + "//" + location.host;449 this.manifest = new Manifest(manifest_path);450 this.path = null;451 this.test_types = null;452 this.manifest_iterator = null;453 this.test_window = null;454 this.test_div = document.getElementById('test_url');455 this.current_test = null;456 this.timeout = null;457 this.num_tests = null;458 this.pause_flag = false;459 this.stop_flag = false;460 this.done_flag = false;461 this.manifest_wait_callbacks = [];462 this.start_callbacks = [];463 this.test_start_callbacks = [];464 this.test_pause_callbacks = [];465 this.result_callbacks = [];466 this.done_callbacks = [];467 this.results = new Results(this);468 this.start_after_manifest_load = false;469 this.manifest.load(this.manifest_loaded.bind(this));470}471Runner.prototype = {472 test_timeout: 20000, 473 currentTest: function() {474 return this.manifest[this.mTestCount];475 },476 open_test_window: function() {477 this.test_window = window.open("about:blank", 800, 600);478 },479 manifest_loaded: function() {480 if (this.start_after_manifest_load) {481 this.do_start();482 }483 },484 start: function(path, test_types, testharness_settings) {485 this.pause_flag = false;486 this.stop_flag = false;487 this.done_flag = false;488 this.path = path;489 this.test_types = test_types;490 window.testharness_properties = testharness_settings;491 this.manifest_iterator = new ManifestIterator(this.manifest, this.path, this.test_types);492 this.num_tests = null;493 if (this.manifest.data === null) {494 this.wait_for_manifest();495 } else {496 this.do_start();497 }498 },499 wait_for_manifest: function() {500 this.start_after_manifest_load = true;501 this.manifest_wait_callbacks.forEach(function(callback) {502 callback();503 });504 },505 do_start: function() {506 if (this.manifest_iterator.count() > 0) {507 this.open_test_window();508 this.start_callbacks.forEach(function(callback) {509 callback();510 });511 this.run_next_test();512 } else {513 var tests = "tests";514 if (this.test_types.length < 3) {515 tests = this.test_types.join(" tests or ") + " tests";516 }517 var message = "No " + tests + " found in this path."518 document.querySelector(".path").setCustomValidity(message);519 this.done();520 }521 },522 pause: function() {523 this.pause_flag = true;524 this.test_pause_callbacks.forEach(function(callback) {525 callback(this.current_test);526 }.bind(this));527 },528 unpause: function() {529 this.pause_flag = false;530 this.run_next_test();531 },532 on_result: function(status, message, subtests) {533 clearTimeout(this.timeout);534 this.results.set(this.current_test, status, message, subtests);535 this.result_callbacks.forEach(function(callback) {536 callback(this.current_test, status, message, subtests);537 }.bind(this));538 this.run_next_test();539 },540 on_timeout: function() {541 this.on_result("TIMEOUT", "", []);542 },543 done: function() {544 this.done_flag = true;545 if (this.test_window) {546 this.test_window.close();547 }548 this.done_callbacks.forEach(function(callback) {549 callback();550 });551 },552 run_next_test: function() {553 if (this.pause_flag) {554 return;555 }556 var next_test = this.manifest_iterator.next();557 if (next_test === null||this.done_flag) {558 this.done();559 return;560 }561 this.current_test = next_test;562 if (next_test.type === "testharness") {563 this.timeout = setTimeout(this.on_timeout.bind(this),564 this.test_timeout * window.testharness_properties.timeout_multiplier);565 }566 this.test_div.textContent = this.current_test.url;567 this.load(this.current_test.url);568 this.test_start_callbacks.forEach(function(callback) {569 callback(this.current_test);570 }.bind(this));571 },572 load: function(path) {573 if (this.test_window.location === null) {574 this.open_test_window();575 }576 this.test_window.location.href = this.server + path;577 },578 progress: function() {579 return this.results.count() / this.test_count();580 },581 test_count: function() {582 if (this.num_tests === null) {583 this.num_tests = this.manifest_iterator.count();584 }585 return this.num_tests;586 }587};588function parseOptions() {589 var options = {590 test_types: ["testharness", "reftest", "manual"]591 };592 var optionstrings = location.search.substring(1).split("&");593 for (var i = 0, il = optionstrings.length; i < il; ++i) {594 var opt = optionstrings[i];595 596 options[opt.substring(0, opt.indexOf("="))] =597 opt.substring(opt.indexOf("=") + 1);598 }599 return options;600}601function setup() {602 var options = parseOptions();603 if (options.path) {604 document.getElementById('path').value = options.path;605 }606 runner = new Runner("/MANIFEST.json", options);607 var test_control = new TestControl(document.getElementById("testControl"), runner);608 new ManualUI(document.getElementById("manualUI"), runner);609 new VisualOutput(document.getElementById("output"), runner);610 if (options.autorun === "1") {611 runner.start(test_control.get_path(),612 test_control.get_test_types(),613 test_control.get_testharness_settings());614 return;615 }616}617window.completion_callback = function(tests, status) {618 var harness_status_map = {0:"OK", 1:"ERROR", 2:"TIMEOUT", 3:"NOTRUN"};619 var subtest_status_map = {0:"PASS", 1:"FAIL", 2:"TIMEOUT", 3:"NOTRUN"};620 621 622 var subtest_results = JSON.parse(JSON.stringify(...

Full Screen

Full Screen

create_form.js

Source:create_form.js Github

copy

Full Screen

1/*2 * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.3 *4 * WSO2 Inc. licenses this file to you under the Apache License,5 * Version 2.0 (the "License"); you may not use this file except6 * in compliance with the License.7 * You may obtain a copy of the License at8 *9 * http://www.apache.org/licenses/LICENSE-2.010 *11 * Unless required by applicable law or agreed to in writing,12 * software distributed under the License is distributed on an13 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY14 * KIND, either express or implied. See the License for the15 * specific language governing permissions and limitations16 * under the License.17 *18 */19/**20 * [contains actions, for creating a swagger name when the swagger url is selected,21 * to show drop down menu for import, upload & create of policies,22 * to call custom api23 * ]24 */25$(function() {26 var uploadUI,importUI,manualUI;27 //function to set the swagger name from the swagger url.28 $('input[name="overview_url"]').change(function() {29 var swaggerUrl = $('input[name="overview_url"]').val();30 var swaggerFileName = "";31 if (swaggerUrl.indexOf("\\") != -1) {32 swaggerFileName = swaggerUrl.substring(swaggerUrl.lastIndexOf('\\') + 1, swaggerUrl.length);33 } else {34 swaggerFileName = swaggerUrl.substring(swaggerUrl.lastIndexOf('/') + 1, swaggerUrl.length);35 }36 if (swaggerFileName.search(/\.[^?]*$/i) < 0) {37 swaggerFileName = swaggerFileName.replace("?", ".");38 var suffix = ".json";39 if (swaggerFileName.indexOf(".") > 0) {40 swaggerFileName = swaggerFileName.substring(0, swaggerFileName.lastIndexOf(".")) + suffix;41 } else {42 swaggerFileName = swaggerFileName + suffix;43 }44 }45 var notAllowedChars = "!@#;%^*+={}|<>";46 for (i = 0; i < notAllowedChars.length; i ++) {47 var c = notAllowedChars.charAt(i);48 swaggerFileName = swaggerFileName.replace(c, "_");49 }50 $('input[name="overview_name"]').val(swaggerFileName);51 var ajaxURL = caramel.context + '/apis/assets?type=swagger&q="name":"' + swaggerFileName + '"';52 $.ajax({53 url: ajaxURL,54 type: 'GET',55 success: function (data) {56 if (data.count > 0) {57 messages.alertInfo("Swagger docs exist with the same name ");58 }59 }60 });61 });62 $('#form-asset-create').ajaxForm({63 beforeSubmit:function(){64 var addSelector = $('#addMethodSelector');65 var selectedValue = addSelector.val();66 var version;67 var name;68 if (selectedValue == "upload") {69 name = encodeURIComponent($('#swagger_file_name').val());70 version = $('#file_version').val();71 if (!validator.isValidForm(uploadUI)) {72 messages.alertError("All required fields must be provided");73 return false;74 }75 } else {76 name = encodeURIComponent($('input[name="overview_name"]').val());77 version = $('input[name="overview_version"]').val();78 if (!validator.isValidForm(importUI)) {79 messages.alertError("All required fields must be provided");80 return false;81 }82 if (!validator.isValidForm(manualUI)) {83 messages.alertError("All required fields must be provided");84 return false;85 }86 }87 var ajaxURL = caramel.context + '/apis/assets?type=swagger&q="name":"' + name +88 '","version":"' + version + '"';89 var resourceExist = false;90 $.ajax({91 async: false,92 url: ajaxURL,93 type: 'GET',94 success: function (data) {95 if (data.count > 0) {96 messages.alertError("Swagger doc exist with same name and version");97 resourceExist = true;98 }99 }100 });101 if (resourceExist) {102 return false;103 }104 var action = "";105 if ($('#importUI').is(":visible")) {106 action = "addNewAssetButton";107 } else if ($('#uploadUI').is(":visible")) {108 action = "addNewSwaggerFileAssetButton";109 }110 if (action === 'addNewSwaggerFileAssetButton') {//upload via file browser111 //call the custom endpoint for processing swagger upload via file browser.112 var $swaggerFileInput = $('input[name="swagger_file_name"]');113 var swaggerFileInputValue = $swaggerFileInput.val();114 var swaggerFilePath = swaggerFileInputValue;115 if(!validator.isValidForm(uploadUI)) {116 messages.alertInfo("All required fields must be provided");117 return false;118 }119 var fileName = swaggerFilePath.split('\\').reverse()[0];120 //set the zip file name, to the hidden attribute.121 $('#swagger_file_name').val(fileName);122 } else if (action === 'addNewAssetButton') {//upload via url.123 if(!validator.isValidForm(importUI)) {124 messages.alertInfo("All required fields must be provided");125 return false;126 }127 }128 var createButton = $('#form-asset-create input[type="submit"]');129 createButton.attr('disabled', 'disabled');130 createButton.next().attr('disabled', 'disabled');131 caramel.render('loading', 'Creating asset. Please wait..', function (info, content) {132 var $content = $(content).removeClass('loading-animation-big').addClass('loading-animation');133 createButton.parent().append($content);134 });135 },136 success:function(data){137 //$.cookie("new-asset-" + data.type, data.id + ":" + data.type + ":" + data.name);138 window.location=$('#form-asset-create').attr('data-redirect-url');139 messages.alertSuccess("Successfully created the swagger");140 },141 error:function(){142 messages.alertError("Error occurred while adding the swagger");143 var createButton = $('#form-asset-create input[type="submit"]');144 createButton.removeAttr('disabled');145 $('.fa-spinner').parent().remove();146 }147 });148 var initUI = function() {149 //function to display upload or import uis.150 uploadUI = $('#uploadUI');151 importUI = $('#importUI');152 manualUI = $('#manualUI');153 importUI.show();154 validator.initValidationEvents('importUI',function(){});155 $('#form-asset-create').attr('action', caramel.context + '/apis/assets?type=swagger');156 $('#addMethodSelector').val('import');157 $('select').on('change', function() {158 var addSelector = $('#addMethodSelector');159 var selectedValue = addSelector.val();160 if (selectedValue == "upload") {161 uploadUI.show();162 importUI.hide();163 manualUI.hide();164 validator.initValidationEvents(uploadUI,function(){});165 validator.removeValidationEvents(importUI);166 validator.removeValidationEvents(manualUI);167 $('#form-asset-create').attr('action', caramel.context + '/assets/swagger/apis/swaggers');168 } else if (selectedValue == "import") {169 importUI.show();170 uploadUI.hide();171 manualUI.hide();172 validator.initValidationEvents(importUI,function(){});173 validator.removeValidationEvents(uploadUI);174 validator.removeValidationEvents(manualUI);175 $('#form-asset-create').attr('action', caramel.context + '/apis/assets?type=swagger');176 } else if (selectedValue == "manual") {177 manualUI.show();178 importUI.hide();179 uploadUI.hide();180 validator.initValidationEvents(manualUI,function(){});181 validator.removeValidationEvents(uploadUI);182 validator.removeValidationEvents(importUI);183 $('#form-asset-create').attr('action', caramel.context + '/apis/assets?type=swagger');184 }185 });186 var fileInput = $('input[name="swagger_file"]');187 if(fileInput.val().length > 0){188 var fileName = fileInput.val().split('\\').reverse()[0];189 $('#swagger_file_name').val(fileName);190 }191 $('input[name="swagger_file"]').change(function(){192 var fileName = fileInput.val().split('\\').reverse()[0];193 $('#swagger_file_name').val(fileName);194 })195 };196 initUI();...

Full Screen

Full Screen

main.ts

Source:main.ts Github

copy

Full Screen

...38 styles.rel = 'stylesheet';39 styles.href = './main.css';40 document.head.appendChild(styles);41 import('./app/manual-ui/manual-ui.js').then(({ ManualUI }) => {42 const manualUI = new ManualUI(this.gameDataService, this.appStateService);43 document.body.appendChild(manualUI.viewContainer);44 manualUI.startTicking();45 });46 } else {47 // Handle action recording in here48 const rotationHero = new RotationHero({49 gameDataService: this.gameDataService,50 appStateService: this.appStateService51 });52 document.body.appendChild(rotationHero.viewContainer);53 this.communicationLayer.addOverlayListener('LogLine', (evt: LogLineEvent) => {54 const ignoreEvents = ['00', '16', '39', '31', '26'];55 if (ignoreEvents.indexOf(evt.line[0]) !== -1) { return; }56 if (evt.line[0] !== '21') {...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var test = new wpt('www.webpagetest.org', 'A.1234567890abcdef1234567890abcdef12345678');3 if (err) return console.error(err);4 console.log('Test started: ' + data.data.testId);5 test.waitForTestComplete(data.data.testId, function(err, data) {6 if (err) return console.error(err);7 console.log('Test completed');8 test.getTestResults(data.data.testId, function(err, data) {9 if (err) return console.error(err);10 console.log('Test results: ' + data.data.summary);11 });12 });13});14var wpt = require('webpagetest');15var test = new wpt('www.webpagetest.org', 'A.1234567890abcdef1234567890abcdef12345678');16 if (err) return console.error(err);17 console.log('Test started: ' + data.data.testId);18 test.waitForTestComplete(data.data.testId, function(err, data) {19 if (err) return console.error(err);20 console.log('Test completed');21 test.getTestResults(data.data.testId, function(err, data) {22 if (err) return console.error(err);23 console.log('Test results: ' + data.data.summary);24 });25 });26});27var wpt = require('webpagetest');28var test = new wpt('www.webpagetest.org', 'A.1234567890abcdef1234567890abcdef12345678');29 if (err) return console.error(err);30 console.log('Test started: ' + data.data.testId);31 test.waitForTestComplete(data.data.testId, function(err, data) {32 if (err) return console.error(err);33 console.log('Test completed');34 test.getTestResults(data.data.testId, function(err, data) {35 if (

Full Screen

Using AI Code Generation

copy

Full Screen

1var net = require('net');2var fs = require('fs');3var client = new net.Socket();4var done = false;5var step = 1;6var testId = '';7var config = {

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptDriver = require('wptdriver');2var testId = 'TestID';3var manualUI = wptDriverClient.manualUI(testId, function (err, manualUI) {4 if (err) {5 console.log(err);6 } else {7 console.log(manualUI);8 }9});10The MIT License (MIT)11Please [submit an issue](

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2test.then(function(data){3 console.log(data);4}, function(err){5 console.log(err);6});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { ManualUI } = require('wpt');2const ui = new ManualUI();3ui.start();4ui.log('this is a test');5ui.log('this is another test');6ui.log('this is yet another test');7ui.done();8const { ManualUI } = require('wpt');9const ui = new ManualUI();10ui.start();11ui.log('this is a test');12ui.log('this is another test');13ui.log('this is yet another test');14ui.done();

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