How to use onLoadError method in backstopjs

Best JavaScript code snippet using backstopjs

jeasyui.extensions.js

Source:jeasyui.extensions.js Github

copy

Full Screen

1/**2* jQuery EasyUI 1.3.33* Copyright (c) 2009-2013 www.jeasyui.com. All rights reserved.4*5* Licensed under the GPL or commercial licenses6* To use it on other terms please contact us: jeasyui@gmail.com7* http://www.gnu.org/licenses/gpl.txt8* http://www.jeasyui.com/license_commercial.php9*10* jQuery EasyUI Generic Plugins Basic Library 1.0 beta11* jQuery EasyUI 通用插件基础库12* jeasyui.extensions.js13* 二次开发 陈建伟14* 最近更新:2013-07-2515*16* 依赖项:jquery.jdirk.js v1.0 beta late17*18* Copyright (c) 2013 ChenJianwei personal All rights reserved.19* http://www.chenjianwei.org20*/21(function ($, undefined) {22 var coreEasyui = {};23 var coreJquery = function () { return $.apply(this, arguments); };24 coreJquery.fn = coreJquery.prototype = {};25 coreJquery.easyui = coreEasyui;26 coreEasyui.getTopEasyuiMessager = function () {27 if ($.util.isTopMost) { return $.messager; }28 return $.util.$ && $.util.$.messager ? $.util.$.messager : $.messager;29 };30 coreEasyui.messager = coreEasyui.getTopEasyuiMessager();31 coreEasyui.getTopEasyuiTooltip = function () {32 if ($.util.isTopMost) { return $.fn.tooltip; }33 return $.util.$ && $.util.$.fn && $.util.$.fn.tooltip ? $.util.$.fn.tooltip : $.fn.tooltip;34 };35 coreEasyui.tooltip = $.fn.tooltip;36 coreEasyui.tooltip.init = function (target, options) {37 var t = $.util.parseJquery(target);38 t.mouseover(function () {39 t.tooltip($.extend({ trackMouse: true }, options, { onHide: function () {40 if ($.isFunction(options.onHide)) { options.onHide.apply(this, arguments); }41 t.tooltip("destroy");42 }43 })).tooltip("show");44 });45 };46 var icons = { "error": "messager-error", "info": "messager-info", "question": "messager-question", "warning": "messager-warning" },47 _show = $.messager.show, _alert = $.messager.alert, _confirm = $.messager.confirm, _prompt = $.messager.prompt,48 defaults = { title: "操作提醒", confirm: "您确认要进行该操作?", prompt: "请输入相应内容:", icon: "info", loading: "正在努力为您加载,请稍待..." };49 // 重写 $.messager.show 方法,使其支持图标以及默认的单个字符串参数的重载;该方法定义如下参数:50 // options: 表示需要弹出消息的内容、图标和方式等信息,该参数类型可以为如下:51 // JSON Object: 兼容 $.messager.show 官方默认 API 的所有属性,并在此基础上增加如下参数:52 // icon: 表示弹出消息的图标,为一个 String 类型值,该值可选的内容与 $.messager.alert 方法的第三个参数可选内容相同;53 // 包括:"error", "info", "question", "warning";54 // 具体内容参见 $.messager.alert 该方法的官方默认 API 中第三个参数可选内容。55 // position: 表示弹出消息的位置,为一个 String 类型值,该值可选的内容定义如下:56 // topLeft: 屏幕左上角, topCenter: 屏幕上方中间,topRight: 屏幕右上角57 // centerLeft: 屏幕左侧中间,center: 屏幕正中间,centerRight: 屏幕右侧中间58 // bottomLeft: 屏幕左下角,bottomCenter: 屏幕下方中间,bottomRight: 屏幕右下角59 // String: 以 icon: "info"、title: "操作提醒"、msg: options 为默认的方式调用上一重载。60 $.messager.show = function (options) {61 var isString = $.util.isString(options) || $.util.isBoolean(options) || $.isNumeric(options);62 if (isString) {63 arguments.length == 1 ? $.messager.show({ msg: String(options) }) : $.messager.show({ title: options, msg: arguments[1], icon: arguments[2], position: arguments[3] });64 return;65 }66 var defaults = $.extend({}, $.messager.defaults, { title: "操作提醒", timeout: 3000, showType: "slide" });67 var position = {68 topLeft: { right: "", left: 0, top: document.body.scrollTop + document.documentElement.scrollTop, bottom: "" },69 topCenter: { right: "", top: document.body.scrollTop + document.documentElement.scrollTop, bottom: "" },70 topRight: { left: "", right: 0, top: document.body.scrollTop + document.documentElement.scrollTop, bottom: "" },71 centerLeft: { left: 0, right: "", bottom: "" },72 center: { right: "", bottom: "" },73 centerRight: { left: "", right: 0, bottom: "" },74 bottomLeft: { left: 0, right: "", top: "", bottom: -document.body.scrollTop - document.documentElement.scrollTop },75 bottomCenter: { right: "", top: "", bottom: -document.body.scrollTop - document.documentElement.scrollTop },76 bottomRight: null77 };78 var opts = $.extend({}, defaults, options);79 opts.style = position[options.position] ? position[options.position] : position.topCenter;80 var iconCls = icons[opts.icon] ? icons[opts.icon] : icons.info;81 opts.msg = "<div class='messager-icon " + iconCls + "'></div>" + "<div>" + opts.msg + "</div>";82 return _show(opts);83 };84 $.union($.messager.show, _show);85 $.messager.alert = function (title, msg, icon, fn) {86 if (arguments.length == 1) { return _alert(defaults.title, arguments[0], defaults.icon); }87 if (arguments.length == 2) {88 if ($.isFunction(arguments[1])) { return _alert(defaults.title, arguments[0], defaults.icon, arguments[1]); }89 if (arguments[1] in icons) { return _alert(defaults.title, arguments[0], arguments[1]); }90 return _alert.apply(this, arguments);91 }92 if (arguments.length == 3) {93 if ($.isFunction(arguments[2])) {94 return (arguments[1] in icons) ? _alert(defaults.title, arguments[0], arguments[1], arguments[2])95 : _alert(arguments[0], arguments[1], defaults.icon, arguments[2]);96 }97 return _alert.apply(this, arguments);98 }99 return _alert.apply(this, arguments);100 };101 $.messager.confirm = function (title, msg, fn) {102 if (arguments.length == 1) {103 return $.isFunction(arguments[0]) ? _confirm(defaults.title, defaults.confirm, arguments[0]) : _confirm(defaults.title, arguments[0]);104 }105 if (arguments.length == 2) {106 return $.isFunction(arguments[1]) ? _confirm(defaults.title, arguments[0], arguments[1]) : _confirm(arguments[0], arguments[1]);107 }108 return _confirm.apply(this, arguments);109 };110 $.messager.prompt = function (title, msg, fn) {111 if (arguments.length == 1) {112 return $.isFunction(arguments[0]) ? _prompt(defaults.title, defaults.prompt, arguments[0]) : _prompt(defaults.title, defaults.prompt);113 }114 if (arguments.length == 2) {115 return $.isFunction(arguments[0]) ? _prompt(defaults.title, arguments[0], arguments[1]) : _prompt(arguments[0], arguments[1]);116 }117 return _prompt.apply(this, arguments);118 };119 // 备注: $.messager 表示当前页面的 easyui-messager 对象;120 // $.easyui.messager 表示可控顶级页面的 easyui-messager 对象;121 // 更改 jQuery EasyUI 中部分控件的国际化语言显示。122 $.extend($.fn.panel.defaults, { loadingMessage: defaults.loading });123 $.extend($.fn.window.defaults, { loadingMessage: defaults.loading });124 $.extend($.fn.dialog.defaults, { loadingMessage: defaults.loading });125 // 更改 jeasyui-combo 组件的非空验证提醒消息语言。126 $.extend($.fn.combo.defaults, { missingMessage: $.fn.validatebox.defaults.missingMessage });127 // 更改 jQuery EasyUI 部分组件的通用错误提示。128 var onLoadError = function (XMLHttpRequest, textStatus, errorThrown) {129 $.messager.progress("close");130 if (coreEasyui.messager != $.messager) { coreEasyui.messager.progress("close"); }131 var msg = (XMLHttpRequest && !$.string.isNullOrWhiteSpace(XMLHttpRequest.responseText) ?132 "如果该问题重复出现,请联系您的系统管理员并反馈该故障。<br />" +133 "错误号:" + XMLHttpRequest.status + "(" + XMLHttpRequest.statusText + ");<hr />" + XMLHttpRequest.responseText :134 "系统出现了一个未指明的错误,如果该问题重复出现,请联系您的系统管理员并反馈该故障。");135 coreEasyui.messager.alert("错误提醒", msg, "error");136 var win = $.util.$("div.panel.window.messager-window:last").children("div.messager-body.panel-body.window-body"),137 opts = win.window("options"), panel = win.window("panel"), width = panel.outerWidth(), height = panel.outerHeight();138 if (width > 800 || height > 800) { win.window("resize", { width: width > 800 ? 800 : width, height: height > 800 ? 800 : height }); }139 win.window("center");140 };141 $.fn.form.defaults.onLoadError = onLoadError;142 $.fn.combobox.defaults.onLoadError = onLoadError;143 $.fn.combotree.defaults.onLoadError = onLoadError;144 $.fn.combogrid.defaults.onLoadError = onLoadError;145 $.fn.datagrid.defaults.onLoadError = onLoadError;146 $.fn.propertygrid.defaults.onLoadError = onLoadError;147 $.fn.tree.defaults.onLoadError = onLoadError;148 $.fn.treegrid.defaults.onLoadError = onLoadError;149 // 更改 jQuery.ajax 函数的部分默认属性。150 $.ajaxSetup({151 dataFilter: function (data, type) {152 return $.util.isString(type) && type.toLowerCase(type) == "json" ? $.string.toJSONString(data) : data;153 },154 error: onLoadError155 });156 $.union(coreJquery);157 $.fn.union(coreJquery.fn);...

Full Screen

Full Screen

Loadable.js

Source:Loadable.js Github

copy

Full Screen

1new hope.Operation.subclass({2 name : "Loader",3 prototype : {4 callbackName : "onLoaded",5 errbackName : "onLoadError"6 }7});8/** Loadable mixin. 9 Specify loadOptions for customization, or create an Operation called <mixeeType>Loader for full custom loader.10 TODO: different semantics for the constructor?11*/12new hope.Mixin({13 name : "Loadable",14 /** Don't overwrite properties already set on the mixee. */15 overwrite : hope.MERGE,16 prototype : {17 /** Loader for this instance, created automatically and stored in the cache. */18 'get:loader' : function() {19 if (!this._loader) {20 // create a new loader, setting this as the callbackTarget21 var options = this.loadOptions || {};22 options.callbackTarget = this;23 this._loader = new (this.constructor.loader)(options);24 }25 return this._loader;26 },27 /** Has this thing been loaded successfully? */28 'get:loaded' : function(){return this.loader.state == hope.LOADED},29 'set:loaded' : function(flag){return this.loader.state = (flag == true ? hope.LOADED : hope.UNLOADED)},30 31 /** Aliases for the load url. */32 'get:src' : function(){return this.loader.url},33 'set:src' : function(url){return this.loader.set("url", url)},34 /** Alias for the load output. */35 'get:data' : function(){return this.loader.output},36 'get:dataType' : function(){return this.loader.outputType},37 'set:dataType' : function(type){return this.loader.set("outputType", type)},38 39 /** Aliases for load/load error messages. */40 'get:loadMessage' : function(){return this.loader.message},41 'set:loadMessage' : function(msg){return this.loader.set("loadMessage", msg)},42 'get:loadErrorMessage' : function(){return this.loader.errorMessage},43 'set:loadErrorMessage' : function(url){this.loader.set("errorMessage", errorMessage)},44 45 /** Load command. Pass a url (string) or object of options to load. */46 load : function(options, onLoaded, onLoadError) {47 options = (typeof options == "string" ? {url:options} : options||{});48 if (onLoaded) options.onLoaded = onLoaded;49 if (onLoadError) options.onLoadError = onLoadError;50 this.loader.execute(options);51 return this;52 },53 // onLoaded and onLoadError handlers, called as: (event, [data|error], key, target)54 onLoaded : undefined,55 onLoadError : undefined56 },57 58 statics : {59 load : function(options, onLoaded, onLoadError) {60 // if options is an array of strings, make an OperationQueue and load them all one at a time61 if (hope.isListLike(options)) {62 var operations = options, i = -1, url;63 while (url = operations[++i]) {64 operations[i] = new (this.loader)({url:url});65 }66 var options = {operations:operations};67 if (onLoaded) options.onCompleted = onLoaded;68 if (onLoadError) options.onError = onLoadError;69 return (new hope.OperationQueue(options)).execute();70 } else {71 options = (typeof options == "string" ? {url:options} : options||{});72 if (onLoaded) options.onLoaded = onLoaded;73 if (onLoadError) options.onLoadError = onLoadError;74 return (new (this.loader)(options)).execute();75 }76 }77 },78 79 /** Create a custom loader for the Loadable thing. 80 If an operation named <classType>Loader is already defined, we'll use that.81 Otherwise we'll create one.82 */83 onMixin : function(it) {84 var loaderName = it.Class.name + "Loader", operation;85 try {86 operation = hope.getThing(loaderName); // will throw if not found87 } catch (e) {88 // create an operation if not already defined89 operation = new hope.Loader.subclass({ name : loaderName });90 }91 // assign to the element (and its prototype, if applicable)92 it.loader = operation;93 }...

Full Screen

Full Screen

zUtil.js

Source:zUtil.js Github

copy

Full Screen

1var zzw = zzw || {};2/**3 * 4 */5$.fn.tree.defaults.loadFilter = function(data, parent) {6 var opt = $(this).data().tree.options;7 var idFiled, textFiled, parentField;8 if (opt.parentField) {9 idFiled = opt.idFiled || 'id';10 textFiled = opt.textFiled || 'text';11 parentField = opt.parentField;12 var i, l, treeData = [], tmpMap = [];13 for (i = 0, l = data.length; i < l; i++) {14 tmpMap[data[i][idFiled]] = data[i];15 }16 for (i = 0, l = data.length; i < l; i++) {17 if (tmpMap[data[i][parentField]] && data[i][idFiled] != data[i][parentField]) {18 if (!tmpMap[data[i][parentField]]['children'])19 tmpMap[data[i][parentField]]['children'] = [];20 data[i]['text'] = data[i][textFiled];21 tmpMap[data[i][parentField]]['children'].push(data[i]);22 } else {23 data[i]['text'] = data[i][textFiled];24 treeData.push(data[i]);25 }26 }27 return treeData;28 }29 return data;30};31/**32 * 33 * @requires jQuery,EasyUI34 * 35 * 防止panel/window/dialog组件超出浏览器边界36 * @param left37 * @param top38 */39zzw.onMove = {40 onMove : function(left, top) {41 var l = left;42 var t = top;43 if (l < 1) {44 l = 1;45 }46 if (t < 1) {47 t = 1;48 }49 var width = parseInt($(this).parent().css('width')) + 14;50 var height = parseInt($(this).parent().css('height')) + 14;51 var right = l + width;52 var buttom = t + height;53 var browserWidth = $(window).width();54 var browserHeight = $(window).height();55 if (right > browserWidth) {56 l = browserWidth - width;57 }58 if (buttom > browserHeight) {59 t = browserHeight - height;60 }61 $(this).parent().css({/* 修正面板位置 */62 left : l,63 top : t64 });65 }66};67$.extend($.fn.dialog.defaults, zzw.onMove);68$.extend($.fn.window.defaults, zzw.onMove);69$.extend($.fn.panel.defaults, zzw.onMove);70/**71 * 通用加載錯誤提示72 */73zzw.onLoadError = {74 onLoadError : function(XMLHttpRequest) {75 $.messager.show({76 msg : XMLHttpRequest.statusText + ' ' + XMLHttpRequest.status + '[' + XMLHttpRequest.responseText + ']',77 title : '錯誤',78 timeout : 079 });80 }81};82$.extend($.fn.datagrid.defaults, zzw.onLoadError);83$.extend($.fn.treegrid.defaults, zzw.onLoadError);84$.extend($.fn.tree.defaults, zzw.onLoadError);85$.extend($.fn.combogrid.defaults, zzw.onLoadError);86$.extend($.fn.combobox.defaults, zzw.onLoadError);87$.extend($.fn.form.defaults, zzw.onLoadError);88$.extend($.fn.datagrid.defaults.editors, {89 combogrid : {90 init : function(container, options) {91 var input = $('<input type="text" class="datagrid-editable-input">').appendTo(container);92 input.combogrid(options);93 return input;94 },95 destroy : function(target) {96 $(target).combogrid('destroy');97 },98 getValue : function(target) {99 return $(target).combogrid('getValue');100 },101 setValue : function(target, value) {102 $(target).combogrid('setValue', value);103 },104 resize : function(target, width) {105 $(target).combogrid('resize', width);106 }107 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1module.exports = {2 {3 },4 {5 },6 {7 },8 {9 }10 "onLoadError": {},11 {12 }13 "paths": {14 },15 "engineOptions": {16 },17}18module.exports = async function (chromy, scenario) {19 const clearCookies = true;20 if (clearCookies) {21 await chromy.clearCookies();22 }23 {24 },25 {26 },27 ];

Full Screen

Using AI Code Generation

copy

Full Screen

1module.exports = {2 {3 },4 {5 }6 {7 "onLoadError": {8 "options": {9 }10 }11 }12 "paths": {13 },14 "engineOptions": {15 },16}17module.exports = {18 onLoadError: function (page, scenario, vp, options, err) {19 console.log('onLoadError', err);20 }21};

Full Screen

Using AI Code Generation

copy

Full Screen

1module.exports = async (page, scenario, vp) => {2 console.log('SCENARIO > ' + scenario.label);3 await require('./loadCookies')(page, scenario);4 page.on('error', msg => {5 console.log('page error > ' + msg);6 });7 page.on('pageerror', msg => {8 console.log('page error > ' + msg);9 });10 page.on('requestfailed', request => {11 console.log(request.failure().errorText);12 });13};

Full Screen

Using AI Code Generation

copy

Full Screen

1module.exports = {2 {3 }4 "paths": {5 },6 "engineOptions": {7 },8}9module.exports = async function (chromy, scenario) {10 console.log('onBefore.js: Adding cookie.');11 await chromy.setCookie({ name: 'cookieName1', value: 'cookieValue1', domain: 'localhost' });12 await chromy.setCookie({ name: 'cookieName2', value: 'cookieValue2', domain: 'localhost' });13 await chromy.setCookie({ name: 'cookieName3', value: 'cookieValue3', domain: 'localhost' });14};15module.exports = async function (chromy, scenario) {16 console.log('onReady.js: Clicking cookie consent button.');

Full Screen

Using AI Code Generation

copy

Full Screen

1module.exports = async (page, scenario, vp) => {2 console.log('SCENARIO > ' + scenario.label);3 await require('./loadCookies')(page, scenario);4 await page.waitFor(500);5};6{7 {8 },9 {10 }11}12{13 {14 },15 {16 }17}

Full Screen

Using AI Code Generation

copy

Full Screen

1casper.on('load.failed', function (resourceError) {2 casper.test.fail(resourceError.errorString);3});4casper.on('resource.error', function (resourceError) {5 casper.test.fail(resourceError.errorString);6});7casper.on('resource.timeout', function (resourceError) {8 casper.test.fail(resourceError.errorString);9});10casper.on('url.changed', function (targetUrl) {11 casper.test.info('New URL: ' + targetUrl);12});13casper.on('page.error', function (msg, trace) {14 casper.test.fail('Error: ' + msg);15});16casper.on('remote.message', function (msg) {17 casper.test.info('remote message caught: ' + msg);18});19casper.on('page.initialized', function () {20 casper.test.info('page.initialized');21});22casper.on('page.resource.requested', function (requestData, networkRequest) {23 casper.test.info('page.resource.requested');24});25casper.on('page.resource.received', function (response) {26 casper.test.info('page.resource.received');27});28casper.on('page.resource.error', function (resourceError) {29 casper.test.fail('Unable to load resource (#' + resourceError.id + 'URL:' + resourceError.url + ')');30});31casper.on('page.resource.timeout', function (requestData) {32 casper.test.fail('Resource request timed out: ' + JSON.stringify(requestData));33});

Full Screen

Using AI Code Generation

copy

Full Screen

1module.exports = {2 "onLoadError": function(page, scenario, vp) {3 console.log(page, scenario, vp);4 }5};6module.exports = {7};8module.exports = {9};10module.exports = {11};12module.exports = {13};14module.exports = {15};16module.exports = {17};18module.exports = {19};20module.exports = {21};22module.exports = {23};24module.exports = {

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 backstopjs 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