How to use Dialog method in chrominator

Best JavaScript code snippet using chrominator

dwz.dialog.js

Source:dwz.dialog.js Github

copy

Full Screen

...39 }40 if(op.fresh || url != $(dialog).data("url")){41 dialog.data("url",url);42 dialog.find(".dialogHeader").find("h1").html(title);43 this.switchDialog(dialog);44 var jDContent = dialog.find(".dialogContent");45 jDContent.ajaxUrl({46 type:options.type||'GET', url:url, data:options.data || {}, callback:function(){47 jDContent.find("[layoutH]").layoutH(jDContent);48 $(".pageContent", dialog).width($(dialog).width()-14);49 $("button.close", dialog).click(function(){50 $.pdialog.close(dialog);51 return false;52 });53 }54 });55 }56 57 } else { //打开一个全新的层58 59 $("body").append(DWZ.frag["dialogFrag"]);60 dialog = $(">.dialog:last-child", "body");61 dialog.data("id",dlgid);62 dialog.data("url",url);63 if(options.close) dialog.data("close",options.close);64 if(options.param) dialog.data("param",options.param);65 ($.fn.bgiframe && dialog.bgiframe());66 67 dialog.find(".dialogHeader").find("h1").html(title);68 $(dialog).css("zIndex", ($.pdialog._zIndex+=2));69 $("div.shadow").css("zIndex", $.pdialog._zIndex - 3).show();70 $.pdialog._init(dialog, options);71 $(dialog).click(function(){72 $.pdialog.switchDialog(dialog);73 });74 75 if(op.resizable)76 dialog.jresize();77 if(op.drawable)78 dialog.dialogDrag();79 $("a.close", dialog).click(function(event){ 80 $.pdialog.close(dialog);81 return false;82 });83 if (op.maxable) {84 $("a.maximize", dialog).show().click(function(event){85 $.pdialog.switchDialog(dialog);86 $.pdialog.maxsize(dialog);87 dialog.jresize("destroy").dialogDrag("destroy");88 return false;89 });90 } else {91 $("a.maximize", dialog).hide();92 }93 $("a.restore", dialog).click(function(event){94 $.pdialog.restore(dialog);95 dialog.jresize().dialogDrag();96 return false;97 });98 if (op.minable) {99 $("a.minimize", dialog).show().click(function(event){100 $.pdialog.minimize(dialog);101 return false;102 });103 } else {104 $("a.minimize", dialog).hide();105 }106 $("div.dialogHeader a", dialog).mousedown(function(){107 return false;108 });109 $("div.dialogHeader", dialog).dblclick(function(){110 if($("a.restore",dialog).is(":hidden"))111 $("a.maximize",dialog).trigger("click");112 else113 $("a.restore",dialog).trigger("click");114 });115 if(op.max) {116// $.pdialog.switchDialog(dialog);117 $.pdialog.maxsize(dialog);118 dialog.jresize("destroy").dialogDrag("destroy");119 }120 $("body").data(dlgid, dialog);121 $.pdialog._current = dialog;122 $.pdialog.attachShadow(dialog);123 //load data124 var jDContent = $(".dialogContent",dialog);125 jDContent.ajaxUrl({126 type:options.type||'GET', url:url, data:options.data || {}, callback:function(){127 jDContent.find("[layoutH]").layoutH(jDContent);128 $(".pageContent", dialog).width($(dialog).width()-14);129 $("button.close", dialog).click(function(){130 $.pdialog.close(dialog);131 return false;132 });133 }134 });135 }136 if (op.mask) {137 $(dialog).css("zIndex", 1000);138 $("a.minimize",dialog).hide();139 $(dialog).data("mask", true);140 $("#dialogBackground").show();141 }else {142 //add a task to task bar143 if(op.minable) $.taskBar.addDialog(dlgid,title);144 }145 },146 /**147 * 切换当前层148 * @param {Object} dialog149 */150 switchDialog:function(dialog) {151 var index = $(dialog).css("zIndex");152 $.pdialog.attachShadow(dialog);153 if($.pdialog._current) {154 var cindex = $($.pdialog._current).css("zIndex");155 $($.pdialog._current).css("zIndex", index);156 $(dialog).css("zIndex", cindex);157 $("div.shadow").css("zIndex", cindex - 1);158 $.pdialog._current = dialog;159 }160 $.taskBar.switchTask(dialog.data("id"));161 },162 /**163 * 给当前层附上阴隐层164 * @param {Object} dialog165 */166 attachShadow:function(dialog) {167 var shadow = $("div.shadow");168 if(shadow.is(":hidden")) shadow.show();169 shadow.css({170 top: parseInt($(dialog)[0].style.top) - 2,171 left: parseInt($(dialog)[0].style.left) - 4,172 height: parseInt($(dialog).height()) + 8,173 width: parseInt($(dialog).width()) + 8,174 zIndex:parseInt($(dialog).css("zIndex")) - 1175 });176 $(".shadow_c", shadow).children().andSelf().each(function(){177 $(this).css("height", $(dialog).outerHeight() - 4);178 });179 },180 _init:function(dialog, options) {181 var op = $.extend({}, this._op, options);182 var height = op.height>op.minH?op.height:op.minH;183 var width = op.width>op.minW?op.width:op.minW;184 if(isNaN(dialog.height()) || dialog.height() < height){185 $(dialog).height(height+"px");186 $(".dialogContent",dialog).height(height - $(".dialogHeader", dialog).outerHeight() - $(".dialogFooter", dialog).outerHeight() - 6);187 }188 if(isNaN(dialog.css("width")) || dialog.width() < width) {189 $(dialog).width(width+"px");190 }191 192 var iTop = ($(window).height()-dialog.height())/2;193 dialog.css({194 left: ($(window).width()-dialog.width())/2,195 top: iTop > 0 ? iTop : 0196 });197 },198 /**199 * 初始化半透明层200 * @param {Object} resizable201 * @param {Object} dialog202 * @param {Object} target203 */204 initResize:function(resizable, dialog,target) {205 $("body").css("cursor", target + "-resize");206 resizable.css({207 top: $(dialog).css("top"),208 left: $(dialog).css("left"),209 height:$(dialog).css("height"),210 width:$(dialog).css("width")211 });212 resizable.show();213 },214 /**215 * 改变阴隐层216 * @param {Object} target217 * @param {Object} options218 */219 repaint:function(target,options){220 var shadow = $("div.shadow");221 if(target != "w" && target != "e") {222 shadow.css("height", shadow.outerHeight() + options.tmove);223 $(".shadow_c", shadow).children().andSelf().each(function(){224 $(this).css("height", $(this).outerHeight() + options.tmove);225 });226 }227 if(target == "n" || target =="nw" || target == "ne") {228 shadow.css("top", options.otop - 2);229 }230 if(options.owidth && (target != "n" || target != "s")) {231 shadow.css("width", options.owidth + 8);232 }233 if(target.indexOf("w") >= 0) {234 shadow.css("left", options.oleft - 4);235 }236 },237 /**238 * 改变左右拖动层的高度239 * @param {Object} target240 * @param {Object} tmove241 * @param {Object} dialog242 */243 resizeTool:function(target, tmove, dialog) {244 $("div[class^='resizable']", dialog).filter(function(){245 return $(this).attr("tar") == 'w' || $(this).attr("tar") == 'e';246 }).each(function(){247 $(this).css("height", $(this).outerHeight() + tmove);248 });249 },250 /**251 * 改变原始层的大小252 * @param {Object} obj253 * @param {Object} dialog254 * @param {Object} target255 */256 resizeDialog:function(obj, dialog, target) {257 var oleft = parseInt(obj.style.left);258 var otop = parseInt(obj.style.top);259 var height = parseInt(obj.style.height);260 var width = parseInt(obj.style.width);261 if(target == "n" || target == "nw") {262 tmove = parseInt($(dialog).css("top")) - otop;263 } else {264 tmove = height - parseInt($(dialog).css("height"));265 }266 $(dialog).css({left:oleft,width:width,top:otop,height:height});267 $(".dialogContent", dialog).css("width", (width-12) + "px");268 $(".pageContent", dialog).css("width", (width-14) + "px");269 if (target != "w" && target != "e") {270 var content = $(".dialogContent", dialog);271 content.css({height:height - $(".dialogHeader", dialog).outerHeight() - $(".dialogFooter", dialog).outerHeight() - 6});272 content.find("[layoutH]").layoutH(content);273 $.pdialog.resizeTool(target, tmove, dialog);274 }275 $.pdialog.repaint(target, {oleft:oleft,otop: otop,tmove: tmove,owidth:width});276 277 $(window).trigger(DWZ.eventType.resizeGrid);278 },279 close:function(dialog) {280 if(typeof dialog == 'string') dialog = $("body").data(dialog);281 var close = dialog.data("close");282 var go = true;283 if(close && $.isFunction(close)) {284 var param = dialog.data("param");285 if(param && param != ""){286 param = DWZ.jsonEval(param);287 go = close(param);288 } else {289 go = close();290 }291 if(!go) return;292 }293 294 $(dialog).hide();295 $("div.shadow").hide();296 if($(dialog).data("mask")){297 $("#dialogBackground").hide();298 } else{299 if ($(dialog).data("id")) $.taskBar.closeDialog($(dialog).data("id"));300 }301 $("body").removeData($(dialog).data("id"));302 $(dialog).trigger(DWZ.eventType.pageClear).remove();303 },304 closeCurrent:function(){305 this.close($.pdialog._current);306 },307 checkCloseCurrent:function(json){308 if (!json) return;309 if (json[DWZ.keys.statusCode] == DWZ.statusCode.timeout310 || (json[DWZ.keys.statusCode] == DWZ.statusCode.error && "closeCurrentDialog" == json.callbackType) ) {311 this.closeCurrent();312 }313 },...

Full Screen

Full Screen

dropdown.test.js

Source:dropdown.test.js Github

copy

Full Screen

...11 describe('Test for mage/dropdown jQuery plugin', function () {12 it('check if dialog opens when the triggerEvent is triggered', function () {13 var opener = $('<div/>'),14 dialog = $('<div/>');15 dialog.dropdownDialog({16 'triggerEvent': 'click',17 'triggerTarget': opener18 });19 opener.trigger('click');20 expect(dialog.dropdownDialog('isOpen')).toBeTruthy();21 dialog.dropdownDialog('destroy');22 dialog.dropdownDialog({23 'triggerEvent': null,24 'triggerTarget': opener25 });26 opener.trigger('click');27 expect(dialog.dropdownDialog('isOpen')).toBeFalsy();28 dialog.dropdownDialog('destroy');29 });30 it('check if a specified class is added to the trigger', function () {31 var opener = $('<div/>'),32 dialog = $('<div/>');33 dialog.dropdownDialog({34 'triggerClass': 'active',35 'triggerTarget': opener36 });37 dialog.dropdownDialog('open');38 expect(opener.hasClass('active')).toBeTruthy();39 dialog.dropdownDialog('close');40 dialog.dropdownDialog('destroy');41 dialog.dropdownDialog({42 'triggerClass': null,43 'triggerTarget': opener44 });45 dialog.dropdownDialog('open');46 expect(opener.hasClass('active')).toBeFalsy();47 dialog.dropdownDialog('close');48 dialog.dropdownDialog('destroy');49 });50 it('check if a specified class is added to the element which the dialog appends to', function () {51 var parent = $('<div/>'),52 dialog = $('<div/>');53 dialog.dropdownDialog({54 'parentClass': 'active',55 'appendTo': parent56 });57 dialog.dropdownDialog('open');58 expect(parent.hasClass('active')).toBeTruthy();59 dialog.dropdownDialog('close');60 dialog.dropdownDialog('destroy');61 dialog.dropdownDialog({62 'parentClass': null,63 'appendTo': parent64 });65 dialog.dropdownDialog('open');66 expect(parent.hasClass('active')).toBeFalsy();67 dialog.dropdownDialog('close');68 dialog.dropdownDialog('destroy');69 });70 it('check if a specified class is added to the element that becomes dialog', function () {71 var dialog = $('<div/>'),72 content;73 dialog.dropdownDialog({74 'dialogContentClass': 'active'75 });76 content = $('.ui-dialog-content');77 dialog.dropdownDialog('open');78 expect(content.hasClass('active')).toBeTruthy();79 dialog.dropdownDialog('close');80 dialog.dropdownDialog('destroy');81 dialog.dropdownDialog({82 'dialogContentClass': null83 });84 dialog.dropdownDialog('open');85 expect(content.hasClass('active')).toBeFalsy();86 dialog.dropdownDialog('close');87 dialog.dropdownDialog('destroy');88 });89 it('check if a specified class is added to dialog', function () {90 var dialog = $('<div/>'),91 uiClass = '.ui-dialog',92 ui;93 dialog.dropdownDialog({94 'defaultDialogClass': 'custom'95 });96 ui = $(uiClass);97 expect(ui.hasClass('custom')).toBeTruthy();98 expect(ui.hasClass('mage-dropdown-dialog')).toBeFalsy();99 dialog.dropdownDialog('destroy');100 dialog.dropdownDialog({});101 ui = $(uiClass);102 expect(ui.hasClass('mage-dropdown-dialog')).toBeTruthy();103 dialog.dropdownDialog('destroy');104 });105 it('check if the specified trigger actually opens the dialog', function () {106 var opener = $('<div/>'),107 dialog = $('<div/>');108 dialog.dropdownDialog({109 'triggerTarget': opener110 });111 opener.trigger('click');112 expect(dialog.dropdownDialog('isOpen')).toBeTruthy();113 dialog.dropdownDialog('close');114 dialog.dropdownDialog('destroy');115 dialog.dropdownDialog({116 'triggerTarget': null117 });118 opener.trigger('click');119 expect(dialog.dropdownDialog('isOpen')).toBeFalsy();120 dialog.dropdownDialog('destroy');121 });122 it('check if the dialog gets closed when clicking outside of it', function () {123 var container = $('<div/>'),124 outside = $('<div/>').attr('id', 'outside').appendTo(container),125 dialog = $('<div/>').attr('id', 'dialog').appendTo(container);126 container.appendTo('body');127 dialog.dropdownDialog({128 'closeOnClickOutside': true129 });130 dialog.dropdownDialog('open');131 outside.trigger('click');132 expect(dialog.dropdownDialog('isOpen')).toBeFalsy();133 dialog.dropdownDialog('destroy');134 dialog.dropdownDialog({135 'closeOnClickOutside': false136 });137 dialog.dropdownDialog('open');138 outside.trigger('click');139 expect(dialog.dropdownDialog('isOpen')).toBeTruthy();140 dialog.dropdownDialog('destroy');141 });142 it('check if the dialog gets closed when mouse leaves the dialog area', function () {143 var container = $('<div/>'),144 dialog = $('<div/>').attr('id', 'dialog').appendTo(container);145 $('<div/>').attr('id', 'outside').appendTo(container);146 $('<div/>').attr('id', 'opener').appendTo(container);147 container.appendTo('body');148 jasmine.clock().install();149 dialog.dropdownDialog({150 'closeOnMouseLeave': true151 });152 dialog.dropdownDialog('open');153 dialog.trigger('mouseenter');154 expect(dialog.dropdownDialog('isOpen')).toBeTruthy();155 dialog.trigger('mouseleave');156 jasmine.clock().tick(10);157 expect(dialog.dropdownDialog('isOpen')).toBeFalsy();158 dialog.dropdownDialog('destroy');159 jasmine.clock().uninstall();160 });161 it('check if the dialog does not close when mouse leaves the dialog area', function () {162 var container = $('<div/>'),163 dialog = $('<div/>').attr('id', 'dialog').appendTo(container);164 $('<div/>').attr('id', 'outside').appendTo(container);165 $('<div/>').attr('id', 'opener').appendTo(container);166 container.appendTo('body');167 jasmine.clock().install();168 dialog.dropdownDialog({169 'closeOnMouseLeave': false170 });171 dialog.dropdownDialog('open');172 dialog.trigger('mouseenter');173 dialog.trigger('mouseleave');174 jasmine.clock().tick(10);175 expect(dialog.dropdownDialog('isOpen')).toBeTruthy();176 dialog.dropdownDialog('destroy');177 jasmine.clock().uninstall();178 });179 it('check if the dialog gets closed with the specified delay', function (done) {180 var container = $('<div/>'),181 dialog = $('<div/>').attr('id', 'dialog').appendTo(container);182 $('<div/>').attr('id', 'outside').appendTo(container);183 $('<div/>').attr('id', 'opener').appendTo(container);184 container.appendTo('body');185 dialog.dropdownDialog({186 'timeout': 5187 });188 dialog.dropdownDialog('open');189 dialog.trigger('mouseenter');190 dialog.trigger('mouseleave');191 expect(dialog.dropdownDialog('isOpen')).toBeTruthy();192 setTimeout(function () {193 expect(dialog.dropdownDialog('isOpen')).toBeFalsy();194 dialog.dropdownDialog('destroy');195 done();196 }, 6);197 });198 /*199 * jQuery ui version 1.9.2 belongs to the adminhtml.200 *201 * This test will fail on backend since backend's jquery.ui will202 * add ui-dialog-titlebar class anyway on create.203 */204 if ($.ui.version !== '1.9.2') {205 it('check if the title bar is prevented from being created', function () {206 var dialog = $('<div/>'),207 uiClass = '.ui-dialog',208 ui;209 dialog.dropdownDialog({210 'createTitleBar': true211 });212 ui = $(uiClass);213 expect(ui.find('.ui-dialog-titlebar').length > 0).toBeTruthy();214 dialog.dropdownDialog('destroy');215 dialog.dropdownDialog({216 'createTitleBar': false217 });218 ui = $(uiClass);219 expect(ui.find('.ui-dialog-titlebar').length <= 0).toBeTruthy();220 dialog.dropdownDialog('destroy');221 });222 }223 it('check if the position function gets disabled', function () {224 var dialog = $('<div/>'),225 uiClass = '.ui-dialog',226 ui;227 dialog.dropdownDialog({228 'autoPosition': false229 });230 ui = $(uiClass);231 dialog.dropdownDialog('open');232 expect(ui.css('top') === 'auto').toBeTruthy();233 dialog.dropdownDialog('destroy');234 dialog.dropdownDialog({235 'autoPosition': true236 });237 ui = $(uiClass);238 dialog.dropdownDialog('open');239 expect(ui.css('top') !== '0px').toBeTruthy();240 dialog.dropdownDialog('destroy');241 });242 it('check if the size function gets disabled', function () {243 var dialog = $('<div/>'),244 uiClass = '.ui-dialog',245 ui;246 dialog.dropdownDialog({247 'autoSize': true,248 'width': '300'249 });250 ui = $(uiClass);251 dialog.dropdownDialog('open');252 expect(ui.css('width') === '300px').toBeTruthy();253 dialog.dropdownDialog('destroy');254 dialog.dropdownDialog({255 'autoSize': false,256 'width': '300'257 });258 ui = $(uiClass);259 dialog.dropdownDialog('open');260 expect(ui.css('width') === '300px').toBeFalsy();261 dialog.dropdownDialog('destroy');262 });263 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const chrominator = require('chrominator');2(async () => {3 const browser = await chrominator.launch();4 const page = await browser.newPage();5 await page.click('#gbqfbb');6 await page.waitForNavigation();7 await page.type('#lst-ib', 'Test');8 await page.click('input[name="btnK"]');9 await page.waitForNavigation();10 await page.click('div#rso a');11 await page.waitForNavigation();12 await page.click('a[href="

Full Screen

Using AI Code Generation

copy

Full Screen

1const chrominator = require('chrominator')2chrominator.launchBrowser({3}).then(async browser => {4 const page = await browser.newPage()5 await page.click('#tsf > div:nth-child(2) > div > div.RNNXgb > div > div.a4bIc > input')6 await page.type('#tsf > div:nth-child(2) > div > div.RNNXgb > div > div.a4bIc > input', 'Hello World')7 await page.click('#tsf > div:nth-child(2) > div > div.FPdoLc.VlcLAe > center > input[type="submit"]:nth-child(1)')8 await page.waitForNavigation()9 await page.waitForSelector('#rso > div > div > div:nth-child(1) > div > div > div.r > a > h3')10 await page.click('#rso > div > div > div:nth-child(1) > div > div > div.r > a > h3')

Full Screen

Using AI Code Generation

copy

Full Screen

1const chrominator = require('chrominator');2(async () => {3 await chrominator.launch({ headless: false });4 await chrominator.click('#gb_70');5 await chrominator.wait(3000);6 await chrominator.dialog.accept();7 await chrominator.wait(3000);8 await chrominator.close();9})();10- `accept()`11- `dismiss()`12- `typeText()`13- `getText()`14- `getTitle()`15const chrominator = require('chrominator');16(async () => {17 await chrominator.launch({ headless: false });18 await chrominator.click('#gb_70');19 await chrominator.wait(3000);20 await chrominator.cookies.set({ name: 'test', value: 'test' });21 await chrominator.wait(3000);22 await chrominator.close();23})();24- `set()`25- `get()`26- `getAll()`27- `delete()`28- `deleteAll()`29const chrominator = require('chrominator');30(async () => {31 await chrominator.launch({ headless: false });32 await chrominator.emulation.setDeviceMetricsOverride({33 });34 await chrominator.wait(3000);35 await chrominator.close();36})();37- `setDeviceMetricsOverride()`38- `setGeolocationOverride()`39- `setTouchEmulationEnabled()`40- `setEmulatedMedia()`41- `setCPUThrottlingRate()`42- `setUserAgentOverride()`43- `setViewport()`44const chrominator = require('chrominator');45(async () => {46 await chrominator.launch({ headless: false });

Full Screen

Using AI Code Generation

copy

Full Screen

1const chrominator = require('chrominator');2chrominator.run(async ({page, dialog}) => {3 await dialog('alert', 'Hello World!');4});5const chrominator = require('chrominator');6chrominator.run(async ({page, dialog}) => {7 await dialog('confirm', 'Hello World!');8});9const chrominator = require('chrominator');10chrominator.run(async ({page, dialog}) => {11 await dialog('prompt', 'Hello World!');12});13const chrominator = require('chrominator');14chrominator.run(async ({page, dialog}) => {15 await dialog('prompt', 'Hello World!', 'Hello');16});17const chrominator = require('chrominator');18chrominator.run(async ({page, dialog}) => {19 await dialog('prompt', 'Hello World!', 'Hello', 'World');20});21const chrominator = require('chrominator');22chrominator.run(async ({page, dialog}) => {23 await dialog('prompt', 'Hello World!', 'Hello', 'World', '!');24});25const chrominator = require('chrominator');26chrominator.run(async ({page, dialog}) => {27 await dialog('prompt', 'Hello World!', 'Hello', 'World', '!', '!');28});29const chrominator = require('chrominator');30chrominator.run(async ({page, dialog}) => {31 await dialog('prompt', 'Hello World!', 'Hello', 'World', '!', '!', '!');32});

Full Screen

Using AI Code Generation

copy

Full Screen

1module.exports = {2 dialog: async function(browser) {3 var chrominator = require("chrominator");4 var chromy = chrominator.init(browser);5 .type('input[title="Search"]', "Hello world")6 .press("Enter")7 .wait("h1")8 .click("button[title='Create an account']")9 .wait("input[name='username']")10 .type("input[name='username']", "testuser")11 .type("input[name='password']", "testpassword")12 .type("input[name='password2']", "testpassword")13 .click("button[type='submit']")14 .dialog("accept")15 .wait("h1")16 .end();17 }18};

Full Screen

Using AI Code Generation

copy

Full Screen

1var chrominator = require('chrominator');2chrominator.run(function() {3 .click('#gbqfba')4 .dialog('alert', 'hello')5 .dialog('confirm', 'yes')6 .dialog('prompt', 'hello world');7});8### `dialog(type, text)`

Full Screen

Using AI Code Generation

copy

Full Screen

1const chrominator = require('chrominator');2chrominator.run(async (chromy, scenario) => {3 await chromy.click('input[name="btnI"]');4 await chromy.wait(2000);5 const dialog = await chromy.dialog();6 console.log(dialog.text);7});

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