Best JavaScript code snippet using appium-xcuitest-driver
QuickTag.js
Source:QuickTag.js
...204 *205 * @param {Object} $valueSelect206 */207 captureClasses: function ($valueSelect) {208 this.parseCssRule(this.editor.document.styleSheets, $valueSelect);209 },210 /**211 * @param {Object} rules212 * @param {Object} $valueSelect213 */214 parseCssRule: function (rules, $valueSelect) {215 for (var i = 0, n = rules.length; i < n; i++) {216 var rule = rules[i];217 if (rule.selectorText) {218 if (/^(\w*)\.(\w+)$/.test(rule.selectorText)) {219 $valueSelect.append(220 $('<option />', {221 value: RegExp.$2 + '"',222 'data-attribute': 'class'223 }).text(rule.selectorText)224 );225 }226 } else {227 // ImportRule (Mozilla)228 if (rule.styleSheet) {229 try {230 if (rule.styleSheet.cssRules) {231 this.parseCssRule(rule.styleSheet.cssRules, $valueSelect);232 }233 } catch (e) {234 if (/Security/i.test(e)) {235 this.appendToLog('parseCssRule', 'A security error occurred. Make sure all stylesheets are accessed from the same domain/subdomain and using the same protocol as the current script.', 'error');236 } else {237 throw e;238 }239 }240 }241 // MediaRule (Mozilla)242 if (rule.cssRules) {243 this.parseCssRule(rule.cssRules, $valueSelect);244 }245 // IE imports246 if (rule.imports) {247 this.parseCssRule(rule.imports, $valueSelect);248 }249 if (rule.rules) {250 this.parseCssRule(rule.rules, $valueSelect);251 }252 }253 }254 },255 /**256 * Handler invoked when a tag is selected257 * Update the attributes combo and the inserted tag field258 *259 * @param {Event} e260 */261 onTagSelect: function (e) {262 var $me = $(e.currentTarget),263 tag = decodeURI($me.val());264 this.filterAttributes(e);...
quick-tag.js
Source:quick-tag.js
...216 /*217 * Add a record for each class selector found in the stylesheets218 */219 captureClasses: function (valueStore) {220 this.parseCssRule(this.editor.document.styleSheets, valueStore);221 },222 parseCssRule: function (rules, valueStore) {223 Ext.each(rules, function (rule) {224 if (rule.selectorText) {225 if (/^(\w*)\.(\w+)$/.test(rule.selectorText)) {226 valueStore.add(new this.valueRecord({227 attribute: 'class',228 text: rule.selectorText,229 value: RegExp.$2 + '"'230 }));231 }232 } else {233 // ImportRule (Mozilla)234 if (rule.styleSheet) {235 try {236 this.parseCssRule(rule.styleSheet.cssRules, valueStore);237 } catch (e) {238 if (/Security/i.test(e)) {239 this.appendToLog('parseCssRule', 'A security error occurred. Make sure all stylesheets are accessed from the same domain/subdomain and using the same protocol as the current script.', 'error');240 }241 }242 }243 // MediaRule (Mozilla)244 if (rule.cssRules) {245 this.parseCssRule(rule.cssRules, valueStore);246 }247 // IE imports248 if (rule.imports) {249 this.parseCssRule(rule.imports, valueStore);250 }251 if (rule.rules) {252 this.parseCssRule(rule.rules, valueStore);253 }254 }255 }, this);256 },257 /*258 * Handler invoked when a tag is selected259 * Update the attributes combo and the inserted tag field260 */261 onTagSelect: function (tagCombo, tagRecord) {262 var tag = tagRecord.get('value');263 this.filterAttributes();264 this.attributeCombo.clearValue();265 this.attributeCombo.show();266 this.valueCombo.hide();...
text-style.js
Source:text-style.js
...278 this.cssLoaded = true;279 for (var i = 0; i < iframe.styleSheets.length; i++) {280 if (!Ext.isIE) {281 try {282 newCssArray = this.parseCssRule(iframe.styleSheets[i].cssRules, newCssArray);283 } catch(e) {284 this.cssLoaded = false;285 }286 } else {287 try{288 // @import StyleSheets (IE)289 if (iframe.styleSheets[i].imports) {290 newCssArray = this.parseCssIEImport(iframe.styleSheets[i].imports, newCssArray);291 }292 if (iframe.styleSheets[i].rules) {293 newCssArray = this.parseCssRule(iframe.styleSheets[i].rules, newCssArray);294 }295 } catch(e) {296 this.cssLoaded = false;297 }298 }299 }300 return newCssArray;301 },302 303 parseCssIEImport : function(cssIEImport, cssArray) {304 var newCssArray = new Object();305 newCssArray = cssArray;306 for (var i=0; i < cssIEImport.length; i++) {307 if (cssIEImport[i].imports) {308 newCssArray = this.parseCssIEImport(cssIEImport[i].imports, newCssArray);309 }310 if (cssIEImport[i].rules) {311 newCssArray = this.parseCssRule(cssIEImport[i].rules, newCssArray);312 }313 }314 return newCssArray;315 },316 317 parseCssRule : function(cssRules, cssArray) {318 var newCssArray = new Object();319 newCssArray = cssArray;320 for (var rule = 0; rule < cssRules.length; rule++) {321 // StyleRule322 if (cssRules[rule].selectorText) {323 newCssArray = this.parseSelectorText(cssRules[rule].selectorText, newCssArray);324 } else {325 // ImportRule (Mozilla)326 if (cssRules[rule].styleSheet) {327 newCssArray = this.parseCssRule(cssRules[rule].styleSheet.cssRules, newCssArray);328 }329 // MediaRule (Mozilla)330 if (cssRules[rule].cssRules) {331 newCssArray = this.parseCssRule(cssRules[rule].cssRules, newCssArray);332 }333 }334 }335 return newCssArray;336 },337 338 parseSelectorText : function(selectorText, cssArray) {339 var cssElements = new Array();340 var cssElement = new Array();341 var tagName, className;342 var newCssArray = new Object();343 newCssArray = cssArray;344 if (selectorText.search(/:+/) == -1) {345 // split equal Styles (Mozilla-specific) e.q. head, body {border:0px}...
block-style.js
Source:block-style.js
...481 this.cssLoaded = true;482 for (var i = 0; i < iframe.styleSheets.length; i++) {483 if (!Ext.isIE) {484 try {485 newCssArray = this.parseCssRule(iframe.styleSheets[i].cssRules, newCssArray);486 } catch(e) {487 this.cssLoaded = false;488 }489 } else {490 try{491 // @import StyleSheets (IE)492 if (iframe.styleSheets[i].imports) {493 newCssArray = this.parseCssIEImport(iframe.styleSheets[i].imports, newCssArray);494 }495 if (iframe.styleSheets[i].rules) {496 newCssArray = this.parseCssRule(iframe.styleSheets[i].rules, newCssArray);497 }498 } catch(e) {499 this.cssLoaded = false;500 }501 }502 }503 return newCssArray;504 },505 506 /*507 * This function parses IE import rules508 */509 parseCssIEImport : function(cssIEImport, cssArray) {510 var newCssArray = new Object();511 newCssArray = cssArray;512 for (var i=0; i < cssIEImport.length; i++) {513 if (cssIEImport[i].imports) {514 newCssArray = this.parseCssIEImport(cssIEImport[i].imports, newCssArray);515 }516 if (cssIEImport[i].rules) {517 newCssArray = this.parseCssRule(cssIEImport[i].rules, newCssArray);518 }519 }520 return newCssArray;521 },522 523 /*524 * This function parses gecko css rules525 */526 parseCssRule : function(cssRules, cssArray) {527 var newCssArray = new Object();528 newCssArray = cssArray;529 for (var rule = 0; rule < cssRules.length; rule++) {530 // StyleRule531 if (cssRules[rule].selectorText) {532 newCssArray = this.parseSelectorText(cssRules[rule].selectorText, newCssArray);533 } else {534 // ImportRule (Mozilla)535 if (cssRules[rule].styleSheet) {536 newCssArray = this.parseCssRule(cssRules[rule].styleSheet.cssRules, newCssArray);537 }538 // MediaRule (Mozilla)539 if (cssRules[rule].cssRules) {540 newCssArray = this.parseCssRule(cssRules[rule].cssRules, newCssArray);541 }542 }543 }544 return newCssArray;545 },546 547 /*548 * This function parses each selector rule549 */550 parseSelectorText : function(selectorText, cssArray) {551 var cssElements = new Array();552 var cssElement = new Array();553 var tagName, className;554 var newCssArray = new Object();...
cssHoverForOldBrowser.js
Source:cssHoverForOldBrowser.js
1window.CSSHover = (function(){2 var REG_INTERACTIVE = /(^|\s)((([^a]([^ ]+)?)|(a([^#.][^ ]+)+)):(hover|active|focus))/i,3 REG_AFFECTED = /(.*?)\:(hover|active|focus)/i,4 REG_PSEUDO = /[^:]+:([a-z-]+).*/i,5 REG_SELECT = /(\.([a-z0-9_-]+):[a-z]+)|(:[a-z]+)/gi,6 REG_CLASS = /\.([a-z0-9_-]*on(hover|active|focus))/i,7 REG_MSIE = /msie (5|6|7)/i,8 REG_COMPAT = /backcompat/i;9 var CSSHOVER_PREFIX = 'csh-';10 var CSSHover = {11 elements: [],12 callbacks: {},13 init:function() {14 if(!REG_MSIE.test(navigator.userAgent) && !REG_COMPAT.test(window.document.compatMode)) return;15 var sheets = window.document.styleSheets, l = sheets.length;16 for(var i=0; i<l; i++) {17 this.parseStylesheet(sheets[i]);18 }19 },20 parseStylesheet:function(sheet) {21 if(sheet.imports) {22 try {23 var imports = sheet.imports, l = imports.length;24 for(var i=0; i<l; i++) {25 this.parseStylesheet(sheet.imports[i]);26 }27 } catch(securityException){}28 }29 try {30 var rules = sheet.rules, l = rules.length;31 for(var j=0; j<l; j++) {32 this.parseCSSRule(rules[j], sheet);33 }34 } catch(securityException){}35 },36 parseCSSRule:function(rule, sheet) {37 var select = rule.selectorText;38 if(REG_INTERACTIVE.test(select)) {39 var style = rule.style.cssText,40 affected = REG_AFFECTED.exec(select)[1],41 pseudo = select.replace(REG_PSEUDO, 'on$1'),42 newSelect = select.replace(REG_SELECT, '.$2' + pseudo),43 className = REG_CLASS.exec(newSelect)[1];44 var hash = affected + className;45 if(!this.callbacks[hash]) {46 sheet.addRule(affected, CSSHOVER_PREFIX + className + ':expression(CSSHover(this, "'+pseudo+'", "'+className+'"))');47 this.callbacks[hash] = true;48 }49 sheet.addRule(newSelect, style);50 }51 },52 patch:function(node, type, className) {53 var property = CSSHOVER_PREFIX + className;54 if(node.style[property]) {55 node.style[property] = null;56 }57 if(!node.csshover) node.csshover = [];58 if(!node.csshover[className]) {59 node.csshover[className] = true;60 var element = new CSSHoverElement(node, type, className);61 this.elements.push(element);62 }63 return type;64 },65 unload:function() {66 try {67 var l = this.elements.length;68 for(var i=0; i<l; i++) {69 this.elements[i].unload();70 }71 this.elements = [];72 this.callbacks = {};73 } catch (e) {74 }75 }76 };77 window.attachEvent('onbeforeunload', function(){78 CSSHover.unload();79 });80 var CSSEvents = {81 onhover: { activator: 'onmouseenter', deactivator: 'onmouseleave' },82 onactive: { activator: 'onmousedown', deactivator: 'onmouseup' },83 onfocus: { activator: 'onfocus', deactivator: 'onblur' }84 };85 function CSSHoverElement(node, type, className) {86 this.node = node;87 this.type = type;88 var replacer = new RegExp('(^|\\s)'+className+'(\\s|$)', 'g');89 this.activator = function(){ node.className += ' ' + className; };90 this.deactivator = function(){ node.className = node.className.replace(replacer, ' '); };91 node.attachEvent(CSSEvents[type].activator, this.activator);92 node.attachEvent(CSSEvents[type].deactivator, this.deactivator);93 }94 CSSHoverElement.prototype = {95 unload:function() {96 this.node.detachEvent(CSSEvents[this.type].activator, this.activator);97 this.node.detachEvent(CSSEvents[this.type].deactivator, this.deactivator);98 this.activator = null;99 this.deactivator = null;100 this.node = null;101 this.type = null;102 }103 };104 return function(node, type, className) {105 if(node) {106 return CSSHover.patch(node, type, className);107 } else {108 CSSHover.init();109 }110 };
...
csshover.js
Source:csshover.js
1<attach event="ondocumentready" handler="parseStylesheets" />2<script>3/**4 * Whatever:hover - V2.02.060206 - hover, active & focus5 * ------------------------------------------------------------6 * (c) 2005 - Peter Nederlof7 * Peterned - http://www.xs4all.nl/~peterned/8 * License - http://creativecommons.org/licenses/LGPL/2.1/9 *10 * Whatever:hover is free software; you can redistribute it and/or11 * modify it under the terms of the GNU Lesser General Public12 * License as published by the Free Software Foundation; either13 * version 2.1 of the License, or (at your option) any later version.14 *15 * Whatever:hover is distributed in the hope that it will be useful,16 * but WITHOUT ANY WARRANTY; without even the implied warranty of17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU18 * Lesser General Public License for more details.19 *20 * Credits and thanks to:21 * Arnoud Berendsen, Martin Reurings, Robert Hanson22 *23 * howto: body { behavior:url("csshover.htc"); }24 * ------------------------------------------------------------25 */2627var csshoverReg = /(^|\s)((([^a]([^ ]+)?)|(a([^#.][^ ]+)+)):(hover|active))|((a|input|textarea)([#.][^ ]+)?:unknown)/i,28currentSheet, doc = window.document, hoverEvents = [], activators = {29 onhover:{on:'onmouseover', off:'onmouseout'},30 onactive:{on:'onmousedown', off:'onmouseup'},31 onunknown:{on:'onfocus', off:'onblur'}32}3334function parseStylesheets() {35 if(!/MSIE (5|6)/.test(navigator.userAgent)) return;36 window.attachEvent('onunload', unhookHoverEvents);37 var sheets = doc.styleSheets, l = sheets.length;38 for(var i=0; i<l; i++) 39 parseStylesheet(sheets[i]);40}41 function parseStylesheet(sheet) {42 if(sheet.imports) {43 try {44 var imports = sheet.imports, l = imports.length;45 for(var i=0; i<l; i++) parseStylesheet(sheet.imports[i]);46 } catch(securityException){}47 }4849 try {50 var rules = (currentSheet = sheet).rules, l = rules.length;51 for(var j=0; j<l; j++) parseCSSRule(rules[j]);52 } catch(securityException){}53 }5455 function parseCSSRule(rule) {56 var select = rule.selectorText, style = rule.style.cssText;57 if(!csshoverReg.test(select) || !style) return;58 59 var pseudo = select.replace(/[^:]+:([a-z-]+).*/i, 'on$1');60 var newSelect = select.replace(/(\.([a-z0-9_-]+):[a-z]+)|(:[a-z]+)/gi, '.$2' + pseudo);61 var className = (/\.([a-z0-9_-]*on(hover|active|unknown))/i).exec(newSelect)[1];62 var affected = select.replace(/:(hover|active|unknown).*$/, '');63 var elements = getElementsBySelect(affected);64 if(elements.length == 0) return;6566 currentSheet.addRule(newSelect, style);67 for(var i=0; i<elements.length; i++)68 new HoverElement(elements[i], className, activators[pseudo]);69 }7071function HoverElement(node, className, events) {72 if(!node.hovers) node.hovers = {};73 if(node.hovers[className]) return;74 node.hovers[className] = true;75 hookHoverEvent(node, events.on, function() { node.className += ' ' + className; });76 hookHoverEvent(node, events.off, function() { node.className = node.className.replace(new RegExp('\\s+'+className, 'g'),''); });77}78 function hookHoverEvent(node, type, handler) {79 node.attachEvent(type, handler);80 hoverEvents[hoverEvents.length] = { 81 node:node, type:type, handler:handler 82 };83 }8485 function unhookHoverEvents() {86 for(var e,i=0; i<hoverEvents.length; i++) {87 e = hoverEvents[i]; 88 e.node.detachEvent(e.type, e.handler);89 }90 }9192function getElementsBySelect(rule) {93 var parts, nodes = [doc];94 parts = rule.split(' ');95 for(var i=0; i<parts.length; i++) {96 nodes = getSelectedNodes(parts[i], nodes);97 } return nodes;98}99 function getSelectedNodes(select, elements) {100 var result, node, nodes = [];101 var identify = (/\#([a-z0-9_-]+)/i).exec(select);102 if(identify) {103 var element = doc.getElementById(identify[1]);104 return element? [element]:nodes;105 }106 107 var classname = (/\.([a-z0-9_-]+)/i).exec(select);108 var tagName = select.replace(/(\.|\#|\:)[a-z0-9_-]+/i, '');109 var classReg = classname? new RegExp('\\b' + classname[1] + '\\b'):false;110 for(var i=0; i<elements.length; i++) {111 result = tagName? elements[i].all.tags(tagName):elements[i].all; 112 for(var j=0; j<result.length; j++) {113 node = result[j];114 if(classReg && !classReg.test(node.className)) continue;115 nodes[nodes.length] = node;116 }117 } 118 119 return nodes;120 }
...
sass-map.js
Source:sass-map.js
...88 lines.push(i);89 }90 return lines;91}92function parseCssRule(rule, cssMap, lineVarMap) {93 const decls = {};94 if (rule.declarations && Array.isArray(rule.declarations)) {95 rule.declarations.forEach(decl => {96 if (decl.type === 'declaration') {97 const cssLines = getPosLines(decl.position);98 const scssLines = [];99 cssLines.forEach(line => {100 if (line in cssMap) {101 mergeArray(scssLines, cssMap[line].filter(l => {102 return l in lineVarMap;103 }));104 }105 });106 if (scssLines.length) {107 decls[decl.property] = scssLines;108 }109 }110 });111 }112 if (Object.keys(decls).length) {113 return {114 selector: mergeSelector(rule.selectors),115 decls,116 };117 }118}119/**120 * Walk css rule121 *122 * return [{123 * selector: String,124 * decls: [{125 * <String>: [ ... ],126 * ...127 * }, ...]128 * }, ...]129 *130 * @param {String} css Css Source131 * @param {Object} cssMap Css-Scss Map132 * @param {Object} lineVarMap line-var map133 * @return {Array} Selector List134 */135function walkCss(css, cssMap, lineVarMap) {136 const rules = cssParser.parse(css).stylesheet.rules;137 const selectors = [];138 rules.forEach(item => {139 if (item.type === 'rule') {140 const s = parseCssRule(item, cssMap, lineVarMap);141 if (s) {142 selectors.push(s);143 }144 } else if (Array.isArray(item.rules)) {145 item.rules.forEach(rule => {146 const s = parseCssRule(rule, cssMap, lineVarMap);147 if (s) {148 selectors.push(s);149 }150 });151 }152 });153 return selectors;154}155function getSassMap(scss, css, cssMap, varMap) {156 // retrive css lines157 const scssLines = [];158 for (const i in cssMap) {159 cssMap[i].forEach(line => {160 if (scssLines.indexOf(line) < 0) {...
Using AI Code Generation
1const { parseCssRule } = require(‘appium-xcuitest-driver/lib/commands/execute.js’);2const { parseCssRule } = require(‘appium-xcuitest-driver/lib/commands/execute.js’);3const { parseCssRule } = require(‘appium-xcuitest-driver/lib/commands/execute.js’);4const { parseCssRule } = require(‘appium-xcuitest-driver/lib/commands/execute.js’);5const { parseCssRule } = require(‘appium-xcuitest-driver/lib/commands/execute.js’);6const { parseCssRule } = require(‘appium-xcuitest-driver/lib/commands/execute.js’);7const { parseCssRule } = require(‘appium-xcuitest-driver/lib/commands/execute.js’);8const { parseCssRule } = require(‘appium-xcuitest-driver/lib/commands/execute.js’);9const { parseCssRule } = require(‘appium-xcuitest-driver/lib/commands/execute.js’);10const { parseCssRule } = require(‘appium-xcuitest-driver/lib/commands/execute.js’);11const { parseCssRule } = require(‘appium-xcuitest-driver/lib/commands/execute.js’);12const { parseCssRule } = require(‘appium-xcuitest-driver/lib/commands/execute.js’);
Using AI Code Generation
1const { parseCss } = require('appium-xcuitest-driver').css-converter;2const css = 'XCUIElementTypeWindow[visible="true"]';3const xcuiType = 'XCUIElementTypeWindow';4const attrs = { visible: 'true' };5const result = parseCss(css);6if (result.type === xcuiType && _.isEqual(result.attrs, attrs)) {7 console.log('Test passed');8} else {9 console.log('Test failed');10}11const { findElementFromElement } = require('appium-xcuitest-driver').commands;12const elementId = 'elementId';13const using = 'xpath';14findElementFromElement(elementId, using, value).then((result) => {15 console.log('Test passed');16}).catch((error) => {17 console.log('Test failed');18});
Using AI Code Generation
1var css = require('css');2var fs = require('fs');3var path = require('path');4var XCUITestDriver = require('appium-xcuitest-driver');5var cssSelector = 'XCUIElementTypeButton[name="Back"]';6var xpath = XCUITestDriver.parseCssRule(cssSelector);7console.log(xpath);
Using AI Code Generation
1var xcuitestDriver = new XCUITestDriver();2var cssRule = xcuitestDriver.parseCssRule("class name", "XCUIElementTypeButton");3commands.parseCssRule = async function (strategy, selector) {4 if (strategy === 'class name') {5 if (selector === 'XCUIElementTypeButton') {6 } else if (selector === 'XCUIElementTypeTextField') {7 }8 }9};10parseCssRule (strategy, selector) {11 if (strategy === 'class name') {12 if (selector === 'XCUIElementTypeButton') {13 } else if (selector === 'XCUIElementTypeTextField') {14 }15 }16};17commands.parseCssRule = async function (strategy, selector) {18 if (strategy === 'class name') {19 if (selector === 'XCUIElementTypeButton') {20 } else if (selector === 'XCUIElementTypeTextField') {21 }22 }23};24parseCssRule (strategy, selector) {25 if (strategy === 'class name') {26 if (selector === 'XCUIElementTypeButton') {27 } else if (selector === 'XCUIElementTypeTextField') {28 }29 }30};31commands.parseCssRule = async function (strategy, selector) {32 if (strategy === 'class name') {33 if (selector === 'XCUIElementTypeButton') {34 } else if (selector === 'XCUIElementTypeTextField') {35 }36 }37};38parseCssRule (strategy, selector) {39 if (strategy === 'class name') {40 if (selector === 'XCUIElementTypeButton
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!!