How to use createDisabledPseudo method in Cypress

Best JavaScript code snippet using cypress

sizzle.js

Source:sizzle.js Github

copy

Full Screen

...252 var name = elem.nodeName.toLowerCase();253 return (name === "input" || name === "button") && elem.type === type;254 };255 }256 function createDisabledPseudo(disabled) {257 return function(elem) {258 return "label" in elem && elem.disabled === disabled || "form" in elem && elem.disabled === disabled || "form" in elem && elem.disabled === false && (elem.isDisabled === disabled || elem.isDisabled !== !disabled && ("label" in elem || !disabledAncestor(elem)) !== disabled);259 };260 }261 function createPositionalPseudo(fn) {262 return markFunction(function(argument) {263 argument = +argument;264 return markFunction(function(seed, matches) {265 var j,266 matchIndexes = fn([], seed.length, argument),267 i = matchIndexes.length;268 while (i--) {269 if (seed[(j = matchIndexes[i])]) {270 seed[j] = !(matches[j] = seed[j]);271 }272 }273 });274 });275 }276 function testContext(context) {277 return context && typeof context.getElementsByTagName !== "undefined" && context;278 }279 support = Sizzle.support = {};280 isXML = Sizzle.isXML = function(elem) {281 var documentElement = elem && (elem.ownerDocument || elem).documentElement;282 return documentElement ? documentElement.nodeName !== "HTML" : false;283 };284 setDocument = Sizzle.setDocument = function(node) {285 var hasCompare,286 subWindow,287 doc = node ? node.ownerDocument || node : preferredDoc;288 if (doc === document || doc.nodeType !== 9 || !doc.documentElement) {289 return document;290 }291 document = doc;292 docElem = document.documentElement;293 documentIsHTML = !isXML(document);294 if (preferredDoc !== document && (subWindow = document.defaultView) && subWindow.top !== subWindow) {295 if (subWindow.addEventListener) {296 subWindow.addEventListener("unload", unloadHandler, false);297 } else if (subWindow.attachEvent) {298 subWindow.attachEvent("onunload", unloadHandler);299 }300 }301 support.attributes = assert(function(el) {302 el.className = "i";303 return !el.getAttribute("className");304 });305 support.getElementsByTagName = assert(function(el) {306 el.appendChild(document.createComment(""));307 return !el.getElementsByTagName("*").length;308 });309 support.getElementsByClassName = rnative.test(document.getElementsByClassName);310 support.getById = assert(function(el) {311 docElem.appendChild(el).id = expando;312 return !document.getElementsByName || !document.getElementsByName(expando).length;313 });314 if (support.getById) {315 Expr.find["ID"] = function(id, context) {316 if (typeof context.getElementById !== "undefined" && documentIsHTML) {317 var m = context.getElementById(id);318 return m ? [m] : [];319 }320 };321 Expr.filter["ID"] = function(id) {322 var attrId = id.replace(runescape, funescape);323 return function(elem) {324 return elem.getAttribute("id") === attrId;325 };326 };327 } else {328 delete Expr.find["ID"];329 Expr.filter["ID"] = function(id) {330 var attrId = id.replace(runescape, funescape);331 return function(elem) {332 var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");333 return node && node.value === attrId;334 };335 };336 }337 Expr.find["TAG"] = support.getElementsByTagName ? function(tag, context) {338 if (typeof context.getElementsByTagName !== "undefined") {339 return context.getElementsByTagName(tag);340 } else if (support.qsa) {341 return context.querySelectorAll(tag);342 }343 } : function(tag, context) {344 var elem,345 tmp = [],346 i = 0,347 results = context.getElementsByTagName(tag);348 if (tag === "*") {349 while ((elem = results[i++])) {350 if (elem.nodeType === 1) {351 tmp.push(elem);352 }353 }354 return tmp;355 }356 return results;357 };358 Expr.find["CLASS"] = support.getElementsByClassName && function(className, context) {359 if (typeof context.getElementsByClassName !== "undefined" && documentIsHTML) {360 return context.getElementsByClassName(className);361 }362 };363 rbuggyMatches = [];364 rbuggyQSA = [];365 if ((support.qsa = rnative.test(document.querySelectorAll))) {366 assert(function(el) {367 docElem.appendChild(el).innerHTML = "<a id='" + expando + "'></a>" + "<select id='" + expando + "-\r\\' msallowcapture=''>" + "<option selected=''></option></select>";368 if (el.querySelectorAll("[msallowcapture^='']").length) {369 rbuggyQSA.push("[*^$]=" + whitespace + "*(?:''|\"\")");370 }371 if (!el.querySelectorAll("[selected]").length) {372 rbuggyQSA.push("\\[" + whitespace + "*(?:value|" + booleans + ")");373 }374 if (!el.querySelectorAll("[id~=" + expando + "-]").length) {375 rbuggyQSA.push("~=");376 }377 if (!el.querySelectorAll(":checked").length) {378 rbuggyQSA.push(":checked");379 }380 if (!el.querySelectorAll("a#" + expando + "+*").length) {381 rbuggyQSA.push(".#.+[+~]");382 }383 });384 assert(function(el) {385 el.innerHTML = "<a href='' disabled='disabled'></a>" + "<select disabled='disabled'><option/></select>";386 var input = document.createElement("input");387 input.setAttribute("type", "hidden");388 el.appendChild(input).setAttribute("name", "D");389 if (el.querySelectorAll("[name=d]").length) {390 rbuggyQSA.push("name" + whitespace + "*[*^$|!~]?=");391 }392 if (el.querySelectorAll(":enabled").length !== 2) {393 rbuggyQSA.push(":enabled", ":disabled");394 }395 docElem.appendChild(el).disabled = true;396 if (el.querySelectorAll(":disabled").length !== 2) {397 rbuggyQSA.push(":enabled", ":disabled");398 }399 el.querySelectorAll("*,:x");400 rbuggyQSA.push(",.*:");401 });402 }403 if ((support.matchesSelector = rnative.test((matches = docElem.matches || docElem.webkitMatchesSelector || docElem.mozMatchesSelector || docElem.oMatchesSelector || docElem.msMatchesSelector)))) {404 assert(function(el) {405 support.disconnectedMatch = matches.call(el, "*");406 matches.call(el, "[s!='']:x");407 rbuggyMatches.push("!=", pseudos);408 });409 }410 rbuggyQSA = rbuggyQSA.length && new RegExp(rbuggyQSA.join("|"));411 rbuggyMatches = rbuggyMatches.length && new RegExp(rbuggyMatches.join("|"));412 hasCompare = rnative.test(docElem.compareDocumentPosition);413 contains = hasCompare || rnative.test(docElem.contains) ? function(a, b) {414 var adown = a.nodeType === 9 ? a.documentElement : a,415 bup = b && b.parentNode;416 return a === bup || !!(bup && bup.nodeType === 1 && (adown.contains ? adown.contains(bup) : a.compareDocumentPosition && a.compareDocumentPosition(bup) & 16));417 } : function(a, b) {418 if (b) {419 while ((b = b.parentNode)) {420 if (b === a) {421 return true;422 }423 }424 }425 return false;426 };427 sortOrder = hasCompare ? function(a, b) {428 if (a === b) {429 hasDuplicate = true;430 return 0;431 }432 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;433 if (compare) {434 return compare;435 }436 compare = (a.ownerDocument || a) === (b.ownerDocument || b) ? a.compareDocumentPosition(b) : 1;437 if (compare & 1 || (!support.sortDetached && b.compareDocumentPosition(a) === compare)) {438 if (a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a)) {439 return -1;440 }441 if (b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b)) {442 return 1;443 }444 return sortInput ? (indexOf(sortInput, a) - indexOf(sortInput, b)) : 0;445 }446 return compare & 4 ? -1 : 1;447 } : function(a, b) {448 if (a === b) {449 hasDuplicate = true;450 return 0;451 }452 var cur,453 i = 0,454 aup = a.parentNode,455 bup = b.parentNode,456 ap = [a],457 bp = [b];458 if (!aup || !bup) {459 return a === document ? -1 : b === document ? 1 : aup ? -1 : bup ? 1 : sortInput ? (indexOf(sortInput, a) - indexOf(sortInput, b)) : 0;460 } else if (aup === bup) {461 return siblingCheck(a, b);462 }463 cur = a;464 while ((cur = cur.parentNode)) {465 ap.unshift(cur);466 }467 cur = b;468 while ((cur = cur.parentNode)) {469 bp.unshift(cur);470 }471 while (ap[i] === bp[i]) {472 i++;473 }474 return i ? siblingCheck(ap[i], bp[i]) : ap[i] === preferredDoc ? -1 : bp[i] === preferredDoc ? 1 : 0;475 };476 return document;477 };478 Sizzle.matches = function(expr, elements) {479 return Sizzle(expr, null, null, elements);480 };481 Sizzle.matchesSelector = function(elem, expr) {482 if ((elem.ownerDocument || elem) !== document) {483 setDocument(elem);484 }485 expr = expr.replace(rattributeQuotes, "='$1']");486 if (support.matchesSelector && documentIsHTML && !compilerCache[expr + " "] && (!rbuggyMatches || !rbuggyMatches.test(expr)) && (!rbuggyQSA || !rbuggyQSA.test(expr))) {487 try {488 var ret = matches.call(elem, expr);489 if (ret || support.disconnectedMatch || elem.document && elem.document.nodeType !== 11) {490 return ret;491 }492 } catch (e) {}493 }494 return Sizzle(expr, document, null, [elem]).length > 0;495 };496 Sizzle.contains = function(context, elem) {497 if ((context.ownerDocument || context) !== document) {498 setDocument(context);499 }500 return contains(context, elem);501 };502 Sizzle.attr = function(elem, name) {503 if ((elem.ownerDocument || elem) !== document) {504 setDocument(elem);505 }506 var fn = Expr.attrHandle[name.toLowerCase()],507 val = fn && hasOwn.call(Expr.attrHandle, name.toLowerCase()) ? fn(elem, name, !documentIsHTML) : undefined;508 return val !== undefined ? val : support.attributes || !documentIsHTML ? elem.getAttribute(name) : (val = elem.getAttributeNode(name)) && val.specified ? val.value : null;509 };510 Sizzle.escape = function(sel) {511 return (sel + "").replace(rcssescape, fcssescape);512 };513 Sizzle.error = function(msg) {514 throw new Error("Syntax error, unrecognized expression: " + msg);515 };516 Sizzle.uniqueSort = function(results) {517 var elem,518 duplicates = [],519 j = 0,520 i = 0;521 hasDuplicate = !support.detectDuplicates;522 sortInput = !support.sortStable && results.slice(0);523 results.sort(sortOrder);524 if (hasDuplicate) {525 while ((elem = results[i++])) {526 if (elem === results[i]) {527 j = duplicates.push(i);528 }529 }530 while (j--) {531 results.splice(duplicates[j], 1);532 }533 }534 sortInput = null;535 return results;536 };537 getText = Sizzle.getText = function(elem) {538 var node,539 ret = "",540 i = 0,541 nodeType = elem.nodeType;542 if (!nodeType) {543 while ((node = elem[i++])) {544 ret += getText(node);545 }546 } else if (nodeType === 1 || nodeType === 9 || nodeType === 11) {547 if (typeof elem.textContent === "string") {548 return elem.textContent;549 } else {550 for (elem = elem.firstChild; elem; elem = elem.nextSibling) {551 ret += getText(elem);552 }553 }554 } else if (nodeType === 3 || nodeType === 4) {555 return elem.nodeValue;556 }557 return ret;558 };559 Expr = Sizzle.selectors = {560 cacheLength: 50,561 createPseudo: markFunction,562 match: matchExpr,563 attrHandle: {},564 find: {},565 relative: {566 ">": {567 dir: "parentNode",568 first: true569 },570 " ": {dir: "parentNode"},571 "+": {572 dir: "previousSibling",573 first: true574 },575 "~": {dir: "previousSibling"}576 },577 preFilter: {578 "ATTR": function(match) {579 match[1] = match[1].replace(runescape, funescape);580 match[3] = (match[3] || match[4] || match[5] || "").replace(runescape, funescape);581 if (match[2] === "~=") {582 match[3] = " " + match[3] + " ";583 }584 return match.slice(0, 4);585 },586 "CHILD": function(match) {587 match[1] = match[1].toLowerCase();588 if (match[1].slice(0, 3) === "nth") {589 if (!match[3]) {590 Sizzle.error(match[0]);591 }592 match[4] = +(match[4] ? match[5] + (match[6] || 1) : 2 * (match[3] === "even" || match[3] === "odd"));593 match[5] = +((match[7] + match[8]) || match[3] === "odd");594 } else if (match[3]) {595 Sizzle.error(match[0]);596 }597 return match;598 },599 "PSEUDO": function(match) {600 var excess,601 unquoted = !match[6] && match[2];602 if (matchExpr["CHILD"].test(match[0])) {603 return null;604 }605 if (match[3]) {606 match[2] = match[4] || match[5] || "";607 } else if (unquoted && rpseudo.test(unquoted) && (excess = tokenize(unquoted, true)) && (excess = unquoted.indexOf(")", unquoted.length - excess) - unquoted.length)) {608 match[0] = match[0].slice(0, excess);609 match[2] = unquoted.slice(0, excess);610 }611 return match.slice(0, 3);612 }613 },614 filter: {615 "TAG": function(nodeNameSelector) {616 var nodeName = nodeNameSelector.replace(runescape, funescape).toLowerCase();617 return nodeNameSelector === "*" ? function() {618 return true;619 } : function(elem) {620 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;621 };622 },623 "CLASS": function(className) {624 var pattern = classCache[className + " "];625 return pattern || (pattern = new RegExp("(^|" + whitespace + ")" + className + "(" + whitespace + "|$)")) && classCache(className, function(elem) {626 return pattern.test(typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "");627 });628 },629 "ATTR": function(name, operator, check) {630 return function(elem) {631 var result = Sizzle.attr(elem, name);632 if (result == null) {633 return operator === "!=";634 }635 if (!operator) {636 return true;637 }638 result += "";639 return operator === "=" ? result === check : operator === "!=" ? result !== check : operator === "^=" ? check && result.indexOf(check) === 0 : operator === "*=" ? check && result.indexOf(check) > -1 : operator === "$=" ? check && result.slice(-check.length) === check : operator === "~=" ? (" " + result.replace(rwhitespace, " ") + " ").indexOf(check) > -1 : operator === "|=" ? result === check || result.slice(0, check.length + 1) === check + "-" : false;640 };641 },642 "CHILD": function(type, what, argument, first, last) {643 var simple = type.slice(0, 3) !== "nth",644 forward = type.slice(-4) !== "last",645 ofType = what === "of-type";646 return first === 1 && last === 0 ? function(elem) {647 return !!elem.parentNode;648 } : function(elem, context, xml) {649 var cache,650 uniqueCache,651 outerCache,652 node,653 nodeIndex,654 start,655 dir = simple !== forward ? "nextSibling" : "previousSibling",656 parent = elem.parentNode,657 name = ofType && elem.nodeName.toLowerCase(),658 useCache = !xml && !ofType,659 diff = false;660 if (parent) {661 if (simple) {662 while (dir) {663 node = elem;664 while ((node = node[dir])) {665 if (ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1) {666 return false;667 }668 }669 start = dir = type === "only" && !start && "nextSibling";670 }671 return true;672 }673 start = [forward ? parent.firstChild : parent.lastChild];674 if (forward && useCache) {675 node = parent;676 outerCache = node[expando] || (node[expando] = {});677 uniqueCache = outerCache[node.uniqueID] || (outerCache[node.uniqueID] = {});678 cache = uniqueCache[type] || [];679 nodeIndex = cache[0] === dirruns && cache[1];680 diff = nodeIndex && cache[2];681 node = nodeIndex && parent.childNodes[nodeIndex];682 while ((node = ++nodeIndex && node && node[dir] || (diff = nodeIndex = 0) || start.pop())) {683 if (node.nodeType === 1 && ++diff && node === elem) {684 uniqueCache[type] = [dirruns, nodeIndex, diff];685 break;686 }687 }688 } else {689 if (useCache) {690 node = elem;691 outerCache = node[expando] || (node[expando] = {});692 uniqueCache = outerCache[node.uniqueID] || (outerCache[node.uniqueID] = {});693 cache = uniqueCache[type] || [];694 nodeIndex = cache[0] === dirruns && cache[1];695 diff = nodeIndex;696 }697 if (diff === false) {698 while ((node = ++nodeIndex && node && node[dir] || (diff = nodeIndex = 0) || start.pop())) {699 if ((ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1) && ++diff) {700 if (useCache) {701 outerCache = node[expando] || (node[expando] = {});702 uniqueCache = outerCache[node.uniqueID] || (outerCache[node.uniqueID] = {});703 uniqueCache[type] = [dirruns, diff];704 }705 if (node === elem) {706 break;707 }708 }709 }710 }711 }712 diff -= last;713 return diff === first || (diff % first === 0 && diff / first >= 0);714 }715 };716 },717 "PSEUDO": function(pseudo, argument) {718 var args,719 fn = Expr.pseudos[pseudo] || Expr.setFilters[pseudo.toLowerCase()] || Sizzle.error("unsupported pseudo: " + pseudo);720 if (fn[expando]) {721 return fn(argument);722 }723 if (fn.length > 1) {724 args = [pseudo, pseudo, "", argument];725 return Expr.setFilters.hasOwnProperty(pseudo.toLowerCase()) ? markFunction(function(seed, matches) {726 var idx,727 matched = fn(seed, argument),728 i = matched.length;729 while (i--) {730 idx = indexOf(seed, matched[i]);731 seed[idx] = !(matches[idx] = matched[i]);732 }733 }) : function(elem) {734 return fn(elem, 0, args);735 };736 }737 return fn;738 }739 },740 pseudos: {741 "not": markFunction(function(selector) {742 var input = [],743 results = [],744 matcher = compile(selector.replace(rtrim, "$1"));745 return matcher[expando] ? markFunction(function(seed, matches, context, xml) {746 var elem,747 unmatched = matcher(seed, null, xml, []),748 i = seed.length;749 while (i--) {750 if ((elem = unmatched[i])) {751 seed[i] = !(matches[i] = elem);752 }753 }754 }) : function(elem, context, xml) {755 input[0] = elem;756 matcher(input, null, xml, results);757 input[0] = null;758 return !results.pop();759 };760 }),761 "has": markFunction(function(selector) {762 return function(elem) {763 return Sizzle(selector, elem).length > 0;764 };765 }),766 "contains": markFunction(function(text) {767 text = text.replace(runescape, funescape);768 return function(elem) {769 return (elem.textContent || elem.innerText || getText(elem)).indexOf(text) > -1;770 };771 }),772 "lang": markFunction(function(lang) {773 if (!ridentifier.test(lang || "")) {774 Sizzle.error("unsupported lang: " + lang);775 }776 lang = lang.replace(runescape, funescape).toLowerCase();777 return function(elem) {778 var elemLang;779 do {780 if ((elemLang = documentIsHTML ? elem.lang : elem.getAttribute("xml:lang") || elem.getAttribute("lang"))) {781 elemLang = elemLang.toLowerCase();782 return elemLang === lang || elemLang.indexOf(lang + "-") === 0;783 }784 } while ((elem = elem.parentNode) && elem.nodeType === 1);785 return false;786 };787 }),788 "target": function(elem) {789 var hash = window.location && window.location.hash;790 return hash && hash.slice(1) === elem.id;791 },792 "root": function(elem) {793 return elem === docElem;794 },795 "focus": function(elem) {796 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);797 },798 "enabled": createDisabledPseudo(false),799 "disabled": createDisabledPseudo(true),800 "checked": function(elem) {801 var nodeName = elem.nodeName.toLowerCase();802 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);803 },804 "selected": function(elem) {805 if (elem.parentNode) {806 elem.parentNode.selectedIndex;807 }808 return elem.selected === true;809 },810 "empty": function(elem) {811 for (elem = elem.firstChild; elem; elem = elem.nextSibling) {812 if (elem.nodeType < 6) {813 return false;...

Full Screen

Full Screen

selector.js

Source:selector.js Github

copy

Full Screen

...264/**265 * Returns a function to use in pseudos for :enabled/:disabled266 * @param {Boolean} disabled true for :disabled; false for :enabled267 */268function createDisabledPseudo( disabled ) {269 // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable270 return function( elem ) {271 // Only certain elements can match :enabled or :disabled272 // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled273 // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled274 if ( "form" in elem ) {275 // Check for inherited disabledness on relevant non-disabled elements:276 // * listed form-associated elements in a disabled fieldset277 // https://html.spec.whatwg.org/multipage/forms.html#category-listed278 // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled279 // * option elements in a disabled optgroup280 // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled281 // All such elements have a "form" property.282 if ( elem.parentNode && elem.disabled === false ) {283 // Option elements defer to a parent optgroup if present284 if ( "label" in elem ) {285 if ( "label" in elem.parentNode ) {286 return elem.parentNode.disabled === disabled;287 } else {288 return elem.disabled === disabled;289 }290 }291 // Support: IE 6 - 11+292 // Use the isDisabled shortcut property to check for disabled fieldset ancestors293 return elem.isDisabled === disabled ||294 // Where there is no isDisabled, check manually295 elem.isDisabled !== !disabled &&296 inDisabledFieldset( elem ) === disabled;297 }298 return elem.disabled === disabled;299 // Try to winnow out elements that can't be disabled before trusting the disabled property.300 // Some victims get caught in our net (label, legend, menu, track), but it shouldn't301 // even exist on them, let alone have a boolean value.302 } else if ( "label" in elem ) {303 return elem.disabled === disabled;304 }305 // Remaining elements are neither :enabled nor :disabled306 return false;307 };308}309/**310 * Returns a function to use in pseudos for positionals311 * @param {Function} fn312 */313function createPositionalPseudo( fn ) {314 return markFunction( function( argument ) {315 argument = +argument;316 return markFunction( function( seed, matches ) {317 var j,318 matchIndexes = fn( [], seed.length, argument ),319 i = matchIndexes.length;320 // Match elements found at the specified indexes321 while ( i-- ) {322 if ( seed[ ( j = matchIndexes[ i ] ) ] ) {323 seed[ j ] = !( matches[ j ] = seed[ j ] );324 }325 }326 } );327 } );328}329/**330 * Checks a node for validity as a jQuery selector context331 * @param {Element|Object=} context332 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value333 */334function testContext( context ) {335 return context && typeof context.getElementsByTagName !== "undefined" && context;336}337/**338 * Sets document-related variables once based on the current document339 * @param {Element|Object} [node] An element or document object to use to set the document340 */341function setDocument( node ) {342 var subWindow,343 doc = node ? node.ownerDocument || node : preferredDoc;344 // Return early if doc is invalid or already selected345 // Support: IE 11+346 // IE sometimes throws a "Permission denied" error when strict-comparing347 // two documents; shallow comparisons work.348 // eslint-disable-next-line eqeqeq349 if ( doc == document || doc.nodeType !== 9 ) {350 return;351 }352 // Update global variables353 document = doc;354 documentElement = document.documentElement;355 documentIsHTML = !jQuery.isXMLDoc( document );356 // Support: IE 9 - 11+357 // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)358 // Support: IE 11+359 // IE sometimes throws a "Permission denied" error when strict-comparing360 // two documents; shallow comparisons work.361 // eslint-disable-next-line eqeqeq362 if ( isIE && preferredDoc != document &&363 ( subWindow = document.defaultView ) && subWindow.top !== subWindow ) {364 subWindow.addEventListener( "unload", unloadHandler );365 }366}367find.matches = function( expr, elements ) {368 return find( expr, null, null, elements );369};370find.matchesSelector = function( elem, expr ) {371 setDocument( elem );372 if ( documentIsHTML &&373 !nonnativeSelectorCache[ expr + " " ] &&374 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {375 try {376 return matches.call( elem, expr );377 } catch ( e ) {378 nonnativeSelectorCache( expr, true );379 }380 }381 return find( expr, document, null, [ elem ] ).length > 0;382};383Expr = jQuery.expr = {384 // Can be adjusted by the user385 cacheLength: 50,386 createPseudo: markFunction,387 match: matchExpr,388 find: {389 ID: function( id, context ) {390 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {391 var elem = context.getElementById( id );392 return elem ? [ elem ] : [];393 }394 },395 TAG: function( tag, context ) {396 if ( typeof context.getElementsByTagName !== "undefined" ) {397 return context.getElementsByTagName( tag );398 // DocumentFragment nodes don't have gEBTN399 } else {400 return context.querySelectorAll( tag );401 }402 },403 CLASS: function( className, context ) {404 if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {405 return context.getElementsByClassName( className );406 }407 }408 },409 relative: {410 ">": { dir: "parentNode", first: true },411 " ": { dir: "parentNode" },412 "+": { dir: "previousSibling", first: true },413 "~": { dir: "previousSibling" }414 },415 preFilter: {416 ATTR: function( match ) {417 match[ 1 ] = match[ 1 ].replace( runescape, funescape );418 // Move the given value to match[3] whether quoted or unquoted419 match[ 3 ] = ( match[ 3 ] || match[ 4 ] || match[ 5 ] || "" )420 .replace( runescape, funescape );421 if ( match[ 2 ] === "~=" ) {422 match[ 3 ] = " " + match[ 3 ] + " ";423 }424 return match.slice( 0, 4 );425 },426 CHILD: function( match ) {427 /* matches from matchExpr["CHILD"]428 1 type (only|nth|...)429 2 what (child|of-type)430 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)431 4 xn-component of xn+y argument ([+-]?\d*n|)432 5 sign of xn-component433 6 x of xn-component434 7 sign of y-component435 8 y of y-component436 */437 match[ 1 ] = match[ 1 ].toLowerCase();438 if ( match[ 1 ].slice( 0, 3 ) === "nth" ) {439 // nth-* requires argument440 if ( !match[ 3 ] ) {441 selectorError( match[ 0 ] );442 }443 // numeric x and y parameters for Expr.filter.CHILD444 // remember that false/true cast respectively to 0/1445 match[ 4 ] = +( match[ 4 ] ?446 match[ 5 ] + ( match[ 6 ] || 1 ) :447 2 * ( match[ 3 ] === "even" || match[ 3 ] === "odd" )448 );449 match[ 5 ] = +( ( match[ 7 ] + match[ 8 ] ) || match[ 3 ] === "odd" );450 // other types prohibit arguments451 } else if ( match[ 3 ] ) {452 selectorError( match[ 0 ] );453 }454 return match;455 },456 PSEUDO: function( match ) {457 var excess,458 unquoted = !match[ 6 ] && match[ 2 ];459 if ( matchExpr.CHILD.test( match[ 0 ] ) ) {460 return null;461 }462 // Accept quoted arguments as-is463 if ( match[ 3 ] ) {464 match[ 2 ] = match[ 4 ] || match[ 5 ] || "";465 // Strip excess characters from unquoted arguments466 } else if ( unquoted && rpseudo.test( unquoted ) &&467 // Get excess from tokenize (recursively)468 ( excess = tokenize( unquoted, true ) ) &&469 // advance to the next closing parenthesis470 ( excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length ) ) {471 // excess is a negative index472 match[ 0 ] = match[ 0 ].slice( 0, excess );473 match[ 2 ] = unquoted.slice( 0, excess );474 }475 // Return only captures needed by the pseudo filter method (type and argument)476 return match.slice( 0, 3 );477 }478 },479 filter: {480 ID: function( id ) {481 var attrId = id.replace( runescape, funescape );482 return function( elem ) {483 return elem.getAttribute( "id" ) === attrId;484 };485 },486 TAG: function( nodeNameSelector ) {487 var expectedNodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();488 return nodeNameSelector === "*" ?489 function() {490 return true;491 } :492 function( elem ) {493 return nodeName( elem, expectedNodeName );494 };495 },496 CLASS: function( className ) {497 var pattern = classCache[ className + " " ];498 return pattern ||499 ( pattern = new RegExp( "(^|" + whitespace + ")" + className +500 "(" + whitespace + "|$)" ) ) &&501 classCache( className, function( elem ) {502 return pattern.test(503 typeof elem.className === "string" && elem.className ||504 typeof elem.getAttribute !== "undefined" &&505 elem.getAttribute( "class" ) ||506 ""507 );508 } );509 },510 ATTR: function( name, operator, check ) {511 return function( elem ) {512 var result = jQuery.attr( elem, name );513 if ( result == null ) {514 return operator === "!=";515 }516 if ( !operator ) {517 return true;518 }519 result += "";520 if ( operator === "=" ) {521 return result === check;522 }523 if ( operator === "!=" ) {524 return result !== check;525 }526 if ( operator === "^=" ) {527 return check && result.indexOf( check ) === 0;528 }529 if ( operator === "*=" ) {530 return check && result.indexOf( check ) > -1;531 }532 if ( operator === "$=" ) {533 return check && result.slice( -check.length ) === check;534 }535 if ( operator === "~=" ) {536 return ( " " + result.replace( rwhitespace, " " ) + " " )537 .indexOf( check ) > -1;538 }539 if ( operator === "|=" ) {540 return result === check || result.slice( 0, check.length + 1 ) === check + "-";541 }542 return false;543 };544 },545 CHILD: function( type, what, _argument, first, last ) {546 var simple = type.slice( 0, 3 ) !== "nth",547 forward = type.slice( -4 ) !== "last",548 ofType = what === "of-type";549 return first === 1 && last === 0 ?550 // Shortcut for :nth-*(n)551 function( elem ) {552 return !!elem.parentNode;553 } :554 function( elem, _context, xml ) {555 var cache, outerCache, node, nodeIndex, start,556 dir = simple !== forward ? "nextSibling" : "previousSibling",557 parent = elem.parentNode,558 name = ofType && elem.nodeName.toLowerCase(),559 useCache = !xml && !ofType,560 diff = false;561 if ( parent ) {562 // :(first|last|only)-(child|of-type)563 if ( simple ) {564 while ( dir ) {565 node = elem;566 while ( ( node = node[ dir ] ) ) {567 if ( ofType ?568 nodeName( node, name ) :569 node.nodeType === 1 ) {570 return false;571 }572 }573 // Reverse direction for :only-* (if we haven't yet done so)574 start = dir = type === "only" && !start && "nextSibling";575 }576 return true;577 }578 start = [ forward ? parent.firstChild : parent.lastChild ];579 // non-xml :nth-child(...) stores cache data on `parent`580 if ( forward && useCache ) {581 // Seek `elem` from a previously-cached index582 outerCache = parent[ expando ] || ( parent[ expando ] = {} );583 cache = outerCache[ type ] || [];584 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];585 diff = nodeIndex && cache[ 2 ];586 node = nodeIndex && parent.childNodes[ nodeIndex ];587 while ( ( node = ++nodeIndex && node && node[ dir ] ||588 // Fallback to seeking `elem` from the start589 ( diff = nodeIndex = 0 ) || start.pop() ) ) {590 // When found, cache indexes on `parent` and break591 if ( node.nodeType === 1 && ++diff && node === elem ) {592 outerCache[ type ] = [ dirruns, nodeIndex, diff ];593 break;594 }595 }596 } else {597 // Use previously-cached element index if available598 if ( useCache ) {599 outerCache = elem[ expando ] || ( elem[ expando ] = {} );600 cache = outerCache[ type ] || [];601 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];602 diff = nodeIndex;603 }604 // xml :nth-child(...)605 // or :nth-last-child(...) or :nth(-last)?-of-type(...)606 if ( diff === false ) {607 // Use the same loop as above to seek `elem` from the start608 while ( ( node = ++nodeIndex && node && node[ dir ] ||609 ( diff = nodeIndex = 0 ) || start.pop() ) ) {610 if ( ( ofType ?611 nodeName( node, name ) :612 node.nodeType === 1 ) &&613 ++diff ) {614 // Cache the index of each encountered element615 if ( useCache ) {616 outerCache = node[ expando ] ||617 ( node[ expando ] = {} );618 outerCache[ type ] = [ dirruns, diff ];619 }620 if ( node === elem ) {621 break;622 }623 }624 }625 }626 }627 // Incorporate the offset, then check against cycle size628 diff -= last;629 return diff === first || ( diff % first === 0 && diff / first >= 0 );630 }631 };632 },633 PSEUDO: function( pseudo, argument ) {634 // pseudo-class names are case-insensitive635 // https://www.w3.org/TR/selectors/#pseudo-classes636 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters637 // Remember that setFilters inherits from pseudos638 var args,639 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||640 selectorError( "unsupported pseudo: " + pseudo );641 // The user may use createPseudo to indicate that642 // arguments are needed to create the filter function643 // just as jQuery does644 if ( fn[ expando ] ) {645 return fn( argument );646 }647 // But maintain support for old signatures648 if ( fn.length > 1 ) {649 args = [ pseudo, pseudo, "", argument ];650 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?651 markFunction( function( seed, matches ) {652 var idx,653 matched = fn( seed, argument ),654 i = matched.length;655 while ( i-- ) {656 idx = indexOf.call( seed, matched[ i ] );657 seed[ idx ] = !( matches[ idx ] = matched[ i ] );658 }659 } ) :660 function( elem ) {661 return fn( elem, 0, args );662 };663 }664 return fn;665 }666 },667 pseudos: {668 // Potentially complex pseudos669 not: markFunction( function( selector ) {670 // Trim the selector passed to compile671 // to avoid treating leading and trailing672 // spaces as combinators673 var input = [],674 results = [],675 matcher = compile( selector.replace( rtrim, "$1" ) );676 return matcher[ expando ] ?677 markFunction( function( seed, matches, _context, xml ) {678 var elem,679 unmatched = matcher( seed, null, xml, [] ),680 i = seed.length;681 // Match elements unmatched by `matcher`682 while ( i-- ) {683 if ( ( elem = unmatched[ i ] ) ) {684 seed[ i ] = !( matches[ i ] = elem );685 }686 }687 } ) :688 function( elem, _context, xml ) {689 input[ 0 ] = elem;690 matcher( input, null, xml, results );691 // Don't keep the element (issue #299)692 input[ 0 ] = null;693 return !results.pop();694 };695 } ),696 has: markFunction( function( selector ) {697 return function( elem ) {698 return find( selector, elem ).length > 0;699 };700 } ),701 contains: markFunction( function( text ) {702 text = text.replace( runescape, funescape );703 return function( elem ) {704 return ( elem.textContent || jQuery.text( elem ) ).indexOf( text ) > -1;705 };706 } ),707 // "Whether an element is represented by a :lang() selector708 // is based solely on the element's language value709 // being equal to the identifier C,710 // or beginning with the identifier C immediately followed by "-".711 // The matching of C against the element's language value is performed case-insensitively.712 // The identifier C does not have to be a valid language name."713 // https://www.w3.org/TR/selectors/#lang-pseudo714 lang: markFunction( function( lang ) {715 // lang value must be a valid identifier716 if ( !ridentifier.test( lang || "" ) ) {717 selectorError( "unsupported lang: " + lang );718 }719 lang = lang.replace( runescape, funescape ).toLowerCase();720 return function( elem ) {721 var elemLang;722 do {723 if ( ( elemLang = documentIsHTML ?724 elem.lang :725 elem.getAttribute( "xml:lang" ) || elem.getAttribute( "lang" ) ) ) {726 elemLang = elemLang.toLowerCase();727 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;728 }729 } while ( ( elem = elem.parentNode ) && elem.nodeType === 1 );730 return false;731 };732 } ),733 // Miscellaneous734 target: function( elem ) {735 var hash = window.location && window.location.hash;736 return hash && hash.slice( 1 ) === elem.id;737 },738 root: function( elem ) {739 return elem === documentElement;740 },741 focus: function( elem ) {742 return elem === document.activeElement &&743 document.hasFocus() &&744 !!( elem.type || elem.href || ~elem.tabIndex );745 },746 // Boolean properties747 enabled: createDisabledPseudo( false ),748 disabled: createDisabledPseudo( true ),749 checked: function( elem ) {750 // In CSS3, :checked should return both checked and selected elements751 // https://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked752 return ( nodeName( elem, "input" ) && !!elem.checked ) ||753 ( nodeName( elem, "option" ) && !!elem.selected );754 },755 selected: function( elem ) {756 // Support: IE <=11+757 // Accessing the selectedIndex property758 // forces the browser to treat the default option as759 // selected when in an optgroup.760 if ( isIE && elem.parentNode ) {761 // eslint-disable-next-line no-unused-expressions762 elem.parentNode.selectedIndex;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.$(':disabled').should('have.length', 1)2Cypress.$(':disabled').should('have.attr', 'disabled')3Cypress.$(':disabled').should('have.attr', 'disabled', 'disabled')4jQuery(':disabled').should('have.length', 1)5jQuery(':disabled').should('have.attr', 'disabled')6jQuery(':disabled').should('have.attr', 'disabled', 'disabled')7$(':disabled').should('have.length', 1)8$(':disabled').should('have.attr', 'disabled')9$(':disabled').should('have.attr', 'disabled', 'disabled')10$(':disabled').should('have.length', 1)11$(':disabled').should('have.attr', 'disabled')12$(':disabled').should('have.attr', 'disabled', 'disabled')13$(':disabled').should('have.length', 1)14$(':disabled').should('have.attr', 'disabled')15$(':disabled').should('have.attr', 'disabled', 'disabled')16$(':disabled').should('have.length', 1)17$(':disabled').should('have.attr', 'disabled')18$(':disabled').should('have.attr', 'disabled', 'disabled')19$(':disabled').should('have.length', 1)20$(':disabled').should('have.attr', 'disabled')21$(':disabled').should('have.attr', 'disabled', 'disabled')22$(':disabled').should('have.length', 1)23$(':disabled').should('have.attr', 'disabled')24$(':disabled').should('have.attr', 'disabled', 'disabled')25$(':disabled').should('have.length', 1)26$(':disabled').should('have.attr', 'disabled')27$(':disabled').should('have.attr', 'disabled', 'disabled')28$(':disabled').should('have.length', 1)29$(':disabled').should('have.attr', 'disabled')30$(':disabled').should('have.attr', 'disabled', 'disabled')

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.$(':button').prop('disabled', true);2Cypress.$(':button').prop('disabled', false);3describe('My First Test', function() {4 it('Does not do much!', function() {5 cy.contains('type').click()6 cy.get('.action-disabled').should('be.disabled')7 })8})9describe('My First Test', function() {10 it('Does not do much!', function() {11 cy.contains('type').click()12 cy.get('.action-disabled').should('be.enabled')13 })14})15describe('My First Test', function() {16 it('Does not do much!', function() {17 cy.contains('type').click()18 cy.get('.action-disabled').should('not.be.disabled')19 })20})21describe('My First Test', function() {22 it('Does not do much!', function() {23 cy.contains('type').click()24 cy.get('.action-disabled').should('not.be.enabled')25 })26})27Cypress.$(':button').focus();28Cypress.$(':button').blur();29describe('My First Test', function() {30 it('Does not do much!', function() {31 cy.contains('type').click()32 cy.get('.action-focus').focus().should('have.class', 'focus')33 cy.get('.action-blur').type('About to blur').blur().should('have.class', 'error')34 })35})

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add('createDisabledPseudo', () => {2 Cypress.$(':disabled').each((i, el) => {3 Cypress.$(el).attr('disabled', 'disabled');4 });5});6describe('Test', () => {7 it('Test', () => {8 cy.get('input').should('be.disabled');9 cy.createDisabledPseudo();10 cy.get('input').should('not.be.disabled');11 });12});13Cypress.$(':disabled').each((i, el) => {14 Cypress.$(el).attr('disabled', 'disabled');15});16Cypress.$(':disabled').each((i, el) => {17 Cypress.$(el).removeAttr('disabled');18});19Cypress.$(el).removeA

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add('createDisabledPseudo', () => {2 Cypress.log({3 })4 cy.window().then((win) => {5 const disabledPseudo = win.document.createElement('style')6 [data-cy="input-field"] {7 pointer-events: none;8 opacity: 0.5;9 }10 win.document.body.appendChild(disabledPseudo)11 })12})13Cypress.Commands.add('createDisabledPseudo', () => {14 Cypress.log({15 })16 cy.window().then((win) => {17 const disabledPseudo = win.document.createElement('style')18 [data-cy="input-field"] {19 pointer-events: none;20 opacity: 0.5;21 }22 win.document.body.appendChild(disabledPseudo)23 })24})25Cypress.Commands.add('createDisabledPseudo', () => {26 Cypress.log({27 })28 cy.window().then((win) => {29 const disabledPseudo = win.document.createElement('style')30 [data-cy="input-field"] {31 pointer-events: none;32 opacity: 0.5;33 }34 win.document.body.appendChild(disabledPseudo)35 })36})37Cypress.Commands.add('createDisabledPseudo', () => {38 Cypress.log({39 })40 cy.window().then((win) => {

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.$(':disabled').each((item) => {2 console.log(item);3});4it('createDisabledPseudo', () => {5 cy.get('input[type="text"]').type('Hello');6 cy.get('input[type="text"]').should('have.value', 'Hello');7 cy.get('input[type="text"]').sho

Full Screen

Using AI Code Generation

copy

Full Screen

1const disabledPseudo = Cypress.$.expr.createPseudo((arg) => {2 return function (elem) {3 return Cypress.$(elem).is(':disabled')4 }5})6Cypress.$(`input${disabledPseudo()}`)7Cypress.$(`input${disabledPseudo()}[name="name"]`)8Cypress.$(`input${disabledPseudo()}[name="name"][value="value"]`)9Cypress.$(`input${disabledPseudo()}[name="name"][value="value"]`)10Cypress.$(`input${disabledPseudo()}[name="name"][value="value"]`)11Cypress.$(`input${disabledPseudo()}[name="name"][value="value"]`)12describe('test', function () {13 it('test', function () {14 cy.get(`input${disabledPseudo()}`)15 cy.get(`input${disabledPseudo()}[name="name"]`)16 cy.get(`input${disabledPseudo()}[name="name"][value="value"]`)17 cy.get(`input${disabledPseudo()}[name="name"][value="value"]`)18 cy.get(`input${disabledPseudo()}[name="name"][value="value"]`)19 cy.get(`input${disabledPseudo()}[name="name"][value="value"]`)20 })21})

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test disabled buttons', () => {2 it('Visits the app', () => {3 })4 it('Tests disabled button', () => {5 cy.get('[data-cy=btn]').should('be.disabled')6 })7})8Cypress.Commands.add('createDisabledPseudo', () => {9 Cypress.log({10 })11 Cypress.SelectorPlayground.defaults({12 })13 Cypress.SelectorPlayground.addMatcher('disabled', ($el) => {14 const disabled = $el.prop('disabled')15 const disabledAttr = $el.attr('disabled')16 })17})18import './commands'19module.exports = (on, config) => {20 on('file:preprocessor', require('@cypress/code-coverage/use-babelrc'))21}22{23 "retries": {24 },

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.$(":disabled").each(function() {2 const disabledElement = Cypress.$(this);3 const disabledElementColor = disabledElement.css("color");4 expect(disabledElementColor).to.equal("rgb(0, 0, 0)");5});6Cypress.$(":enabled").each(function() {7 const enabledElement = Cypress.$(this);8 const enabledElementColor = enabledElement.css("color");9 expect(enabledElementColor).to.equal("rgb(0, 0, 0)");10});11Cypress.$(":focus").each(function() {12 const focusedElement = Cypress.$(this);13 const focusedElementColor = focusedElement.css("color");14 expect(focusedElementColor).to.equal("rgb(0, 0, 0)");15});16Cypress.$(":hover").each(function() {17 const hoveredElement = Cypress.$(this);18 const hoveredElementColor = hoveredElement.css("color");19 expect(hoveredElementColor).to.equal("rgb(0, 0, 0)");20});21Cypress.$(":active").each(function() {22 const activeElement = Cypress.$(this);23 const activeElementColor = activeElement.css("color");

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('test disabled pseudo class', () => {2 it('should test disabled pseudo class', () => {3 cy.get('button').contains('Disabled Button').should('be.disabled');4 });5});6Cypress.Commands.add('createDisabledPseudo', (element) => {7 cy.log('creating disabled pseudo class');8 cy.wrap(element).invoke('attr', 'disabled', 'disabled');9});10import './commands';11describe('test disabled pseudo class', () => {12 it('should test disabled pseudo class', () => {13 cy.get('button').contains('Disabled Button').should('be.disabled');14 });15});16Cypress.Commands.add('createDisabledPseudo', (element) => {17 cy.log('creating disabled pseudo class');18 cy.wrap(element).invoke('attr', 'disabled', 'disabled');19});20import './commands';21describe('test disabled pseudo class', () => {22 it('should test disabled pseudo class', () => {23 cy.get('button').contains('Disabled Button').should('be.disabled');24 });25});

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress 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