{"id":1042,"date":"2021-07-31T17:30:41","date_gmt":"2021-07-31T17:30:41","guid":{"rendered":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/2021\/07\/31\/advance-cypress-interview-questions-part-1\/"},"modified":"2021-07-31T17:30:41","modified_gmt":"2021-07-31T17:30:41","slug":"advance-cypress-interview-questions-part-1","status":"publish","type":"post","link":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/2021\/07\/31\/advance-cypress-interview-questions-part-1\/","title":{"rendered":"Advance Cypress Interview Questions \u2013 Part 1"},"content":{"rendered":"<p><html><body><\/p>\n<section class=\"tcb-post-content tcb-shortcode thrv_wrapper\" data-css=\"tve-u-16ec5d248bb\">\n<div class=\"tve_flt tcb-style-wrap\" id=\"tve_flt\">\n<div class=\"tve_shortcode_editor tar-main-content\" data-post-id=\"1042\" id=\"tve_editor\">\n<div class=\"thrv_wrapper tve-toc tve-elem-scroll tve-toc-expandable tcb-local-vars-root\" data-animation=\"slide\" data-animation-speed=\"fast\" data-bullet-style='{\"0\":\"tve-u-17399ffbddd\",\"1\":\"tve-u-1739a0466e5\",\"2\":\"tve-u-1739a04a2bb\"}' data-columns=\"1\" data-columns-d=\"1\" data-css=\"tve-u-17afd408490\" data-ct=\"toc-60671\" data-ct-name=\"Table of Contents 03\" data-element-name=\"Table of Contents\" data-headers=\"h1,h3,h5\" data-heading-style='{\"0\":\"tve-u-17afd408495\",\"1\":\"tve-u-17afd408497\",\"2\":\"tve-u-17afd408498\"}' data-highlight=\"section\" data-number-style='{\"0\":\"tve-u-17afd408496\",\"1\":\"tve-u-173dc888a58\",\"2\":\"tve-u-173dc8891dc\"}' data-numbering=\"basic\" data-state-default=\"expanded\" data-state-default-m=\"collapsed\" data-transition=\"fade\" style=\"\">\n<div class=\"thrive-colors-palette-config\" style=\"display: none !important\"><\/div>\n<div class=\"tve-toc-divider\" style=\"position: absolute; width: 0; height: 0; overflow: hidden;\">\n<div class=\"thrv_wrapper thrv-divider tve-vert-divider\" data-color-d=\"rgba(0, 0, 0, 0)\" data-css=\"tve-u-17afd408491\" data-style=\"tve_sep-1\" data-thickness-d=\"1\">\n<hr class=\"tve_sep tve_sep-1\" style=\"\"\/><\/div>\n<\/div>\n<p><svg class=\"toc-icons\" style=\"position: absolute; width: 0; height: 0; overflow: hidden;\" version=\"1.1\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\"><symbol data-id=\"icon-circle-outlined\" id=\"toc-bullet-0\" viewbox=\"0 0 512 512\"><path d=\"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm0 448c-110.5 0-200-89.5-200-200S145.5 56 256 56s200 89.5 200 200-89.5 200-200 200z\"><\/path><\/symbol><symbol data-id=\"icon-circle-outlined\" id=\"toc-bullet-1\" viewbox=\"0 0 512 512\"><path d=\"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm0 448c-110.5 0-200-89.5-200-200S145.5 56 256 56s200 89.5 200 200-89.5 200-200 200z\"><\/path><\/symbol><symbol data-id=\"icon-circle-outlined\" id=\"toc-bullet-2\" viewbox=\"0 0 512 512\"><path d=\"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm0 448c-110.5 0-200-89.5-200-200S145.5 56 256 56s200 89.5 200 200-89.5 200-200 200z\"><\/path><\/symbol><\/svg><\/p>\n<div class=\"tve-content-box-background\" data-css=\"tve-u-17afd408492\" style=\"\"><\/div>\n<div class=\"thrv_wrapper tve-toc-title show-icon tcb-icon-display tve-no-dropzone tve-prevent-content-edit\" data-css=\"tve-u-17afd408493\" style=\"\">\n<div class=\"tve-content-box-background\"><\/div>\n<div class=\"tve-cb\" style=\"\">\n<div class=\"tve-toc-title-icon\" data-icon-code=\"icon-arrow-circle-down-solid\" style=\"\"><svg class=\"tcb-icon\" data-id=\"icon-arrow-circle-down-solid\" data-name=\"\" viewbox=\"0 0 512 512\"><path d=\"M504 256c0 137-111 248-248 248S8 393 8 256 119 8 256 8s248 111 248 248zm-143.6-28.9L288 302.6V120c0-13.3-10.7-24-24-24h-16c-13.3 0-24 10.7-24 24v182.6l-72.4-75.5c-9.3-9.7-24.8-9.9-34.3-.4l-10.9 11c-9.4 9.4-9.4 24.6 0 33.9L239 404.3c9.4 9.4 24.6 9.4 33.9 0l132.7-132.7c9.4-9.4 9.4-24.6 0-33.9l-10.9-11c-9.5-9.5-25-9.3-34.3.4z\"><\/path><\/svg><\/div>\n<div class=\"thrv_wrapper thrv_text_element tve_no_icons\">\n<div class=\"tcb-plain-text\" style=\"\">Table of Contents<\/div>\n<\/p><\/div>\n<\/div>\n<\/div>\n<div class=\"tve-cb tve-toc-content tve-prevent-content-edit\" style=\"\">\n<div class=\"thrv_wrapper tve-toc-list tcb-no-delete tcb-no-save tcb-no-clone tve-no-dropzone\" data-css=\"tve-u-17afd408494\" style=\"\">\n<div class=\"tve-content-box-background\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"tve_ct_content tve_clearfix\">\n<div class=\"ct_column\">\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-17afd408497\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1627746386412\" jump-animation=\"smooth\">1. How can I get the Text content in cypress?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-17afd408497\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1627746386413\" jump-animation=\"smooth\">2. What is cy.contains command?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-17afd408497\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1627746386414\" jump-animation=\"smooth\">3. How can we use browser Navigation in Cypress?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-17afd408497\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1627746386415\" jump-animation=\"smooth\">4. How can I wait for element to be visible in Cypress?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-17afd408497\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1627746386416\" jump-animation=\"smooth\">5. How can I click hidden element?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-17afd408497\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1627746386417\" jump-animation=\"smooth\">6. How can I get the browser Properties in Cypress?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-17afd408497\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1627746386418\" jump-animation=\"smooth\">7. List of some cypress function which will be useful for traversing DOM?<\/a><\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv-divider tve-vert-divider\" data-color-d=\"rgba(0, 0, 0, 0)\" data-css=\"tve-u-17afd408491\" data-style=\"tve_sep-1\" data-thickness-d=\"1\">\n<hr class=\"tve_sep tve_sep-1\" style=\"\"\/><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1627746386412\"><a class=\"tve-froala fr-basic\" name=\"_Toc76910860\" style=\"outline: none;\">1. How can I get the Text content in cypress?<\/a><\/h3>\n<p>Cypress doesn\u2019t provide get text method on element using jQuery Native DOM method we can get the text like below<\/p>\n<div class=\"code-block code-block-2\" style=\"margin: 8px auto; text-align: center; display: block; clear: both;\">\n<p><!-- horizontal responsive 2 --><br \/>\n<ins class=\"adsbygoogle\" data-ad-client=\"ca-pub-3231318496783163\" data-ad-format=\"auto\" data-ad-slot=\"2788468763\" data-full-width-responsive=\"true\" style=\"display:block\"><\/ins>\n<\/div>\n<p><strong>Option 1:<\/strong> Get the text using jQuery method<\/p>\n<p><strong>Option 2:<\/strong> Assert directly using should and have.text<\/p>\n<p><strong>Option 3:<\/strong> Use invoke function to get the text<\/p>\n<p><strong> <\/strong><\/p>\n<p><strong>Option1: <\/strong>Get the text using JQuery method<\/p>\n<p><strong><em>Example:<\/em><\/strong><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17afd42374e\" style=\"\">\n<p data-css=\"tve-u-17afd42b6b9\" style=\"\">cy.get(&#8216;#customers&#8217;).then(($ele)=&gt;{<\/p>\n<p data-css=\"tve-u-17afd42b6bb\" style=\"\">cy.log($ele.text()); \/\/logs the text<\/p>\n<p data-css=\"tve-u-17afd42b6bc\" style=\"\">})<strong>\u00a0<\/strong><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p><strong>Option 2: If we want to verify text we can directly use it, we don\u2019t have to use above method<\/strong><\/p>\n<p><strong><em>Example:<\/em><\/strong><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17afd4305ed\" style=\"\">\n<p data-css=\"tve-u-17afd4344e4\" style=\"\">cy.get(&#8216;div&#8217;).should(&#8216;have.text&#8217;, &#8216;foobarbaz&#8217;)<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p><strong>Option 3: we can use invoke function to get the text<\/strong><\/p>\n<p><strong><em>Example:<\/em><\/strong><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17afd446536\" style=\"\">\n<p data-css=\"tve-u-17afd44b3a8\" style=\"\">cy.log(&#8220;**********&#8221;+text); \/\/logs the text<\/p>\n<p data-css=\"tve-u-17afd449bc9\" style=\"\">});<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1627746386413\"><a class=\"tve-froala fr-basic\" name=\"_Toc76910861\" style=\"outline: none;\">2. What is cy.contains command?<\/a><\/h3>\n<p><strong>cy.contains()<\/strong> command can be used to find the element by using their contents<\/p>\n<p><strong>Example:<\/strong><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17afd455179\" style=\"\">\n<p data-css=\"tve-u-17afd458813\" style=\"\">cy.contains(&#8216;Hello&#8217;)<\/p>\n<p data-css=\"tve-u-17afd458815\" style=\"\">\/\/This returns the first matching element which is<\/p>\n<p data-css=\"tve-u-17afd458816\" style=\"\">having text hello<\/p>\n<p data-css=\"tve-u-17afd458818\" style=\"\">cy.get(&#8216;.button&#8217;).contains(&#8216;Clickme&#8217;)<\/p>\n<p data-css=\"tve-u-17afd458819\" style=\"\">\/\/This returns element with .button class having text Click me<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1627746386414\"><a class=\"tve-froala\" name=\"_Toc76910862\" style=\"outline: none;\">3. How can we use browser Navigation in Cypress?<\/a><\/h3>\n<p>Cypress provides a way to navigate back and forward in browser<\/p>\n<p><strong>cy.go()<\/strong> function can be used for this purpose<\/p>\n<p><strong>cy.go(&#8216;back&#8217;)<\/strong><br \/>\n<u>or<\/u><br \/>\n<strong>cy.go(-1)<\/strong>\u00a0 is used to navigate to previous browser history<\/p>\n<p><strong>cy.go(&#8216;forward&#8217;)<\/strong>\u00a0 <u>or<\/u><br \/>\n<strong>cy.go(1)<\/strong> is used to go forward in browser history<\/p>\n<p><strong>Example:<\/strong><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17afd45f4f3\" style=\"\">\n<p data-css=\"tve-u-17afd46487e\" style=\"\">cy.go(&#8216;back&#8217;)<\/p>\n<p data-css=\"tve-u-17afd464880\" style=\"\">cy.location(&#8216;pathname&#8217;).should(&#8216;not.include&#8217;, &#8216;navigation&#8217;)<\/p>\n<p data-css=\"tve-u-17afd464881\" style=\"\">cy.go(&#8216;forward&#8217;)<\/p>\n<p data-css=\"tve-u-17afd464882\" style=\"\">cy.location(&#8216;pathname&#8217;).should(&#8216;include&#8217;, &#8216;navigation&#8217;)<\/p>\n<p data-css=\"tve-u-17afd464883\" style=\"\">\/\/ clicking back<\/p>\n<p data-css=\"tve-u-17afd464885\" style=\"\">cy.go(-1)<\/p>\n<p data-css=\"tve-u-17afd464886\" style=\"\">cy.location(&#8216;pathname&#8217;).should(&#8216;not.include&#8217;, &#8216;navigation&#8217;)<\/p>\n<p data-css=\"tve-u-17afd464887\" style=\"\">\/\/ clicking forward<\/p>\n<p data-css=\"tve-u-17afd464888\" style=\"\">cy.go(1)<\/p>\n<p data-css=\"tve-u-17afd46488a\" style=\"\">cy.location(&#8216;pathname&#8217;).should(&#8216;include&#8217;, &#8216;navigation&#8217;)<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1627746386415\"><a class=\"tve-froala fr-basic\" name=\"_Toc76910863\" style=\"outline: none;\">4. How can I wait for element to be visible in Cypress?<\/a><\/h3>\n<p>Cypress internally wait for element before performing any action. However we can use the below code as a workaround whenever necessary<\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17afd46b979\" style=\"\">\n<p data-css=\"tve-u-17afd46e3bb\" style=\"\">cy.get(&#8216;.somelement&#8217;, { timeout: 10000 }).should(&#8216;be.visible&#8217;);<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1627746386416\"><a class=\"tve-froala fr-basic\" name=\"_Toc76910864\" style=\"outline: none;\">5. How can I click hidden element?<\/a><\/h3>\n<p>Most of the type in other automation framework if element is not visible or interactable we get error message but cypress provides a way to click on hidden element using <em><strong>{force:true}<\/strong><\/em> option<\/p>\n<p><strong>Example:<\/strong><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17afd475fd0\" style=\"\">\n<p data-css=\"tve-u-17afd47979a\" style=\"\">cy.get(&#8216;.checkbox&#8217;).check({ force: true })<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1627746386417\"><a class=\"tve-froala\" name=\"_Toc76910865\" style=\"outline: none;\">6. How can I get the browser Properties in Cypress?<\/a><\/h3>\n<p><strong>Cypress.browser<\/strong> gives the all browser properties such as name, path, headless, channel etc.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17afd480165\" style=\"\">\n<p data-css=\"tve-u-17afd483ff9\" style=\"\">let browserName = cypress.browser.name<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\"><a class=\"tve-froala fr-basic\" name=\"_Toc76910866\" style=\"outline: none;\">7. List of some cypress function which will be useful for traversing DOM?<\/a><\/h3>\n<p><strong>Note: Any one can be asked to explain or some of them will be asked in Interview<\/strong><\/p>\n<p>Cypress framework by default provides many traversal functions<\/p>\n<p><strong>.prev():<\/strong> .<strong>prev() <\/strong>is used to \u00a0get the immediately preceding sibling of each element in a set of the elements.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17afd48a1b4\" style=\"\">\n<p data-css=\"tve-u-17afd48ddea\" style=\"\">cy.get(&#8216;tr.highlight&#8217;).prev();<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p><strong>b) .prevAll()<\/strong>: <strong>.prevAll()<\/strong> can be used to get all previous siblings of each DOM element in a set of matched DOM elements.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17afd4ed7d8\" style=\"\">\n<p data-css=\"tve-u-17afd4f1314\" style=\"\">cy.get(&#8216;.active&#8217;).prevAll()<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p><strong>.prevUntil():<\/strong> prevUntil can be used to get all previous siblings of each DOM element in a set of matched DOM elements up to, but not including, the element provided.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<p>Consider below HTML code:<\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17afd50bdef\" style=\"\">\n<p data-css=\"tve-u-17afd50fd3d\" style=\"\">&lt;ul&gt;<\/p>\n<p data-css=\"tve-u-17afd50fd3f\" style=\"\">\u00a0 &lt;li id=&#8221;fruits&#8221; class=&#8221;header&#8221;&gt;Fruits&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd50fd41\" style=\"\">\u00a0 &lt;li&gt;apples&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd50fd42\" style=\"\">\u00a0 &lt;li&gt;oranges&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd50fd44\" style=\"\">\u00a0 &lt;li&gt;bananas&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd50fd45\" style=\"\">\u00a0 &lt;li id=&#8221;veggies&#8221; class=&#8221;header&#8221;&gt;Vegetables&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd50fd46\" style=\"\">\u00a0 &lt;li&gt;cucumbers&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd50fd47\" style=\"\">\u00a0 &lt;li&gt;carrots&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd50fd49\" style=\"\">\u00a0 &lt;li&gt;corn&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd50fd4a\" style=\"\">\u00a0 &lt;li id=&#8221;nuts&#8221; class=&#8221;header&#8221;&gt;Nuts&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd50fd4b\" style=\"\">\u00a0 &lt;li&gt;walnuts&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd50fd4c\" style=\"\">\u00a0 &lt;li&gt;cashews&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd50fd4e\" style=\"\">\u00a0 &lt;li&gt;almonds&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd50fd4f\" style=\"\">&lt;\/ul&gt;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p>Then I used cy.get(&#8216;#nuts&#8217;).prevUntil(&#8216;#veggies&#8217;) it returns all the previous sibling&#8217;s until <strong>#veggies <\/strong>which is<strong> <\/strong>\u00a0<\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17afd5d10af\" style=\"\">\n<p data-css=\"tve-u-17afd5d2d42\" style=\"\">[&lt;li&gt;cucumbers&lt;\/li&gt;, &lt;li&gt;carrots&lt;\/li&gt;, &lt;li&gt;corn&lt;\/li&gt;]<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p><strong>c) .parent():\u00a0<\/strong>.parent() is used to get the parent DOM element of a set of DOM elements..parent() only travels a single level up<\/p>\n<p><strong>Example:<\/strong><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17afd5d849b\" style=\"\">\n<p data-css=\"tve-u-17afd5de294\" style=\"\">cy.get(&#8216;header&#8217;).parent()<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p><strong>d) .parents()<\/strong>: .parents is used to get the parent DOM elements of a set of DOM elements..parents() travels multiple levels up the DOM<\/p>\n<p><strong>Example:<\/strong><\/p>\n<p>Consider we have HTML code like below<\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17afd5e899e\" style=\"\">\n<p data-css=\"tve-u-17afd5eb6fb\" style=\"\">&lt;ul class=&#8221;main-nav&#8221;&gt;<\/p>\n<p data-css=\"tve-u-17afd5eb6fd\" style=\"\">\u00a0 &lt;li&gt;Overview&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd5eb6ff\" style=\"\">\u00a0 &lt;li&gt;<\/p>\n<p data-css=\"tve-u-17afd5eb700\" style=\"\">\u00a0\u00a0\u00a0 Getting started<\/p>\n<p data-css=\"tve-u-17afd5eb701\" style=\"\">\u00a0\u00a0\u00a0 &lt;ul class=&#8221;sub-nav&#8221;&gt;<\/p>\n<p data-css=\"tve-u-17afd5eb703\" style=\"\">\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;li&gt;Install&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd5eb704\" style=\"\">\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;li class=&#8221;active&#8221;&gt;Build&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd5eb705\" style=\"\">\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;li&gt;Test&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd5eb706\" style=\"\">\u00a0\u00a0\u00a0 &lt;\/ul&gt;<\/p>\n<p data-css=\"tve-u-17afd5eb708\" style=\"\">\u00a0 &lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd5eb709\" style=\"\">&lt;\/ul&gt;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p>If we use<\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17afd5eecb5\" style=\"\">\n<p data-css=\"tve-u-17afd5f1e18\" style=\"\">cy.get(&#8216;li.active&#8217;).parents()<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p>then the output is array of elements which contains <strong>[.sub-nav, li, .main-nav]<\/strong><\/p>\n<p><strong>e) .parentsUntil()<\/strong>: .parentsUntil() is used to get all ancestors of each DOM element in a set of matched DOM elements up to, but not including the specified element<\/p>\n<p><strong>Example: <\/strong><\/p>\n<p>Consider below HTML<\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17afd602395\" style=\"\">\n<p data-css=\"tve-u-17afd605f6f\" style=\"\">&lt;ul class=&#8221;nav&#8221;&gt;<\/p>\n<p data-css=\"tve-u-17afd605f71\" style=\"\">\u00a0 &lt;li&gt;<\/p>\n<p data-css=\"tve-u-17afd605f72\" style=\"\">\u00a0\u00a0\u00a0 &lt;a href=&#8221;#&#8221;&gt;Clothes&lt;\/a&gt;<\/p>\n<p data-css=\"tve-u-17afd605f74\" style=\"\">\u00a0\u00a0\u00a0 &lt;ul class=&#8221;menu&#8221;&gt;<\/p>\n<p data-css=\"tve-u-17afd605f75\" style=\"\">\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;li&gt;<\/p>\n<p data-css=\"tve-u-17afd605f76\" style=\"\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;a href=&#8221;\/shirts&#8221;&gt;Shirts&lt;\/a&gt;<\/p>\n<p data-css=\"tve-u-17afd605f78\" style=\"\">\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd605f79\" style=\"\">\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;li class=&#8221;active&#8221;&gt;<\/p>\n<p data-css=\"tve-u-17afd605f7a\" style=\"\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;a href=&#8221;\/pants&#8221;&gt;Pants&lt;\/a&gt;<\/p>\n<p data-css=\"tve-u-17afd605f7b\" style=\"\">\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd605f7d\" style=\"\">\u00a0\u00a0\u00a0 &lt;\/ul&gt;<\/p>\n<p data-css=\"tve-u-17afd605f7e\" style=\"\">\u00a0 &lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd605f7f\" style=\"\">&lt;\/ul&gt;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p>If I used \u00a0<em><strong>cy.get(&#8216;.active&#8217;).parentsUntil(&#8216;.nav&#8217;)<\/strong><\/em> \u00a0then it return all the parents until <strong>.nav. <\/strong>Which will be [ul.menu, li]<\/p>\n<p><strong>f) .next():<\/strong> .next is used to get the immediately following sibling of each DOM element within a set of DOM elements.<\/p>\n<p><strong>Example: <\/strong><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17afd612cc2\" style=\"\">\n<p data-css=\"tve-u-17afd6149dc\" style=\"\">&lt;ul&gt;<\/p>\n<p data-css=\"tve-u-17afd6149df\" style=\"\">\u00a0 &lt;li&gt;apples&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd6149e0\" style=\"\">\u00a0 &lt;li class=&#8221;second&#8221;&gt;oranges&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd6149e1\" style=\"\">\u00a0 &lt;li&gt;bananas&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd6149e3\" style=\"\">&lt;\/ul&gt;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p>Consider above HTML Code,<\/p>\n<p>If I use <em><strong>cy.get(&#8216;.second&#8217;).next()<\/strong><\/em> then it returns <strong>bananas<\/strong><strong><\/strong><br \/><strong><\/strong><br \/><strong>g) .nextAll():<\/strong> .nextAll can be used to get all following siblings of each DOM element in a set of matched DOM elements.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17afd623181\" style=\"\">\n<p data-css=\"tve-u-17afd625fb3\" style=\"\">&lt;ul&gt;<\/p>\n<p data-css=\"tve-u-17afd625fb5\" style=\"\">\u00a0 &lt;li&gt;apples&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd625fb7\" style=\"\">\u00a0 &lt;li class=&#8221;second&#8221;&gt;oranges&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd625fb8\" style=\"\">\u00a0 &lt;li&gt;bananas&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd625fb9\" style=\"\">\u00a0 &lt;li&gt;pineapples&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd625fba\" style=\"\">\u00a0 &lt;li&gt;grapes&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd625fbc\" style=\"\">&lt;\/ul&gt;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p>The code <em><strong>cy.get(&#8216;.second&#8217;).nextAll() <\/strong><\/em>will return array of next all siblings which is [&lt;li&gt;bananas&lt;\/li&gt;, &lt;li&gt;pineapples&lt;\/li&gt;, &lt;li&gt;grapes&lt;\/li&gt;]<\/p>\n<p><strong>h) .nextUntil()<\/strong> : .nextUntill() is used to get all following siblings of each DOM element in a set of matched DOM elements up to, but not including, the element provided.<\/p>\n<p><strong>Example: <\/strong><\/p>\n<p>Consider below HTML code<\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17afd632ee8\" style=\"\">\n<p data-css=\"tve-u-17afd636d3c\" style=\"\">&lt;ul&gt;<\/p>\n<p data-css=\"tve-u-17afd636d3e\" style=\"\">\u00a0 &lt;li id=&#8221;fruits&#8221; class=&#8221;header&#8221;&gt;Fruits&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd636d40\" style=\"\">\u00a0 &lt;li&gt;apples&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd636d41\" style=\"\">\u00a0 &lt;li&gt;oranges&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd636d42\" style=\"\">\u00a0 &lt;li&gt;bananas&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd636d43\" style=\"\">\u00a0 &lt;li id=&#8221;veggies&#8221; class=&#8221;header&#8221;&gt;Vegetables&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd636d45\" style=\"\">\u00a0 &lt;li&gt;cucumbers&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd636d46\" style=\"\">\u00a0 &lt;li&gt;carrots&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd636d47\" style=\"\">\u00a0 &lt;li&gt;corn&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd636d49\" style=\"\">\u00a0 &lt;li id=&#8221;nuts&#8221; class=&#8221;header&#8221;&gt;Nuts&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd636d4a\" style=\"\">\u00a0 &lt;li&gt;walnuts&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd636d4b\" style=\"\">\u00a0 &lt;li&gt;cashews&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd636d4c\" style=\"\">\u00a0 &lt;li&gt;almonds&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd636d4e\" style=\"\">&lt;\/ul&gt;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p>If we use <em><strong>cy.get(&#8216;#veggies&#8217;).nextUntil(&#8216;#nuts&#8217;)<\/strong><\/em> in our code then it will return array of elements containing next siblings until <strong>#veggies <\/strong>which is [&lt;li&gt;cucumbers&lt;\/li&gt;, &lt;li&gt;carrots&lt;\/li&gt;, &lt;li&gt;corn&lt;\/li&gt;]<\/p>\n<p><strong>i) <\/strong>.<strong>first(): <\/strong>.first() can be used to get the first match matching DOM element<\/p>\n<p><strong>Example: <\/strong><\/p>\n<p>Consider below HTML code<\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17afd644660\" style=\"\">\n<p data-css=\"tve-u-17afd646e21\" style=\"\">&lt;ul&gt;<\/p>\n<p data-css=\"tve-u-17afd646e23\" style=\"\">\u00a0 &lt;li class=&#8221;one&#8221;&gt;Knick knack on my thumb&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd646e24\" style=\"\">\u00a0 &lt;li class=&#8221;two&#8221;&gt;Knick knack on my shoe&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd646e26\" style=\"\">\u00a0 &lt;li class=&#8221;three&#8221;&gt;Knick knack on my knee&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd646e27\" style=\"\">\u00a0 &lt;li class=&#8221;four&#8221;&gt;Knick knack on my door&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd646e28\" style=\"\">&lt;\/ul&gt;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p data-css=\"tve-u-17afd65ec85\"><code>If we use <\/code><em><strong>cy.get(&#8216;li&#8217;).first()<\/strong><\/em><code> in our code it returns first matching element which is <\/code><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17afd6501dd\" style=\"\">\n<p data-css=\"tve-u-17afd652a09\" style=\"\">&lt;li class=&#8221;one&#8221;&gt;Knick knack on my thumb&lt;\/li&gt;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p><strong>j) .last() :\u00a0<\/strong>The .last() method returns the last matching DOM element<strong> <br \/>Example: <br \/>Consider below HTML code<\/strong><\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17afd6aa948\" style=\"\">\n<p data-css=\"tve-u-17afd6ada3c\" style=\"\">&lt;ul&gt;<\/p>\n<p data-css=\"tve-u-17afd6ada3e\" style=\"\">\u00a0 &lt;li class=&#8221;one&#8221;&gt;Knick knack on my thumb&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd6ada40\" style=\"\">\u00a0 &lt;li class=&#8221;two&#8221;&gt;Knick knack on my shoe&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd6ada41\" style=\"\">\u00a0 &lt;li class=&#8221;three&#8221;&gt;Knick knack on my knee&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd6ada42\" style=\"\">\u00a0 &lt;li class=&#8221;four&#8221;&gt;Knick knack on my door&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd6ada43\" style=\"\">&lt;\/ul&gt;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p>If we use cy.get(&#8216;li&#8217;).last() in our test script then it returns last matching dom element which is<\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17afd6ba1a6\" style=\"\">\n<p data-css=\"tve-u-17afd6bcd26\" style=\"\">&lt;li class=&#8221;four&#8221;&gt;Knick knack on my door&lt;\/li&gt;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p><strong>j) .children():<\/strong> .childeren can be used to get the children of each DOM element within a set of DOM elements.<\/p>\n<p><strong>Example: <\/strong><\/p>\n<p>Consider below HTML code<\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17afd9ae20d\" style=\"\">\n<p data-css=\"tve-u-17afd9b1b82\" style=\"\">&lt;ul class=&#8221;secondary-nav&#8221;&gt;<\/p>\n<p data-css=\"tve-u-17afd9b1b85\" style=\"\">\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;li class=&#8221;services-1&#8243;&gt;Web Design&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd9b1b86\" style=\"\">\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;li class=&#8221;services-2&#8243;&gt;Logo Design&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd9b1b87\" style=\"\">\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;li class=&#8221;services-3&#8243;&gt;<\/p>\n<p data-css=\"tve-u-17afd9b1b89\" style=\"\">&lt;\/ul&gt;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p>In our test script we use <em><strong>cy.get(&#8216;ul.secondary-nav&#8217;).children()<\/strong><\/em> then it returns all the children of <em><strong>&#8216;ul.secondary-nav&#8217;<\/strong><\/em> class which is<\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17afd9bb31d\" style=\"\">\n<p data-css=\"tve-u-17afd9beda9\" style=\"\">[<\/p>\n<p data-css=\"tve-u-17afd9bedac\" style=\"\">&lt;li class=&#8221;services-1&#8243;&gt;Web Design&lt;\/li&gt;,<\/p>\n<p data-css=\"tve-u-17afd9bedad\" style=\"\">&lt;li class=&#8221;services-2&#8243;&gt;Logo Design&lt;\/li&gt;,<\/p>\n<p data-css=\"tve-u-17afd9bedae\" style=\"\">&lt;li class=&#8221;services-3&#8243;&gt;Print Design&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd9bedb0\" style=\"\">]<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p><strong>l) .root():<\/strong> root can be used to get the root DOM element<\/p>\n<p><strong>Example: cy.root() returns &lt;html&gt;<\/strong><\/p>\n<p><strong>m) . siblings ():<\/strong> . siblings() returns all the siblings of specified DOM element<\/p>\n<p><strong>Example:<\/strong><\/p>\n<p>Consider below HTML code<\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_contentbox_shortcode thrv-content-box tve-elem-default-pad\">\n<div class=\"tve-content-box-background\" style=\"background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)) !important; background-size: auto !important; background-position: 50% 50% !important; background-attachment: scroll !important; background-repeat: no-repeat !important; --background-image:linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5))  !important; --background-size:auto auto  !important; --background-position:50% 50%  !important; --background-attachment:scroll  !important; --background-repeat:no-repeat  !important;\"><\/div>\n<div class=\"tve-cb\">\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-17afd9cca53\" style=\"\">\n<p data-css=\"tve-u-17afd9d0847\" style=\"\">&lt;ul&gt;<\/p>\n<p data-css=\"tve-u-17afd9d084a\" style=\"\">\u00a0 &lt;li&gt;Home&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd9d084b\" style=\"\">\u00a0 &lt;li&gt;Contact&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd9d084d\" style=\"\">\u00a0 &lt;li class=&#8221;active&#8221;&gt;Services&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd9d084e\" style=\"\">\u00a0 &lt;li&gt;Price&lt;\/li&gt;<\/p>\n<p data-css=\"tve-u-17afd9d084f\" style=\"\">&lt;\/ul&gt;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p>If I use <em><strong>cy.get(&#8216;.active&#8217;).siblings()<\/strong><\/em> which will return me all siblings of <strong>.active<\/strong> class which is<strong> [&#8216;&lt;li&gt;Price&lt;\/li&gt;,&lt;li&gt;Home&lt;\/li&gt;&lt;li&gt;Contact&lt;\/li&gt;]<\/strong><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"tcb_flag\" style=\"display: none\"><\/div>\n<\/section>\n<p><\/body><\/html><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Table of Contents 1. How can I get the Text content in cypress? 2. What is cy.contains command? 3. How can we use browser Navigation in Cypress? 4. How can I wait for element to be visible in Cypress? 5. How can I click hidden element? 6. How can I get the browser Properties in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,4],"tags":[],"class_list":["post-1042","post","type-post","status-publish","format-standard","hentry","category-cypress","category-interview-questions","post-wrapper","thrv_wrapper"],"_links":{"self":[{"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1042","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=1042"}],"version-history":[{"count":0,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1042\/revisions"}],"wp:attachment":[{"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=1042"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=1042"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=1042"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}