Best JavaScript code snippet using appium-xcuitest-driver
primitives.test.js
Source:primitives.test.js
...31 material: {},32 position: '1 2 3'33 }34 }, function (el) {35 assert.equal(el.getAttribute('geometry').primitive, 'box');36 assert.ok('material' in el.components);37 assert.equal(el.getAttribute('position').x, 1);38 done();39 });40 });41 test('merges defined components with default components', function (done) {42 primitiveFactory({43 defaultComponents: {44 material: {color: '#FFF', metalness: 0.63}45 }46 }, function (el) {47 el.setAttribute('material', 'color', 'tomato');48 var material = el.getAttribute('material');49 assert.equal(material.color, 'tomato');50 assert.equal(material.metalness, 0.63);51 done();52 });53 });54 test('maps attributes to components', function (done) {55 primitiveFactory({56 mappings: {57 color: 'material.color',58 'position-aliased': 'position'59 }60 }, function (el) {61 el.setAttribute('color', 'tomato');62 el.setAttribute('position-aliased', '1 2 3');63 process.nextTick(function () {64 assert.equal(el.getAttribute('material').color, 'tomato');65 assert.equal(el.getAttribute('position').x, 1);66 done();67 });68 });69 });70});71suite('registerPrimitive (using innerHTML)', function () {72 function primitiveFactory (definition, attributes, cb, preCb) {73 var el = helpers.entityFactory();74 var tagName = 'a-test-' + primitiveId++;75 registerPrimitive(tagName, definition);76 if (preCb) { preCb(el.sceneEl); }77 if (cb) {78 el.addEventListener('child-attached', function (evt) {79 evt.detail.el.addEventListener('loaded', function () {80 cb(el.children[0], tagName);81 });82 });83 }84 el.innerHTML = `<${tagName} ${attributes}></${tagName}>`;85 }86 test('prioritizes defined components over default components', function (done) {87 primitiveFactory({88 defaultComponents: {89 material: {color: '#FFF', metalness: 0.63}90 }91 }, 'material="color: tomato"', function (el) {92 var material = el.getAttribute('material');93 assert.equal(material.color, 'tomato');94 assert.equal(material.metalness, 0.63);95 done();96 });97 });98 test('batches default components and mappings for one `init` call', function (done) {99 AFRAME.registerComponent('test', {100 schema: {101 foo: {default: ''},102 qux: {default: ''},103 quux: {default: ''}104 },105 init: function () {106 // Set by default component.107 assert.equal(this.data.foo, 'bar');108 // Set by first mapping.109 assert.equal(this.data.qux, 'qaz');110 // Set by second mapping.111 assert.equal(this.data.quux, 'corge');112 delete AFRAME.components.test;113 done();114 }115 });116 primitiveFactory({117 defaultComponents: {118 test: {foo: 'bar'}119 },120 mappings: {121 qux: 'test.qux',122 quux: 'test.quux'123 }124 }, 'qux="qaz" quux="corge"');125 });126 test('prioritizes mixins over default components', function (done) {127 primitiveFactory({128 defaultComponents: {129 material: {color: 'blue'}130 }131 }, 'mixin="foo"', function postCreation (el) {132 assert.equal(el.getAttribute('material').color, 'red');133 done();134 }, function preCreation (sceneEl) {135 helpers.mixinFactory('foo', {material: 'color: red'}, sceneEl);136 });137 });138 test('merges mixin for multi-prop component', function (done) {139 primitiveFactory({140 defaultComponents: {141 material: {color: 'blue'}142 }143 }, 'mixin="foo"', function postCreation (el) {144 assert.equal(el.getAttribute('material').color, 'blue');145 assert.equal(el.getAttribute('material').shader, 'flat');146 el.setAttribute('material', {side: 'double'});147 assert.equal(el.getAttribute('material').color, 'blue');148 assert.equal(el.getAttribute('material').shader, 'flat');149 assert.equal(el.getAttribute('material').side, 'double');150 done();151 }, function preCreation (sceneEl) {152 helpers.mixinFactory('foo', {material: 'shader: flat'}, sceneEl);153 });154 });155 test('applies boolean mixin', function (done) {156 primitiveFactory({157 defaultComponents: {158 visible: {default: true}159 }160 }, 'mixin="foo"', function postCreation (el) {161 assert.equal(el.getAttribute('visible'), false);162 el.setAttribute('visible', true);163 assert.equal(el.getAttribute('visible'), true);164 done();165 }, function preCreation (sceneEl) {166 helpers.mixinFactory('foo', {visible: false}, sceneEl);167 });168 });169 test('applies single-prop value mixin', function (done) {170 AFRAME.registerComponent('test', {171 schema: {default: 'foo'}172 });173 primitiveFactory({174 defaultComponents: {}175 }, 'mixin="foo"', function postCreation (el) {176 assert.equal(el.getAttribute('test'), 'bar');177 done();178 }, function preCreation (sceneEl) {179 helpers.mixinFactory('foo', {test: 'bar'}, sceneEl);180 });181 });182 test('applies empty mixin', function (done) {183 AFRAME.registerComponent('test', {184 schema: {185 foo: {default: 'foo'},186 bar: {default: 'bar'}187 }188 });189 primitiveFactory({190 defaultComponents: {}191 }, 'mixin="foo"', function postCreation (el) {192 assert.equal(el.getAttribute('test').foo, 'foo');193 assert.equal(el.getAttribute('test').bar, 'bar');194 done();195 }, function preCreation (sceneEl) {196 helpers.mixinFactory('foo', {test: ''}, sceneEl);197 });198 });199 test('prioritizes mapping over mixin', function (done) {200 primitiveFactory({201 defaultComponents: {202 material: {color: 'blue'}203 },204 mappings: {foo: 'material.color'}205 }, 'mixin="bar" foo="purple"', function postCreation (el) {206 assert.equal(el.getAttribute('material').color, 'purple');207 done();208 }, function preCreation (sceneEl) {209 helpers.mixinFactory('bar', {material: 'color: orange'}, sceneEl);210 });211 });212 test('handles mapping to a single-property component', function (done) {213 primitiveFactory({214 mappings: {215 viz: 'visible'216 }217 }, 'viz="false"', function postCreation (el) {218 assert.equal(el.getAttribute('visible'), false);219 done();220 });221 });222 test('handles initializing with a defined multi-property component', function (done) {223 AFRAME.registerComponent('test', {224 schema: {225 foo: {type: 'string'},226 bar: {type: 'number'}227 }228 });229 primitiveFactory({}, 'test="foo: qux; bar: 10"', function postCreation (el) {230 assert.shallowDeepEqual(el.getAttribute('test'), {231 foo: 'qux',232 bar: 10233 });234 delete AFRAME.components.test;235 done();236 });237 });238 test('handles component with dependency', function (done) {239 AFRAME.registerComponent('testdep', {240 schema: {foo: {default: ''}},241 init: function () {242 this.el.setObject3D('test', new THREE.Object3D());243 }244 });245 AFRAME.registerComponent('test', {246 dependencies: ['testdep'],247 schema: {default: ''},248 init: function () {249 assert.ok(this.el.getObject3D('test'), 'testdep should have set this object3D.');250 delete AFRAME.components.test;251 delete AFRAME.components.testdep;252 done();253 }254 });255 primitiveFactory({256 defaultComponents: {257 testdep: {}258 }259 }, 'test=""');260 });261 test('initializes position, rotation, scale', function (done) {262 primitiveFactory({}, '', function (el) {263 assert.shallowDeepEqual(el.getAttribute('position'), {x: 0, y: 0, z: 0});264 assert.shallowDeepEqual(el.getAttribute('rotation'), {x: 0, y: 0, z: 0});265 assert.shallowDeepEqual(el.getAttribute('scale'), {x: 1, y: 1, z: 1});266 done();267 });268 });269 test('with multiple primitives', function (done) {270 var count = 0;271 var el = helpers.entityFactory();272 var tagName = 'a-test-' + primitiveId++;273 registerPrimitive(tagName, {274 defaultComponents: {275 geometry: {primitive: 'plane'},276 material: {}277 },278 mappings: {color: 'material.color'}279 });280 el.addEventListener('child-attached', function (evt) {281 count++;282 if (count >= 2) {283 evt.detail.el.addEventListener('loaded', function () {284 process.nextTick(function () {285 assert.equal(el.children[0].getAttribute('material').color, 'red');286 assert.equal(el.children[1].getAttribute('material').color, 'blue');287 done();288 });289 });290 }291 });292 el.innerHTML = `293 <${tagName} color="red"></${tagName}>294 <${tagName} color="blue"></${tagName}>295 `;296 });297 test('handles updated mixin', function (done) {298 primitiveFactory({299 defaultComponents: {300 material: {color: 'blue'}301 },302 mappings: {foo: 'material.color'}303 }, 'mixin="bar"', function postCreation (el) {304 assert.equal(el.getAttribute('material').color, 'orange');305 document.querySelector('[mixin="bar"]').setAttribute('material', 'color: black');306 process.nextTick(function () {307 assert.equal(el.getAttribute('material').color, 'black');308 el.setAttribute('foo', 'purple');309 setTimeout(function () {310 assert.equal(el.getAttribute('material').color, 'purple');311 done();312 });313 });314 }, function preCreation (sceneEl) {315 helpers.mixinFactory('bar', {material: 'color: orange'}, sceneEl);316 });317 });318 test('resolves mapping collisions', function (done) {319 primitiveFactory({320 defaultComponents: {321 geometry: {primitive: 'box'},322 material: {},323 position: '1 2 3'324 },325 mappings: {visible: 'material.visible'}326 }, '', function (el) {327 assert.equal(el.mappings['material-visible'], 'material.visible');328 assert.notOk(el.mappings['visible']);329 done();330 });331 });332 test('handles mapping not in default components', function (done) {333 primitiveFactory({334 defaultComponents: {},335 mappings: {color: 'material.color'}336 }, '', function (el) {337 el.setAttribute('color', 'blue');338 setTimeout(() => {339 assert.equal(el.getAttribute('material').color, 'blue');340 done();341 });342 });343 });...
flashobject_test.js
Source:flashobject_test.js
...45function getFlashVarsFromElement(flash) {46 var el = flash.getFlashElement();47 // This should work in everything except IE:48 if (el.hasAttribute && el.hasAttribute('flashvars'))49 return el.getAttribute('flashvars');50 // For IE: find and return the value of the correct param element:51 el = el.firstChild;52 while (el) {53 if (el.name == 'FlashVars') {54 return el.value;55 }56 el = el.nextSibling;57 }58 return '';59}60function testInstantiationAndRendering() {61 control.$replayAll();62 var flash = new goog.ui.media.FlashObject(FLASH_URL, domHelper);63 flash.render();64 flash.dispose();65}66function testRenderedWithCorrectAttributes() {67 if (goog.userAgent.IE && !goog.userAgent.isDocumentModeOrHigher(11)) {68 return;69 }70 control.$replayAll();71 var flash = new goog.ui.media.FlashObject(FLASH_URL, domHelper);72 flash.setAllowScriptAccess('allowScriptAccess');73 flash.setBackgroundColor('backgroundColor');74 flash.setId('id');75 flash.setFlashVars({'k1': 'v1', 'k2': 'v2'});76 flash.setWmode('wmode');77 flash.render();78 var el = flash.getFlashElement();79 assertEquals('true', el.getAttribute('allowFullScreen'));80 assertEquals('all', el.getAttribute('allowNetworking'));81 assertEquals('allowScriptAccess', el.getAttribute('allowScriptAccess'));82 assertEquals(83 goog.ui.media.FlashObject.FLASH_CSS_CLASS, el.getAttribute('class'));84 assertEquals('k1=v1&k2=v2', el.getAttribute('FlashVars'));85 assertEquals('id', el.getAttribute('id'));86 assertEquals('id', el.getAttribute('name'));87 assertEquals(88 'https://www.macromedia.com/go/getflashplayer',89 el.getAttribute('pluginspage'));90 assertEquals('high', el.getAttribute('quality'));91 assertEquals('false', el.getAttribute('SeamlessTabbing'));92 assertEquals(FLASH_URL.getTypedStringValue(), el.getAttribute('src'));93 assertEquals('application/x-shockwave-flash', el.getAttribute('type'));94 assertEquals('wmode', el.getAttribute('wmode'));95}96function testRenderedWithCorrectAttributesOldIe() {97 if (!goog.userAgent.IE || goog.userAgent.isDocumentModeOrHigher(11)) {98 return;99 }100 control.$replayAll();101 var flash = new goog.ui.media.FlashObject(FLASH_URL, domHelper);102 flash.setAllowScriptAccess('allowScriptAccess');103 flash.setBackgroundColor('backgroundColor');104 flash.setId('id');105 flash.setFlashVars({'k1': 'v1', 'k2': 'v2'});106 flash.setWmode('wmode');107 flash.render();108 var el = flash.getFlashElement();109 assertEquals(110 'class', goog.ui.media.FlashObject.FLASH_CSS_CLASS,111 el.getAttribute('class'));112 assertEquals(113 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000', el.getAttribute('classid'));114 assertEquals('id', 'id', el.getAttribute('id'));115 assertEquals('name', 'id', el.getAttribute('name'));116 assertContainsParam(el, 'allowFullScreen', 'true');117 assertContainsParam(el, 'allowNetworking', 'all');118 assertContainsParam(el, 'AllowScriptAccess', 'allowScriptAccess');119 assertContainsParam(el, 'bgcolor', 'backgroundColor');120 assertContainsParam(el, 'FlashVars', 'FlashVars');121 assertContainsParam(el, 'movie', FLASH_URL);122 assertContainsParam(el, 'quality', 'high');123 assertContainsParam(el, 'SeamlessTabbing', 'false');124 assertContainsParam(el, 'wmode', 'wmode');125}126function assertContainsParam(element, expectedName, expectedValue) {127 var failureMsg = 'Expected param with name \"' + expectedName +128 '\" and value \"' + expectedValue + '\". Not found in child nodes: ' +129 element.innerHTML;...
AjaxHelper.js
Source:AjaxHelper.js
...6 function (e) {7 8 e.preventDefault();9 let el = e.currentTarget;10 let ajaxAction = el.getAttribute("action");11 let ajaxMethod = el.getAttribute("data-method");12 let ajaxFailureFunction = el.getAttribute("failure-func");13 let ajaxSuccessFunction = el.getAttribute("success-func");14 let ajaxContentType = el.getAttribute("data-content-type");15 let ajaxDataId = el.getAttribute("data-id");16 let ajaxDataArea = el.getAttribute("data-area");17 let ajaxAlert = el.getAttribute("ajax-alert");18 if (ajaxAlert === "true") {19 swal({20 21 title: el.getAttribute("alert-title"),22 text: el.getAttribute("alert-text"), //"در صÙرت Øذ٠رکÙØ±Ø¯Ø Ø¯Ûگر Ùاب٠بازÛØ§Ø¨Û ÙÙ
Û Ø¨Ø§Ø´Ø¯!", 23 type: el.getAttribute("alert-type"),24 showCancelButton: true,25 confirmButtonColor: "#e6b034",26 confirmButtonText: el.getAttribute("alert-confirm"), //"بÙÙØ Øذ٠بشÙ!", 27 cancelButtonText: el.getAttribute("alert-cancel"), // "ÙÙØ Ùغ٠بشÙ!", 28 closeOnConfirm: false,29 closeOnCancel: false30 }, function (isConfirm) {31 if (isConfirm) {32 $.ajax({33 url: "/" + ajaxDataArea + ajaxAction + "/" + ajaxDataId ,34 type: ajaxMethod,35 processData: false, // Important!36 contentType: false,37 cache: false,38 //contentType:ajaxContentType,39 40 success: function (data) {41 42 if (ajaxSuccessFunction !== "") {43 swal({44 title: data.title,45 type: data.type,46 text: data.message,47 timer: 3000,48 showConfirmButton: false49 });50 51 window[ajaxSuccessFunction](data);52 } else {53 54 swal({55 title: data.title,56 type: data.type,57 text: data.message,58 timer: 3000,59 showConfirmButton: false60 });61 62 }63 },64 error: function (data) {65 if (ajaxFailureFunction !== "") {66 67 window[ajaxFailureFunction](data);68 } else {69 swal({70 title: "خطا!",71 type: "error",72 text: "Ø®Ø·Ø§Û ØºÛر Ùاب٠پÛØ´ بÛÙÛØ Ø¨Ø§ پشتÛباÙÛ ØªÙ
اس بگÛرÛد! ",73 confirmButtonText: "بÙÙØ ØتÙ
ا"74 });75 76 }77 }78 });79 }80 else {81 swal({82 title: "ÙغÙ!",83 type: "error",84 text: "عÙ
ÙÛات تÙسط Ø´Ù
ا Ùغ٠شدØ",85 confirmButtonText: "بÙÙ"86 });87 }88 });89 } else {90 $.ajax({91 url: "/" + ajaxDataArea + ajaxAction + "/" + ajaxDataId,92 type: ajaxMethod,93 processData: false, // Important!94 contentType: false,95 cache: false,96 success: function (data) {97 if (ajaxSuccessFunction !== "") {98 window[ajaxSuccessFunction](data);99 } else {100 alert("success");101 }102 },103 error: function (data) {104 if (ajaxFailureFunction !== "") {105 106 window[ajaxFailureFunction](data);107 } else {108 alert("Error");109 }110 }111 });112 }113 });114}115var elements = document.querySelectorAll(".ajaxForm");116for (let i = 0; i < elements.length; i++) {117 elements[i].classList.remove("ajaxForm");118 elements[i].addEventListener("submit",119 function (e) {120 debugger;121 e.preventDefault();122 var isAllow = true;123 let el = e.currentTarget;124 let formData = new FormData(this);125 $(el).find("input[name]").each(function (index, node) {126 formData.append(node.name, node.value);127 if (node.value === "" || node.value === null) {128 node.style.borderColor = "red";129 node.addEventListener('change', function (e) {130 if (e.srcElement.value.trim() === "" || e.srcElement.value === null) {131 e.srcElement.setAttribute("style", "border-color:red");132 }133 else { e.srcElement.removeAttribute("style"); }134 });135 isAllow = false;136 }137 });138 let ajaxAction = el.getAttribute("action");139 let ajaxMethod = el.getAttribute("method");140 let ajaxFailureFunction = el.getAttribute("failure-func");141 let ajaxSuccessFunction = el.getAttribute("success-func");142 let enctype = el.getAttribute("enctype");143 let autoReset = el.getAttribute("data-autoReset");144 if (isAllow === true) {145 $.ajax({146 url: ajaxAction,147 type: ajaxMethod,148 processData: false, // Important!149 contentType: false,150 cache: false,151 enctype: enctype,152 data: formData,153 success: function (data) {154 if (ajaxSuccessFunction !== "") {155 window[ajaxSuccessFunction](data);156 if (autoReset === "True") {157 $(el).find("input[name]").each(function (index, node) {...
Ext.Forms.js
Source:Ext.Forms.js
...141 }142 return true;143 }, input:function(el) {144 var object = new this.Form.TextField({145 allowBlank : el.getAttribute("allowblank") == undefined ? false : eval(el.getAttribute("allowblank")),146 vtype : el.getAttribute("vtype"),147 cls : el.type == "password" ? el.getAttribute("cls") : null,148 //width : el.getAttribute("vwidth") ? null : null,149 id : el.id,150 name : el.id,151 style : (el.getAttribute("vtype") == "integer" || el.getAttribute("vtype") == "number" ? "text-align: right;" : ""),152 readOnly : el.readOnly,153 defValue : el.getAttribute("defvalue"),154 alt : el.alt,155 maxLength : el.getAttribute("maxlength") ? el.getAttribute("maxlength") : Number.MAX_VALUE,156 minLength : el.getAttribute("minlength") ? el.getAttribute("minlength") : 0,157 minValue : el.getAttribute("minvalue") ? el.getAttribute("minvalue") : 0,158 maxValue : el.getAttribute("maxvalue") ? el.getAttribute("maxvalue") : Number.MAX_VALUE159 });160 if(el.readOnly) {161 object.style += "color:#656B86;";162 }163 if(el.value != "" && el.format == "date") {164 el.value = datagrids[0].date(el.value);165 }166 if(this.isApply) {167 object.applyTo(el.id);168 }169 if(el.getAttribute("defvalue")) {170 object.setValue(el.getAttribute("defvalue"));171 }172 return object;173 }, date : function(el) {174 var object = new this.Form.DateField({175 id : el.id,176 name : el.id,177 allowBlank : el.getAttribute("allowblank") == undefined ? false : eval(el.getAttribute("allowblank")),178 format : (el.getAttribute("format") ? el.getAttribute("format") : "Yå¹´mædæ¥"),179 readOnly : true,180 //width : el.getAttribute("vwidth") ? null : null,181 defValue : el.getAttribute("defvalue"),182 vType : "date",183 alt : el.alt,184 setAllMonth : (el.setAllMonth ? el.setAllMonth : false)185 });186 if(this.isApply) {187 object.applyTo(el.id);188 }189 if(el.getAttribute("defvalue")) {190 object.setValue(el.getAttribute("defvalue"));191 } else {192 object.setValue(nowDate);193 }194 return object;195 }196});197var Forms = new Ext.Forms();
...
tree.js
Source:tree.js
...85 for (var x = 0; x < node.childNodes.length; x++) {86 var el = node.childNodes[x];87 if (el.nodeName == 'folder') {88 if(this.home==''){89 this.home = el.getAttribute('ref');90 //this.activenode = el.getAttribute('ref');91 } 92 this.n++;93 var f = document.createElement("div");94 f.className = "node";95 var html = "<div style='overflow:hidden;width:1000px;'><div class='toggle closed' id='toggle"+el.getAttribute('ref')96 +"' onclick='tree.togglenode("+el.getAttribute('ref')+")'></div><div id='"+"treelabel"97 +el.getAttribute('ref')+"' class='closelabel' onclick='tree.click(\""98 +el.getAttribute('ref')+"\");' onselectstart='return false;' ondblclick='tree.togglenode("+el.getAttribute('ref')+")'>"99 +el.getAttribute('label')+"</div></div>";100 var b = document.createElement("div");101 b.id = "treenode"+el.getAttribute('ref');102 f.innerHTML = html; 103 f.appendChild(b); 104 b.style.display = "none"; 105 106 if(el.getAttribute('ref') != "")107 this.nodes[el.getAttribute('ref')] = {"ref": el.getAttribute('ref'), "id" : "treelabel"+el.getAttribute('ref'), label : el.getAttribute('label'),"pid" : parent.id, "owner" : pref};108 109 this.parseTree(el,b,el.getAttribute('ref'));110 parent.appendChild(f);111 }112 113 if (el.nodeName == 'leaf') {114 if(this.home=='') this.home = el.getAttribute('ref');115 this.n++;116 var l = document.createElement("div");117 l.innerHTML = "<div style='overflow:hidden;width:1000px;'><div id='"+"treelabel"+el.getAttribute('ref')+"' class='leaf' onclick='tree.click(\""118 +el.getAttribute('ref')+"\");' onselectstart='return false;'>"119 +el.getAttribute('label')+"</div></div>";120 var ref = l.getAttribute('ref');121 parent.appendChild(l);122 if(el.getAttribute('ref') != "")123 this.nodes[el.getAttribute('ref')] = {id : "treelabel"+el.getAttribute('ref'), label : el.getAttribute('label'),pid : parent.id, owner : pref};124 }125 }126 127 },128 129 togglenode : function (id){130 var n = document.getElementById("treenode"+id);131 var s = document.getElementById("treelabel"+id);132 var t = document.getElementById("toggle"+id);133 if(n.style.display=='block'){134 n.style.display = 'none'; 135 s.className="closelabel";136 t.className="toggle closed"137 }else{...
elements.spec.js
Source:elements.spec.js
...10 describe('Initialization', function () {11 it('should set element contenteditable attribute to true', function () {12 var editor = this.newMediumEditor('.editor');13 expect(editor.elements.length).toBe(1);14 expect(this.el.getAttribute('contenteditable')).toEqual('true');15 });16 it('should not set element contenteditable when disableEditing is true', function () {17 var editor = this.newMediumEditor('.editor', {18 disableEditing: true19 });20 expect(editor.elements.length).toBe(1);21 expect(this.el.getAttribute('contenteditable')).toBeFalsy();22 });23 it('should not set element contenteditable when data-disable-editing is true', function () {24 this.el.setAttribute('data-disable-editing', true);25 var editor = this.newMediumEditor('.editor');26 expect(editor.elements.length).toBe(1);27 expect(this.el.getAttribute('contenteditable')).toBeFalsy();28 });29 it('should set element data attr medium-editor-element to true and add medium-editor-element class', function () {30 var editor = this.newMediumEditor('.editor');31 expect(editor.elements.length).toBe(1);32 expect(this.el.getAttribute('data-medium-editor-element')).toEqual('true');33 expect(this.el.className).toBe('editor medium-editor-element');34 });35 it('should set element role attribute to textbox', function () {36 var editor = this.newMediumEditor('.editor');37 expect(editor.elements.length).toBe(1);38 expect(this.el.getAttribute('role')).toEqual('textbox');39 });40 it('should set element aria multiline attribute to true', function () {41 var editor = this.newMediumEditor('.editor');42 expect(editor.elements.length).toBe(1);43 expect(this.el.getAttribute('aria-multiline')).toEqual('true');44 });45 it('should set the data-medium-editor-editor-index attribute to be the id of the editor instance', function () {46 var editor = this.newMediumEditor('.editor');47 expect(editor.elements[0]).toBe(this.el);48 expect(parseInt(this.el.getAttribute('data-medium-editor-editor-index'))).toBe(editor.id);49 });50 });51 describe('Destroy', function () {52 it('should remove the contenteditable attribute', function () {53 var editor = this.newMediumEditor('.editor');54 expect(this.el.getAttribute('contenteditable')).toEqual('true');55 editor.destroy();56 expect(this.el.hasAttribute('contenteditable')).toBe(false);57 });58 it('should remove the medium-editor-element attribute and class name', function () {59 this.el.classList.add('temp-class');60 expect(this.el.className).toBe('editor temp-class');61 var editor = this.newMediumEditor('.editor');62 expect(this.el.getAttribute('data-medium-editor-element')).toEqual('true');63 expect(this.el.className).toBe('editor temp-class medium-editor-element');64 editor.destroy();65 expect(this.el.hasAttribute('data-medium-editor-element')).toBe(false);66 expect(this.el.className).toBe('editor temp-class');67 });68 it('should remove the role attribute', function () {69 var editor = this.newMediumEditor('.editor');70 expect(this.el.getAttribute('role')).toEqual('textbox');71 editor.destroy();72 expect(this.el.hasAttribute('role')).toBe(false);73 });74 it('should remove the aria-multiline attribute', function () {75 var editor = this.newMediumEditor('.editor');76 expect(this.el.getAttribute('aria-multiline')).toEqual('true');77 editor.destroy();78 expect(this.el.hasAttribute('aria-multiline')).toBe(false);79 });80 it('should remove the data-medium-editor-editor-index attribute', function () {81 var editor = this.newMediumEditor('.editor');82 expect(parseInt(this.el.getAttribute('data-medium-editor-editor-index'))).toBe(editor.id);83 editor.destroy();84 expect(this.el.hasAttribute('data-medium-editor-editor-index')).toBe(false);85 });86 });...
image.spec.js
Source:image.spec.js
...23 components: {24 CImage25 }26 })27 expect(vm.$children[0].$el.getAttribute('src')).to.have.string('data:image')28 expect(vm.$children[1].$el.getAttribute('src')).to.equal('#@1x')29 expect(vm.$children[2].$el.getAttribute('src')).to.equal('#@2x')30 expect(vm.$children[3].$el.getAttribute('src')).to.equal('#@3x')31 })32 it('dpr: 1', () => {33 vm = new Vue({34 el,35 template: `<div>36 <c-image :flexible="1" :width="10" src="#@1x"></c-image>37 <c-image :flexible="1" :height="10" src="#@2x"></c-image>38 <c-image :flexible="1" :width="10" :height="10" src="#@3x"></c-image>39 </div>`,40 components: {41 CImage42 }43 })44 expect(vm.$children[0].$el.getAttribute('src')).to.equal('#@1x')45 expect(vm.$children[0].$el.getAttribute('width')).to.equal('5')46 expect(vm.$children[1].$el.getAttribute('src')).to.equal('#@1x')47 expect(vm.$children[1].$el.getAttribute('height')).to.equal('5')48 expect(vm.$children[2].$el.getAttribute('src')).to.equal('#@1x')49 expect(vm.$children[2].$el.getAttribute('width')).to.equal('5')50 expect(vm.$children[2].$el.getAttribute('height')).to.equal('5')51 })52 it('dpr: 2', () => {53 vm = new Vue({54 el,55 template: `<div>56 <c-image :flexible="2" :width="10" src="#@1x"></c-image>57 <c-image :flexible="2" :height="10" src="#@2x"></c-image>58 <c-image :flexible="2" :width="10" :height="10" src="#@3x"></c-image>59 </div>`,60 components: {61 CImage62 }63 })64 expect(vm.$children[0].$el.getAttribute('src')).to.equal('#@2x')65 expect(vm.$children[0].$el.getAttribute('width')).to.equal('10')66 expect(vm.$children[1].$el.getAttribute('src')).to.equal('#@2x')67 expect(vm.$children[1].$el.getAttribute('height')).to.equal('10')68 expect(vm.$children[2].$el.getAttribute('src')).to.equal('#@2x')69 expect(vm.$children[2].$el.getAttribute('width')).to.equal('10')70 expect(vm.$children[2].$el.getAttribute('height')).to.equal('10')71 })72 it('dpr: 3', () => {73 vm = new Vue({74 el,75 template: `<div>76 <c-image :flexible="3" :width="10" src="#@1x"></c-image>77 <c-image :flexible="3" :height="10" src="#@2x"></c-image>78 <c-image :flexible="3" :width="10" :height="10" src="#@3x"></c-image>79 </div>`,80 components: {81 CImage82 }83 })84 expect(vm.$children[0].$el.getAttribute('src')).to.equal('#@3x')85 expect(vm.$children[0].$el.getAttribute('width')).to.equal('15')86 expect(vm.$children[1].$el.getAttribute('src')).to.equal('#@3x')87 expect(vm.$children[1].$el.getAttribute('height')).to.equal('15')88 expect(vm.$children[2].$el.getAttribute('src')).to.equal('#@3x')89 expect(vm.$children[2].$el.getAttribute('width')).to.equal('15')90 expect(vm.$children[2].$el.getAttribute('height')).to.equal('15')91 })...
wh.social.twitter.widget.js
Source:wh.social.twitter.widget.js
...56{57 el=$(el);58 if(el.retrieve("wh-twitter-widget"))59 return el.retrieve("wh-twitter-widget");60 var opts = { showprofileimage: ['true','1'].contains(el.getAttribute("data-showprofileimage"))61 , showpostdate: ['true','1'].contains(el.getAttribute("data-showpostdate"))62 , query: el.getAttribute("data-query")63 , linktarget: el.getAttribute("data-linktarget")64 , showretweetlink: el.getAttribute("data-showretweetlink")65 , showreplylink: el.getAttribute("data-showreplylink")66 , replylabel: el.getAttribute("data-replylabel")67 , retweetlabel: el.getAttribute("data-retweetlabel")68 };69 if(el.getAttribute('data-maxitems'))70 opts.maxitems = parseInt(el.getAttribute('data-maxitems'));71 return new $wh.TwitterWidget(el, opts);72};73$(window).addEvent("domready", function()74{75 $$('.-wh-twitter-widget, .wh-twitter-widget').each($wh.setupElementAsTwitterWidget);76});...
Using AI Code Generation
1const wd = require('wd');2const chai = require('chai');3const chaiAsPromised = require('chai-as-promised');4chai.use(chaiAsPromised);5const assert = chai.assert;6const should = chai.should();7const expect = chai.expect;8const caps = {
Using AI Code Generation
1const wdio = require("webdriverio");2const assert = require("assert");3const opts = {4 capabilities: {5 }6};7async function main() {8 const client = await wdio.remote(opts);9 const el = await client.$("~MyButton");10 const attribute = await el.getAttribute("enabled");11 assert.strictEqual(attribute, true);12 await client.deleteSession();13}14main();15const el = await client.$("XCUIElementTypeButton");
Using AI Code Generation
1var el = driver.findElement(By.id('test'));2var value = el.getAttribute('value');3console.log(value);4el = self.driver.find_element_by_id('test')5value = el.get_attribute('value')6print(value)
Using AI Code Generation
1const attribute = await el.getAttribute('name');2console.log(attribute);3const attribute = await el.getAttribute('name');4console.log(attribute);5const attribute = await el.getAttribute('name');6console.log(attribute);7const attribute = await el.getAttribute('name');8console.log(attribute);9const attribute = await el.getAttribute('name');10console.log(attribute);11const attribute = await el.getAttribute('name');12console.log(attribute);13const attribute = await el.getAttribute('name');14console.log(attribute);15const attribute = await el.getAttribute('name');16console.log(attribute);17const attribute = await el.getAttribute('name');18console.log(attribute);19const attribute = await el.getAttribute('name');20console.log(attribute);21const attribute = await el.getAttribute('name');22console.log(attribute);
Using AI Code Generation
1const el = await driver.findElementByAccessibilityId('test-ADD TO CART');2const value = await el.getAttribute('name');3console.log(value);4const el = await driver.findElementByAccessibilityId('test-ADD TO CART');5const value = await el.getAttribute('contentDescription');6console.log(value);
Using AI Code Generation
1var el = driver.findElement(By.id('someId'));2var value = el.getAttribute('value');3console.log(value);4var el = driver.findElement(By.id('someId'));5var name = el.getAttribute('name');6console.log(name);7var el = driver.findElement(By.id('someId'));8var label = el.getAttribute('label');9console.log(label);10var el = driver.findElement(By.id('someId'));11var type = el.getAttribute('type');12console.log(type);13var el = driver.findElement(By.id('someId'));14var rect = el.getAttribute('rect');15console.log(rect);16var el = driver.findElement(By.id('someId'));17var enabled = el.getAttribute('enabled');18console.log(enabled);19var el = driver.findElement(By.id('someId'));20var valid = el.getAttribute('valid');21console.log(valid);22var el = driver.findElement(By.id('someId'));23var visible = el.getAttribute('visible');24console.log(visible);25var el = driver.findElement(By.id('someId
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!