{"id":760,"date":"2021-07-21T18:42:35","date_gmt":"2021-07-21T18:42:35","guid":{"rendered":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/2021\/07\/21\/common-cypress-interview-questions\/"},"modified":"2021-07-21T18:42:35","modified_gmt":"2021-07-21T18:42:35","slug":"common-cypress-interview-questions","status":"publish","type":"post","link":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/2021\/07\/21\/common-cypress-interview-questions\/","title":{"rendered":"Common Cypress Interview Questions"},"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=\"760\" id=\"tve_editor\">\n<div class=\"thrv_wrapper tve-toc tve-elem-scroll tve-toc-expandable show-icon tcb-icon-display tcb-local-vars-root\" data-animation=\"slide\" data-animation-speed=\"slow\" data-bullet-style='{\"0\":\"tve-u-17399bf2913\",\"1\":\"tve-u-17399c228ad\",\"2\":\"tve-u-17399c282f4\"}' data-columns=\"1\" data-columns-d=\"1\" data-css=\"tve-u-17aca2412f9\" data-ct=\"toc-60696\" data-ct-name=\"Table of Contents 12\" data-element-name=\"Table of Contents\" data-headers=\"h3,h5\" data-heading-style='{\"0\":\"tve-u-17aca241302\",\"1\":\"tve-u-17aca241304\",\"2\":\"tve-u-17aca241306\"}' data-highlight=\"progressive\" data-id=\"lsjywc2j\" data-number-style='{\"0\":\"tve-u-17aca241303\",\"1\":\"tve-u-17aca241305\",\"2\":\"tve-u-17aca241307\"}' data-numbering=\"advanced\" data-state-default=\"expanded\" data-state-default-m=\"collapsed\" data-transition=\"none\" style=\"\">\n<div class=\"thrive-colors-palette-config\" style=\"display: none !important\"><\/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-lsjywc2j\" 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-lsjywc2j\" 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-lsjywc2j\" 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-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.08)\" data-css=\"tve-u-17aca2412fb\" data-style=\"tve_sep-1\" data-thickness-d=\"1\">\n<hr class=\"tve_sep tve_sep-1\" style=\"\"\/><\/div>\n<\/div>\n<div class=\"tve-content-box-background\" data-css=\"tve-u-17aca2412fc\"><\/div>\n<div class=\"thrv_wrapper tve-toc-title tve-toc-hidden reverse show-icon tcb-icon-display tve-no-dropzone tve-prevent-content-edit\" data-css=\"tve-u-17aca2412fd\" style=\"\">\n<div class=\"tve-content-box-background\" style=\"\"><\/div>\n<div class=\"tve-cb\" style=\"\">\n<div class=\"tve-toc-title-icon\" data-icon-code=\"icon-caret-right-solid\" style=\"\"><svg class=\"tcb-icon\" data-id=\"icon-caret-right-solid\" data-name=\"\" viewbox=\"0 0 192 512\">\n<path d=\"M0 384.662V127.338c0-17.818 21.543-26.741 34.142-14.142l128.662 128.662c7.81 7.81 7.81 20.474 0 28.284L34.142 398.804C21.543 411.404 0 402.48 0 384.662z\"><\/path>\n<\/svg><\/div>\n<div class=\"thrv_wrapper thrv_text_element tve_no_icons\" data-css=\"tve-u-17aca2412fe\" style=\"\">\n<div class=\"tcb-plain-text\" data-css=\"tve-u-17aca2412ff\" style=\"\">Table Of Contents<\/div>\n<\/p><\/div>\n<\/div>\n<\/div>\n<div class=\"tve-cb tve-toc-content tve-prevent-content-edit\">\n<div class=\"thrv_wrapper tve-toc-list tcb-no-delete tcb-no-save tcb-no-clone tve-no-dropzone\" data-css=\"tve-u-17aca241300\" style=\"\">\n<div class=\"tve-content-box-background\" data-css=\"tve-u-17aca241301\" data-tcb_hover_state_parent=\"1\" style=\"\"><\/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-level0 tve_no_icons\" data-css=\"tve-u-17aca241302\" data-element-name=\"Heading Level 1\" data-tag=\"H3\">\n<div class=\"thrv_wrapper tve-toc-number tve-toc-number0 tve_no_icons tve-jump-scroll\" data-css=\"tve-u-17aca241303\" data-element-name=\"Number Level 1\" data-level=\"0\" data-target=\"#t-1626888826259\" jump-animation=\"smooth\"><span class=\"tve-toc-disabled\">1<\/span><\/div>\n<p><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1626888826259\" jump-animation=\"smooth\">What is Cypress?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level0 tve_no_icons\" data-css=\"tve-u-17aca241302\" data-element-name=\"Heading Level 1\" data-tag=\"H3\">\n<div class=\"thrv_wrapper tve-toc-number tve-toc-number0 tve_no_icons tve-jump-scroll\" data-css=\"tve-u-17aca241303\" data-element-name=\"Number Level 1\" data-level=\"0\" data-target=\"#t-1626888826260\" jump-animation=\"smooth\"><span class=\"tve-toc-disabled\">2<\/span><\/div>\n<p><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1626888826260\" jump-animation=\"smooth\">How Cypress architecture is different from selenium?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level0 tve_no_icons\" data-css=\"tve-u-17aca241302\" data-element-name=\"Heading Level 1\" data-tag=\"H3\">\n<div class=\"thrv_wrapper tve-toc-number tve-toc-number0 tve_no_icons tve-jump-scroll\" data-css=\"tve-u-17aca241303\" data-element-name=\"Number Level 1\" data-level=\"0\" data-target=\"#t-1626888826261\" jump-animation=\"smooth\"><span class=\"tve-toc-disabled\">3<\/span><\/div>\n<p><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1626888826261\" jump-animation=\"smooth\">Can I use Cypress framework with C# or Java just like Selenium?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level0 tve_no_icons\" data-css=\"tve-u-17aca241302\" data-element-name=\"Heading Level 1\" data-tag=\"H3\">\n<div class=\"thrv_wrapper tve-toc-number tve-toc-number0 tve_no_icons tve-jump-scroll\" data-css=\"tve-u-17aca241303\" data-element-name=\"Number Level 1\" data-level=\"0\" data-target=\"#t-1626888826262\" jump-animation=\"smooth\"><span class=\"tve-toc-disabled\">4<\/span><\/div>\n<p><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1626888826262\" jump-animation=\"smooth\">Could you tell me about some differences between Cypress and Selenium?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level0 tve_no_icons\" data-css=\"tve-u-17aca241302\" data-element-name=\"Heading Level 1\" data-tag=\"H3\">\n<div class=\"thrv_wrapper tve-toc-number tve-toc-number0 tve_no_icons tve-jump-scroll\" data-css=\"tve-u-17aca241303\" data-element-name=\"Number Level 1\" data-level=\"0\" data-target=\"#t-1626888826264\" jump-animation=\"smooth\"><span class=\"tve-toc-disabled\">5<\/span><\/div>\n<p><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1626888826264\" jump-animation=\"smooth\">What are the advantages of Cypress?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level0 tve_no_icons\" data-css=\"tve-u-17aca241302\" data-element-name=\"Heading Level 1\" data-tag=\"H3\">\n<div class=\"thrv_wrapper tve-toc-number tve-toc-number0 tve_no_icons tve-jump-scroll\" data-css=\"tve-u-17aca241303\" data-element-name=\"Number Level 1\" data-level=\"0\" data-target=\"#t-1626888826265\" jump-animation=\"smooth\"><span class=\"tve-toc-disabled\">6<\/span><\/div>\n<p><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1626888826265\" jump-animation=\"smooth\">Can I use Junit or TestNG in cypress?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level0 tve_no_icons\" data-css=\"tve-u-17aca241302\" data-element-name=\"Heading Level 1\" data-tag=\"H3\">\n<div class=\"thrv_wrapper tve-toc-number tve-toc-number0 tve_no_icons tve-jump-scroll\" data-css=\"tve-u-17aca241303\" data-element-name=\"Number Level 1\" data-level=\"0\" data-target=\"#t-1626888826266\" jump-animation=\"smooth\"><span class=\"tve-toc-disabled\">7<\/span><\/div>\n<p><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1626888826266\" jump-animation=\"smooth\">How can I install cypress?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level0 tve_no_icons\" data-css=\"tve-u-17aca241302\" data-element-name=\"Heading Level 1\" data-tag=\"H3\">\n<div class=\"thrv_wrapper tve-toc-number tve-toc-number0 tve_no_icons tve-jump-scroll\" data-css=\"tve-u-17aca241303\" data-element-name=\"Number Level 1\" data-level=\"0\" data-target=\"#t-1626888826267\" jump-animation=\"smooth\"><span class=\"tve-toc-disabled\">8<\/span><\/div>\n<p><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1626888826267\" jump-animation=\"smooth\">How can I open cypress window and execute tests?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level0 tve_no_icons\" data-css=\"tve-u-17aca241302\" data-element-name=\"Heading Level 1\" data-tag=\"H3\">\n<div class=\"thrv_wrapper tve-toc-number tve-toc-number0 tve_no_icons tve-jump-scroll\" data-css=\"tve-u-17aca241303\" data-element-name=\"Number Level 1\" data-level=\"0\" data-target=\"#t-1626888826268\" jump-animation=\"smooth\"><span class=\"tve-toc-disabled\">9<\/span><\/div>\n<p><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1626888826268\" jump-animation=\"smooth\">Could you talk something about Cypress file and folder structures?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level0 tve_no_icons\" data-css=\"tve-u-17aca241302\" data-element-name=\"Heading Level 1\" data-tag=\"H3\">\n<div class=\"thrv_wrapper tve-toc-number tve-toc-number0 tve_no_icons tve-jump-scroll\" data-css=\"tve-u-17aca241303\" data-element-name=\"Number Level 1\" data-level=\"0\" data-target=\"#t-1626888826269\" jump-animation=\"smooth\"><span class=\"tve-toc-disabled\">10<\/span><\/div>\n<p><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1626888826269\" jump-animation=\"smooth\">What is Cypress CLI?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level0 tve_no_icons\" data-css=\"tve-u-17aca241302\" data-element-name=\"Heading Level 1\" data-tag=\"H3\">\n<div class=\"thrv_wrapper tve-toc-number tve-toc-number0 tve_no_icons tve-jump-scroll\" data-css=\"tve-u-17aca241303\" data-element-name=\"Number Level 1\" data-level=\"0\" data-target=\"#t-1626888826270\" jump-animation=\"smooth\"><span class=\"tve-toc-disabled\">11<\/span><\/div>\n<p><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1626888826270\" jump-animation=\"smooth\">How can I run single specfile in command line?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level0 tve_no_icons\" data-css=\"tve-u-17aca241302\" data-element-name=\"Heading Level 1\" data-tag=\"H3\">\n<div class=\"thrv_wrapper tve-toc-number tve-toc-number0 tve_no_icons tve-jump-scroll\" data-css=\"tve-u-17aca241303\" data-element-name=\"Number Level 1\" data-level=\"0\" data-target=\"#t-1626888826271\" jump-animation=\"smooth\"><span class=\"tve-toc-disabled\">12<\/span><\/div>\n<p><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1626888826271\" jump-animation=\"smooth\">I am new to cypress, I wanted to execute hello world test script in cypress how can I do that could you explain?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level0 tve_no_icons\" data-css=\"tve-u-17aca241302\" data-element-name=\"Heading Level 1\" data-tag=\"H3\">\n<div class=\"thrv_wrapper tve-toc-number tve-toc-number0 tve_no_icons tve-jump-scroll\" data-css=\"tve-u-17aca241303\" data-element-name=\"Number Level 1\" data-level=\"0\" data-target=\"#t-1626888826272\" jump-animation=\"smooth\"><span class=\"tve-toc-disabled\">13<\/span><\/div>\n<p><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1626888826272\" jump-animation=\"smooth\">Why should I create my tests inside integration folder, why can\u2019t I create test in other folders?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level0 tve_no_icons\" data-css=\"tve-u-17aca241302\" data-element-name=\"Heading Level 1\" data-tag=\"H3\">\n<div class=\"thrv_wrapper tve-toc-number tve-toc-number0 tve_no_icons tve-jump-scroll\" data-css=\"tve-u-17aca241303\" data-element-name=\"Number Level 1\" data-level=\"0\" data-target=\"#t-1626888826273\" jump-animation=\"smooth\"><span class=\"tve-toc-disabled\">14<\/span><\/div>\n<p><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1626888826273\" jump-animation=\"smooth\">How can see the default configuration in Cypress?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level0 tve_no_icons\" data-css=\"tve-u-17aca241302\" data-element-name=\"Heading Level 1\" data-tag=\"H3\">\n<div class=\"thrv_wrapper tve-toc-number tve-toc-number0 tve_no_icons tve-jump-scroll\" data-css=\"tve-u-17aca241303\" data-element-name=\"Number Level 1\" data-level=\"0\" data-target=\"#t-1626888826274\" jump-animation=\"smooth\"><span class=\"tve-toc-disabled\">15<\/span><\/div>\n<p><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1626888826274\" jump-animation=\"smooth\">How can I create suites in cypress?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level0 tve_no_icons\" data-css=\"tve-u-17aca241302\" data-element-name=\"Heading Level 1\" data-tag=\"H3\">\n<div class=\"thrv_wrapper tve-toc-number tve-toc-number0 tve_no_icons tve-jump-scroll\" data-css=\"tve-u-17aca241303\" data-element-name=\"Number Level 1\" data-level=\"0\" data-target=\"#t-1626888826275\" jump-animation=\"smooth\"><span class=\"tve-toc-disabled\">16<\/span><\/div>\n<p><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1626888826275\" jump-animation=\"smooth\">Tell me at least 5 Cypress commands?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level0 tve_no_icons\" data-css=\"tve-u-17aca241302\" data-element-name=\"Heading Level 1\" data-tag=\"H3\">\n<div class=\"thrv_wrapper tve-toc-number tve-toc-number0 tve_no_icons tve-jump-scroll\" data-css=\"tve-u-17aca241303\" data-element-name=\"Number Level 1\" data-level=\"0\" data-target=\"#t-1626888826276\" jump-animation=\"smooth\"><span class=\"tve-toc-disabled\">17<\/span><\/div>\n<p><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1626888826276\" jump-animation=\"smooth\">How can I click on the button in Cypress?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level0 tve_no_icons\" data-css=\"tve-u-17aca241302\" data-element-name=\"Heading Level 1\" data-tag=\"H3\">\n<div class=\"thrv_wrapper tve-toc-number tve-toc-number0 tve_no_icons tve-jump-scroll\" data-css=\"tve-u-17aca241303\" data-element-name=\"Number Level 1\" data-level=\"0\" data-target=\"#t-1626888826277\" jump-animation=\"smooth\"><span class=\"tve-toc-disabled\">18<\/span><\/div>\n<p><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1626888826277\" jump-animation=\"smooth\">List out some commands which I can use to interact with DOM elements?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level0 tve_no_icons\" data-css=\"tve-u-17aca241302\" data-element-name=\"Heading Level 1\" data-tag=\"H3\">\n<div class=\"thrv_wrapper tve-toc-number tve-toc-number0 tve_no_icons tve-jump-scroll\" data-css=\"tve-u-17aca241303\" data-element-name=\"Number Level 1\" data-level=\"0\" data-target=\"#t-1626888826278\" jump-animation=\"smooth\"><span class=\"tve-toc-disabled\">19<\/span><\/div>\n<p><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1626888826278\" jump-animation=\"smooth\">Consider a scenario, I have link on webpage and clicking this link opens new window I need to verify some text in that window. How can I verify?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level0 tve_no_icons\" data-css=\"tve-u-17aca241302\" data-element-name=\"Heading Level 1\" data-tag=\"H3\">\n<div class=\"thrv_wrapper tve-toc-number tve-toc-number0 tve_no_icons tve-jump-scroll\" data-css=\"tve-u-17aca241303\" data-element-name=\"Number Level 1\" data-level=\"0\" data-target=\"#t-1626888826279\" jump-animation=\"smooth\"><span class=\"tve-toc-disabled\">20<\/span><\/div>\n<p><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1626888826279\" jump-animation=\"smooth\">What are the selectors supported by Cypress?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level0 tve_no_icons\" data-css=\"tve-u-17aca241302\" data-element-name=\"Heading Level 1\" data-tag=\"H3\">\n<div class=\"thrv_wrapper tve-toc-number tve-toc-number0 tve_no_icons tve-jump-scroll\" data-css=\"tve-u-17aca241303\" data-element-name=\"Number Level 1\" data-level=\"0\" data-target=\"#t-1626888826280\" jump-animation=\"smooth\"><span class=\"tve-toc-disabled\">21<\/span><\/div>\n<p><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1626888826280\" jump-animation=\"smooth\">Can I use XPath in Cypress?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level0 tve_no_icons\" data-css=\"tve-u-17aca241302\" data-element-name=\"Heading Level 1\" data-tag=\"H3\">\n<div class=\"thrv_wrapper tve-toc-number tve-toc-number0 tve_no_icons tve-jump-scroll\" data-css=\"tve-u-17aca241303\" data-element-name=\"Number Level 1\" data-level=\"0\" data-target=\"#t-1626888826281\" jump-animation=\"smooth\"><span class=\"tve-toc-disabled\">22<\/span><\/div>\n<p><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1626888826281\" jump-animation=\"smooth\">What is environment variable in Cypress?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level0 tve_no_icons\" data-css=\"tve-u-17aca241302\" data-element-name=\"Heading Level 1\" data-tag=\"H3\">\n<div class=\"thrv_wrapper tve-toc-number tve-toc-number0 tve_no_icons tve-jump-scroll\" data-css=\"tve-u-17aca241303\" data-element-name=\"Number Level 1\" data-level=\"0\" data-target=\"#t-1626888826282\" jump-animation=\"smooth\"><span class=\"tve-toc-disabled\">23<\/span><\/div>\n<p><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1626888826282\" jump-animation=\"smooth\">How can I change the baseUrl in cypress dynamically?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level0 tve_no_icons\" data-css=\"tve-u-17aca241302\" data-element-name=\"Heading Level 1\" data-tag=\"H3\">\n<div class=\"thrv_wrapper tve-toc-number tve-toc-number0 tve_no_icons tve-jump-scroll\" data-css=\"tve-u-17aca241303\" data-element-name=\"Number Level 1\" data-level=\"0\" data-target=\"#t-1626888826283\" jump-animation=\"smooth\"><span class=\"tve-toc-disabled\">24<\/span><\/div>\n<p><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1626888826283\" jump-animation=\"smooth\">What is Preserve cookies in Cypress? Why do we need that?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level0 tve_no_icons\" data-css=\"tve-u-17aca241302\" data-element-name=\"Heading Level 1\" data-tag=\"H3\">\n<div class=\"thrv_wrapper tve-toc-number tve-toc-number0 tve_no_icons tve-jump-scroll\" data-css=\"tve-u-17aca241303\" data-element-name=\"Number Level 1\" data-level=\"0\" data-target=\"#t-1626888826284\" jump-animation=\"smooth\"><span class=\"tve-toc-disabled\">25<\/span><\/div>\n<p><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1626888826284\" jump-animation=\"smooth\">What is custom commands in Cypress?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level0 tve_no_icons\" data-css=\"tve-u-17aca241302\" data-element-name=\"Heading Level 1\" data-tag=\"H3\">\n<div class=\"thrv_wrapper tve-toc-number tve-toc-number0 tve_no_icons tve-jump-scroll\" data-css=\"tve-u-17aca241303\" data-element-name=\"Number Level 1\" data-level=\"0\" data-target=\"#t-1707804713029\" jump-animation=\"smooth\"><span class=\"tve-toc-disabled\">26<\/span><\/div>\n<p><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1707804713029\" jump-animation=\"smooth\">How can I type Keypress in Cypress?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level0 tve_no_icons\" data-css=\"tve-u-17aca241302\" data-element-name=\"Heading Level 1\" data-tag=\"H3\">\n<div class=\"thrv_wrapper tve-toc-number tve-toc-number0 tve_no_icons tve-jump-scroll\" data-css=\"tve-u-17aca241303\" data-element-name=\"Number Level 1\" data-level=\"0\" data-target=\"#t-1707804713030\" jump-animation=\"smooth\"><span class=\"tve-toc-disabled\">27<\/span><\/div>\n<p><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1707804713030\" jump-animation=\"smooth\"> How can I read the value from Cypress Configuration file?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level0 tve_no_icons\" data-css=\"tve-u-17aca241302\" data-element-name=\"Heading Level 1\" data-tag=\"H3\">\n<div class=\"thrv_wrapper tve-toc-number tve-toc-number0 tve_no_icons tve-jump-scroll\" data-css=\"tve-u-17aca241303\" data-element-name=\"Number Level 1\" data-level=\"0\" data-target=\"#t-1707804713031\" jump-animation=\"smooth\"><span class=\"tve-toc-disabled\">28<\/span><\/div>\n<p><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1707804713031\" jump-animation=\"smooth\">How to get the title of the page?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level0 tve_no_icons\" data-css=\"tve-u-17aca241302\" data-element-name=\"Heading Level 1\" data-tag=\"H3\">\n<div class=\"thrv_wrapper tve-toc-number tve-toc-number0 tve_no_icons tve-jump-scroll\" data-css=\"tve-u-17aca241303\" data-element-name=\"Number Level 1\" data-level=\"0\" data-target=\"#t-1707804713032\" jump-animation=\"smooth\"><span class=\"tve-toc-disabled\">29<\/span><\/div>\n<p><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1707804713032\" jump-animation=\"smooth\">How can I use the sleep in Cypress?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level0 tve_no_icons\" data-css=\"tve-u-17aca241302\" data-element-name=\"Heading Level 1\" data-tag=\"H3\">\n<div class=\"thrv_wrapper tve-toc-number tve-toc-number0 tve_no_icons tve-jump-scroll\" data-css=\"tve-u-17aca241303\" data-element-name=\"Number Level 1\" data-level=\"0\" data-target=\"#t-1707804713033\" jump-animation=\"smooth\"><span class=\"tve-toc-disabled\">30<\/span><\/div>\n<p><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1707804713033\" jump-animation=\"smooth\">How can I get the first and last child of the selected element?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level0 tve_no_icons\" data-css=\"tve-u-17aca241302\" data-element-name=\"Heading Level 1\" data-tag=\"H3\">\n<div class=\"thrv_wrapper tve-toc-number tve-toc-number0 tve_no_icons tve-jump-scroll\" data-css=\"tve-u-17aca241303\" data-element-name=\"Number Level 1\" data-level=\"0\" data-target=\"#t-1707804713034\" jump-animation=\"smooth\"><span class=\"tve-toc-disabled\">31<\/span><\/div>\n<p><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1707804713034\" jump-animation=\"smooth\">What is shadow Dom? How can I access shadow DOM in cypress?<\/a><\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv-divider tve-vert-divider\" data-color-d=\"rgba(0, 0, 0, 0.08)\" data-css=\"tve-u-17aca2412fb\" 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-1626888826259\"><a class=\"\" name=\"_Toc76233657\" style=\"outline: none;\">What is Cypress?<\/a><\/h3>\n<p>Cypress is a next-generation testing tool constructed for the modern web. This tool addresses the critical problems which we face every day like synchronization issues, flaky tests, element loading issues, issues with dynamic elements etc.<\/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<h3 class=\"\" id=\"t-1626888826260\"><a class=\"\" name=\"_Toc76233658\" style=\"outline: none;\">How Cypress architecture is different from selenium?<\/a><\/h3>\n<p>Selenium relies on WebDriver to execute the commands that means selenium executes remote command across the network. But in the cypress, it directly operates inside the browser. So the browser executes the commands which we run as script.<\/p>\n<p><strong>Explanation: <\/strong>Real world scenario,<\/p>\n<p><strong>Consider Selenium,<\/strong><\/p>\n<p>If I have <strong>element.click()<\/strong> in my test script, Once I execute this script selenium sends this code to browser specific drivers like ChromeDriver, Ghecko Driver etc. The browser specific drivers then interact with specific browsers like Chrome, Firefox etc. and executes the click action.<\/p>\n<p><strong>Consider Cypress,<\/strong><\/p>\n<p>The \u00a0same command <strong>element.click()<\/strong> Considering Cypress.<\/p>\n<p>Once you execute code in Cypress, The cypress directly sends the code to browser and click action gets executed.<\/p>\n<p>So with the above example we can understand that the middle layer that is <strong>webdriver<\/strong> which is present in the selenium but Cypress doesn\u2019t need any middle layer.<\/p>\n<h3 class=\"\" id=\"t-1626888826261\"><a class=\"\" name=\"_Toc76233659\" style=\"outline: none;\">Can I use Cypress framework with C# or Java just like Selenium?<\/a><\/h3>\n<p>No, Cypress is NodeJS based framework. Cypress supports only JavaScript and Typescript as a programming language.<\/p>\n<h3 class=\"\" id=\"t-1626888826262\"><a class=\"\" name=\"_Toc76233660\" style=\"outline: none;\">Could you tell me about some differences between Cypress and Selenium?<\/a><\/h3>\n<ul class=\"\">\n<li>Selenium supports all major languages like C#, Java, Python, JavaScript, Ruby etc.<\/li>\n<li>Cypress Supports only JavaScript\/Typescript languages<\/li>\n<li>Selenium Commands are executed through web drivers<\/li>\n<li>Cypress Commands Executed directly on the browser<\/li>\n<li>\u00a0Selenium Supports all major browsers chrome,Edge, Internet Explorer, Safari, Firefox<\/li>\n<li>Cypress supports only Chrome, Edge and Firefox<\/li>\n<li>With Selenium Configuration of drivers and language biding should be done by our own<\/li>\n<li>With Cypress we get ready framework available we just need to install.<\/li>\n<li>Selenium Appium can we used to test native mobile applications<\/li>\n<li>Cypress doesn\u2019t support any native mobile application testing<\/li>\n<\/ul>\n<h3 class=\"\" id=\"t-1626888826264\"><a class=\"\" name=\"_Toc76233662\" style=\"outline: none;\">What are the advantages of Cypress?<\/a><\/h3>\n<ul class=\"\">\n<li>Cypress is NodeJS modern framework so it works seamlessly with Single Page applications and internal Ajax calls.<\/li>\n<li>Cypress provides Time Travel options, so It takes snapshots of each tests, after execution we can see what happened exactly in each step. We don\u2019t have to do any configuration for this this comes by default with cypress.<\/li>\n<li>Cypress Debuggability feature provides access to developer tools on the browser so we can debug directly in the browser.<\/li>\n<li>Cypress Automatically waits for commands and assertions or any animation to complete so most of the time we don\u2019t have to put additional sleep in our tests.<\/li>\n<li>Since Cypress directly executes commands on browser it is quite faster compared to Selenium based tools.<\/li>\n<li>Cypress runs tests and executes commands directly on browser so it is less flaky.<\/li>\n<li>Cypress provides Video Capture option we can record whole set of tests execution.<\/li>\n<\/ul>\n<h3 class=\"\" id=\"t-1626888826265\"><a class=\"\" name=\"_Toc76233663\" style=\"outline: none;\">Can I use Junit or TestNG in cypress?<\/a><\/h3>\n<p><strong>\u00a0 \u00a0 Or<\/strong><\/p>\n<p><strong>\u00a0 \u00a0 What is Testing Framework Cypress comes with?<\/strong><\/p>\n<p>We cannot use the Junit or TestNG in Cypress, Cypress comes with Mocha and Chai assertion libraries.<\/p>\n<h3 class=\"\" id=\"t-1626888826266\"><a class=\"\" name=\"_Toc76233664\" style=\"outline: none;\">How can I install cypress?<\/a><\/h3>\n<p>If you want to install cypress, we need to install Node first, once we install node we can install cypress with command \u00a0<strong>npm install cypress<\/strong><\/p>\n<h3 class=\"\" id=\"t-1626888826267\"><a class=\"\" name=\"_Toc76233665\" style=\"outline: none;\">How can I open cypress window and execute tests?<\/a><\/h3>\n<p>Once you install the cypress, we can open cypress using <strong>npm cypress open<\/strong> command and execute the tests by clicking on test file name.<\/p>\n<p><strong><em>Note:<\/em><\/strong> First time when we execute npm cypress open command, cypress prepares the framework ready for you. This involves creating folder structure such as cypress, support, plugin, integration etc. This happens only when we execute npm cypress open command for the first time, subsequent execution of this command only launches the cypress window since set up is done already.<\/p>\n<h3 class=\"\" id=\"t-1626888826268\"><a class=\"\" name=\"_Toc76233666\" style=\"outline: none;\">Could you talk something about Cypress file and folder structures?<\/a><\/h3>\n<ol class=\"\">\n<li>Cypress uses <strong>cypress.json<\/strong> file, if we want to specify any <strong>custom configuration<\/strong> which is located in the root of our project.<\/li>\n<li>The <strong>folder<\/strong> named <strong>cypress<\/strong> is located in the project root folder which is main folder for cypress automation framework.<\/li>\n<li><strong>By default Cypress folder contains 4 subfolders<\/strong> namely <strong>fixtures<\/strong>, <strong>integration<\/strong>, <strong>plugins<\/strong> and <strong>support<\/strong>.<\/li>\n<li><strong>Fixtures<\/strong> folder can be used to store our external Json data files and we can use these files in our tests using the command cy.fixture().<\/li>\n<li><strong>Integration<\/strong> folder mainly consists of our actual spec\/test files<\/li>\n<li><strong>Plugins<\/strong> folder contains special files that executes in Node before project is loaded, before the browser launches, and during your test execution. This is very\u00a0 helpful when we want to have pre processers and post processors. Files in this folder can be executed after all the test execution is complete as well.<\/li>\n<li>Example: Let us consider, If we want to generate HTML result after all the test is completed. The HTML report generation or collating those HTML reports can be done here in this file.<\/li>\n<li><strong>Support<\/strong> folder contains the special file index.js which will be run before each and every test. Support folder can also be used to create utility methods which will be helpful in through out our automation framework. This file is the perfect place to put all your reusable behavior such as Custom commands or global overrides that you want to be applied to all of your spec files.<\/li>\n<\/ol>\n<h3 class=\"\" id=\"t-1626888826269\"><a class=\"\" name=\"_Toc76233667\" style=\"outline: none;\">What is Cypress CLI?<\/a><\/h3>\n<p>Cypress CLI is unique feature in cypress it provides ability to run our cypress tests in command line. This feature is helpful when we run our cypress tests in pipelines. It provides many options and flags control the cypress test behavior.<\/p>\n<p><strong>Example:<\/strong> use <strong>npm cypress run<\/strong> to run your tests in command line.<\/p>\n<h3 class=\"\" id=\"t-1626888826270\"><a class=\"\" name=\"_Toc76233668\" style=\"outline: none;\">How can I run single specfile in command line?<\/a><\/h3>\n<p>We can run single spec file in command line using <strong>&#8211; &#8211; spec<\/strong> option and specifying test name.<\/p>\n<p>Example: \u00a0<strong>npm cypress run &#8211; &#8211; spec=\u201dmyspec.ts\u201d<\/strong><\/p>\n<h3 class=\"\" id=\"t-1626888826271\"><a class=\"\" name=\"_Toc76233669\" style=\"outline: none;\">I am new to cypress, I wanted to execute hello world test script in cypress how can I do that could you explain?<\/a><\/h3>\n<p>Once you have installed cypress it will create folder called integration, inside integration folder you can create your first spec file using typescript or JavaScript.<\/p>\n<p>Your spec file should contain <em><strong>describe()<\/strong><\/em> block and or <em><strong>it()<\/strong><\/em> block. Use the cypress command inside this block and execute the test.<\/p>\n<h3 class=\"\" id=\"t-1626888826272\"><a class=\"\" name=\"_Toc76233670\" style=\"outline: none;\">Why should I create my tests inside integration folder, why can\u2019t I create test in other folders?<\/a><\/h3>\n<p>The default tests folder is integration in cypress, so when we execute the tests it will look for integration folder get all the test file.<\/p>\n<p>But you can create the tests in other folder in that case you need to change the configuration and specify where your integration folder is located using option called \u201c<em><strong>integrationFolder<\/strong><\/em>\u201d<\/p>\n<h3 class=\"\" id=\"t-1626888826273\"><a class=\"\" name=\"_Toc76233671\" style=\"outline: none;\">How can see the default configuration in Cypress?<\/a><\/h3>\n<p>You can see the default configuration in Cypress Under on Cypress window \u00a0Test Runner &gt; Settings and Configurations.<\/p>\n<h3 class=\"\" id=\"t-1626888826274\"><a class=\"\" name=\"_Toc76233672\" style=\"outline: none;\">How can I create suites in cypress?<\/a><\/h3>\n<p>We can create a describe() block the describe block acts as suite, inside that each test can be created as single <em><strong>it()<\/strong><\/em> block.<\/p>\n<p><em><strong>Describe()<\/strong><\/em> is like a suite here.<\/p>\n<h3 class=\"\" id=\"t-1626888826275\"><a class=\"\" name=\"_Toc76233673\" style=\"outline: none;\">Tell me at least 5 Cypress commands?<\/a><\/h3>\n<p><strong>cy.visit():<\/strong> cy.visit() is used to navigate to the specific website<br \/>Ex: cy.visit(\u2018http:\/\/www.google.com\u2019);<\/p>\n<p><strong>cy.log():<\/strong> cy.log is used for display cypress console logs during execution<br \/>Ex: cy.log(\u2018test 123\u2019);<\/p>\n<p><strong>cy.get():<\/strong> cy.get is used for getting dom element in cypress, once we get dom element we can perform action on that like click, type etc.<br \/>Example: let myElement = cy.get(\u2018#username\u2019)<\/p>\n<p><strong>cy.url():<\/strong> cy.url() is used to Get the current URL of the page that is currently active.<br \/><em><strong>Example:<\/strong><\/em> Consider you have navigate to https:\/\/google.com using cy.visit();, now you can use the cy.url() to get the url back.<\/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-17aca345354\" style=\"\">\n<p data-css=\"tve-u-17aca34cf7b\" style=\"\">\/\/ Example Cypress Code:<\/p>\n<p data-css=\"tve-u-17aca34cf7d\" style=\"\">cy.visit(&#8216;https:\/\/www.google.com&#8217;); \/\/Visit the webpage<\/p>\n<p data-css=\"tve-u-17aca34cf7f\" style=\"\">let myurl= cy.url(); \/\/Get webpage url<\/p>\n<p data-css=\"tve-u-17aca34cf80\" style=\"\">cy.url().should(&#8216;include&#8217;, &#8216;google&#8217;); \/\/Assert URL<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1626888826276\"><a class=\"\" name=\"_Toc76233674\" style=\"outline: none;\">How can I click on the button in Cypress?<\/a><\/h3>\n<p><strong>.click()<\/strong> function is used to click the element on cypress. The click function should be chained with element. I.e we need to get the desired element first and we need to click.<\/p>\n<p><strong>Example:<\/strong> If we want to click on Google Search button, First we need to get the element of search using selectors 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-17aca35bfb8\" style=\"\">\n<p data-css=\"tve-u-17aca35f58a\" style=\"\">cy.get(&#8216;#search&#8217;).click()<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1626888826277\"><a class=\"\" name=\"_Toc76233675\" style=\"outline: none;\">List out some commands which I can use to interact with DOM elements?<\/a><\/h3>\n<p><strong> .click() :<\/strong> is used to click on the element<\/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-17aca379a3f\" style=\"\">\n<p data-css=\"tve-u-17aca37fa6a\" style=\"\">cy.get(&#8216;#search&#8217;).click()<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p><strong>.dblclick() : is used to double click on the element.<\/strong><\/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-17aca38d6d4\" style=\"\">\n<p data-css=\"tve-u-17aca391e57\" style=\"\">cy.get(&#8216;input[name=&#8221;btnK&#8221;]&#8217;).dblclick();<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p><strong>.rightclick(): is used to right click on the element<\/p>\n<p>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-17aca3a25db\" style=\"\">\n<p data-css=\"tve-u-17aca3a6cbf\" style=\"\">cy.get(&#8216;body&#8217;).rightclick();<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p><strong>.type()<\/strong> : is used to type on element or text boxes<\/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-17aca3afa1d\" style=\"\">\n<p data-css=\"tve-u-17aca3b870c\" style=\"\">cy.get(&#8216;input[name=&#8221;texbox&#8221;]&#8217;).type(&#8220;This is to test&#8221;);<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p><strong>.clear()<\/strong> : is used to clear the fields or text boxes.<\/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-17aca3c2b64\" style=\"\">\n<p data-css=\"tve-u-17aca3c8107\" style=\"\">cy.get(&#8216;input[name=&#8221;q&#8221;]&#8217;).clear();<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p><strong>.check() :<\/strong> is used to Check checkbox(es) or radio(s).<\/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-17aca3e0918\" style=\"\">\n<p data-css=\"tve-u-17aca3e5041\" style=\"\">cy.get(&#8216;input[name=&#8221;chkbox&#8221;]&#8217;).check();<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p><strong>.uncheck() :<\/strong> is used to unCheck checkbox(es) or radio(s).<\/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-17aca3ece2b\" style=\"\">\n<p data-css=\"tve-u-17aca3f0a53\" style=\"\">cy.get(&#8216;input[name=&#8221;chkbox&#8221;]&#8217;).uncheck();<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p><strong>.select()<\/strong>: Select an &lt;option&gt; within a &lt;select&gt;<\/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-17aca3f8afd\" style=\"\">\n<p data-css=\"tve-u-17aca3fcbcb\" style=\"\">cy.get(&#8216;select&#8217;).select(&#8216;user-1&#8217;)<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1626888826278\"><a class=\"\" name=\"_Toc76233676\" style=\"outline: none;\">Consider a scenario, I have link on webpage and clicking this link opens new window I need to verify some text in that window. How can I verify?<\/a><\/h3>\n<p>Cypress by default doesn\u2019t support, working with new windows so we need to follow different approach here.<\/p>\n<p><span style=\"text-decoration: underline;\">Let\u2019s consider example:<\/span><\/p>\n<p><em><strong>&lt;a href=&#8221;http:\/\/google.com&#8221; target=&#8221;_blank&#8221;&gt; Take me to Google &lt;\/a&gt;<\/strong><\/em><\/p>\n<p>In the above code clicking on Take me to Google link opens the new window the reason is we have attribute <strong>target=&#8221;_blank&#8221;.<\/strong> So now if we remove attribute. <strong>target=&#8221;_blank&#8221;<\/strong> then it will open in the same window. That can be performed by below 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-17aca40ee45\" style=\"\">\n<p data-css=\"tve-u-17aca4125a5\" style=\"\">\/\/ We can remove the offending attribute &#8211; target=&#8217;_blank&#8217;<\/p>\n<p data-css=\"tve-u-17aca4125a7\" style=\"\">\/\/ that would normally open content in a new tab.<\/p>\n<p data-css=\"tve-u-17aca4125a9\" style=\"\">cy.get(&#8216;a[href*=&#8221;google&#8221;]&#8217;).invoke(&#8216;removeAttr&#8217;, &#8216;target&#8217;).click()<\/p>\n<p data-css=\"tve-u-17aca4125aa\" style=\"\">\/\/ after clicking the &lt;a&gt; we are now navigated to the new page and we can assert that the url is correct<\/p>\n<p data-css=\"tve-u-17aca4125ab\" style=\"\">cy.url().should(&#8216;include&#8217;, &#8216;google&#8217;)<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1626888826279\"><a class=\"\" name=\"_Toc76233677\" style=\"outline: none;\">What are the selectors supported by Cypress?<\/a><\/h3>\n<p>By Default cypress supports only CSS selectors, However we can use third party plugin to use Xpath selectors.<\/p>\n<h3 class=\"\" id=\"t-1626888826280\"><a class=\"\" name=\"_Toc76233678\" style=\"outline: none;\">Can I use XPath in Cypress?<\/a><\/h3>\n<p>Cypress doesn\u2019t support xpath by default, but if we install third party plugin like <strong>cypress-xpath <\/strong>we can use xpath in your script.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<p>We need to install <strong>cypress-xpath <\/strong>in our project first using<\/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-17aca41e4cc\" style=\"\">\n<p data-css=\"tve-u-17aca423433\" style=\"\">\u00a0npm install cypress-xpath<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p>Once we have installed the above plugin, we need to add entry into project&#8217;s cypress\/support\/index.js<\/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-17aca427e31\" style=\"\">\n<p data-css=\"tve-u-17aca42b747\" style=\"\">require(&#8216;cypress-xpath&#8217;)<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p>After that we can use the xpath in out script 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-17aca43067f\" style=\"\">\n<p data-css=\"tve-u-17aca433a4e\" style=\"\">\u00a0cy.xpath(&#8216;\/\/ul[@class=&#8221;todo-list&#8221;]\/\/li&#8217;)<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1626888826281\"><a class=\"\" name=\"_Toc76233679\" style=\"outline: none;\">What is environment variable in Cypress?<\/a><\/h3>\n<p>The Environment Variables is a variable whose value sets at the level of the operating system, and it sets outside the context of the program or framework<\/p>\n<p>In order to use environment variable we need to define in <em><strong>cypress.json<\/strong><\/em><\/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-17aca43b9dc\" style=\"\">\n<p data-css=\"tve-u-17aca4411a3\" style=\"\">{<\/p>\n<p data-css=\"tve-u-17aca4411a5\" style=\"\">\u00a0 &#8220;env&#8221;: {<\/p>\n<p data-css=\"tve-u-17aca4411a6\" style=\"\">\u00a0\u00a0\u00a0 key: value<\/p>\n<p data-css=\"tve-u-17aca4411a8\" style=\"\">\u00a0 }<\/p>\n<p data-css=\"tve-u-17aca43f97f\" style=\"\">}<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p>Once we define we can access them in our script 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-17aca44638d\" style=\"\">\n<p data-css=\"tve-u-17aca448c69\" style=\"\">cy.visit(Cypress.env(&#8216;key&#8217;));<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p>This environment variable value we can change dynamically using command line arguments<\/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-17aca44c68b\" style=\"\">\n<p data-css=\"tve-u-17aca44f720\" style=\"\">cypress run &#8211;env &#8220;Key&#8221;=&#8221;Value&#8221;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p>Lets consider one example, let me create one evnrinment variable in <strong>cypress.json<\/strong><\/p>\n<p><strong>For example:<\/strong><\/p>\n<p><strong><img alt=\"\" decoding=\"async\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAmgAAABgCAYAAACpI44NAAAP90lEQVR4Ae2dvY4byRVG9RbaFbCzEiDBUOTYoXI7dG5jggXsR1jZ0T6Aok02sB5AkbN5gXktGt9YZ3H3bpPdbDanm+QZYHC7\/qtuHVZ9LJLdL3bt7+7ubpf\/ly9fnvRPPdr\/+1M\/6AcZkAEZkAEZkIHOQJNhvwZf\/Hr19YKCCjQhggWtLMiADMiADMjAeRjoOozwZIH28PCwe3x83H3+\/HnSyZoTeZ6J1K\/6VQZkQAZkQAauhwEEWbeTBFpE2ZcvXyYJM07ehOd64HEunUsZkAEZkAEZOA8DXZgRniTQIs4+fvyoQPv6\/TwhPQ+k+lW\/yoAMyIAM3BoDCLJuFWiKrqcfhdzaC8LxugnIgAzIgAxsgYEuzAgr0BRoCjQZkAEZkAEZkIGVGECQdTtJoOXHAff3937EudLkbUHh2wffacqADMiADMjA8gx0YUb4oEDjl5t88f8Y6yQuP4n6VJ\/KgAzIgAzIwHUxgCDr9qBAQ5B5gnZdMPjidj5lQAZkQAZkYBsMdGFGeJJA81ec25hEX0zOgwzIgAzIgAxcFwMIsm4VaH6vzC+GyoAMyIAMyIAMrMRAF2aEFWgrTYjvgK7rHZDz6XzKgAzIgAzMYQBB1q0CTYHmuyYZkAEZkAEZkIGVGOjCjPAkgfbp0ycf9bTSxM1R45bxXZwMyIAMyIAMXAYDCLJuJwm0\/JqTW274sPTLmHBfmM6TDMiADMiADGyfgS7MCE8WaNxyY6oViu1D4Rw5RzIgAzIgAzKwLgMIsm7PJtCmCrlbzueLYt0Xhf7X\/zIgAzIgA2sz0IUZYQXay5dHPcJqSUG5NhS278IkAzIgAzIgA+sygCDrVoGmQPOXO\/4ARAZkQAZkQAZWYqALM8IKNAWaL8qVXpS+a133Xav+1\/8yIANbYABB1q0CbSGBdn9\/v8szS495bukWwLAPLlAyIAMyIAMysB4DXZgRPqtA+\/Dhw5Ngya056vWS3+Maqyu3B8l\/8tXrsXLHpkeYffz48ajvs\/mCWO8Foe\/1vQzIgAzIwBYYQJB1e1aBFpET4ZIb3fbrYwXQ3Px50Hv+U75ez61vqBzicyjtUNwWwLAPLlAyIAMyIAMysB4DXZgRflaBlhMsxNoh4bJkWhVlOclDrC3ZhgJtPbBdVPS9DMiADMjAJTOAIOv27AJtTAjlY0G+u9U\/Joyg4p88CVNnPZ0jjvoIT7GUmSseFWguDpe8ONh3+ZUBGZCB9RjowozwqgINYYSI4ov2sYmLGIsIQ5QhhEiPoOL7ZdSRE7JjhRb9OLYcbaZ87wdph6wviPVeEPpe38uADMiADGyBAQRZt6sKtCExVeMizPpHkvWUrQs2wrGHhNFSaQhKBOSx9W4BDPvgAiUDMiADMiAD6zHQhRnhVQVaTp346LJaBM+YQIsgSh5OvmK7oDtWNM3J7wnaemC7qOh7GZABGZCBS2YAQdbtqgKtnpYNCaMpAi2nWHy8GMvHn0P1nSuOk7tj679koOy7C6IMyIAMyIAMnM5AF2aEVxVoOfHKydk+YTNFoKVshNncU6yUP\/U7aAq00wH1Ra4PZUAGZEAGbpEBBFm3qwq0iCNEWv2Ik1OwqQKNOmL3ib1D8Qo0F4VbXBQcs9zLgAzIwPoMdGFGeHWBdkg4XUqaJ2jrA+4i4xzIgAzIgAxcIgMIsm4VaAs9i5OPWY8RlZcIkn12AZQBGZABGZCB5RjowoywAm0hgcYtN\/JRLR\/Rjok1AV8OcH2pL2VABmRABi6RAQRZtwq0hQTamBgbSr9EkOyzC6AMyIAMyIAMLMdAF2aEFWgrCrQh0Wbcy1k\/9NBv8\/zmIrvcIqsv9aUMyMAcBhBk3SrQFGgKohtmYM5iYhk3IRmQARlYjoEuzAgr0G54c\/bUad6p0zX5zUV2uUVWX+pLGZCBOQwgyLpVoCnQPEG7YQbmLCaWcROSARmQgeUY6MKMsALthjfnazoJcizzTgNdZJdbZPWlvpQBGZjDAIKs26sWaDwhYOubd27NwUPeuV3H3Kci7Btr7tN26LFalKN9wulXnuhA+Fg79DSIY+qgPzxpYuotTA61se+edTyRYl9b3JCYuTrUxqG0+KT6NPXR5qG6uy9ghH7jG+o71AfS5iwmlnETkgEZkIHlGOjCjPDmBRqbUjZHNpWp9hIEWjbm9DNjOmWsYz65VIHGuBBHiBDi59ghgTbF9\/ThkIia0p8u0CgzJmYrK5SJRaAh2BBoU3zlIrvcIqsv9aUMyMAcBhBk3SrQVvyIEwGJ+MwGG\/FQN9\/nvkao0G42+3raQ\/xUOyY6ptaDOJoiOsbqHBJo8f2pwmusXdLnCLQ+L9SFreKNvFN8NWcxsYybkAzIgAwsx0AXZoQ3K9DYZPjop1pOnLI5IXJIr2KCNDYxwlUEsfHvK89mTnotS730tbZN2iFLfygXm3YSn3L0rW60QyKOExP6WNukzqQN9T15a55eRxdotMVpzVB5xkNaFT60VfOkLtqNrfkZy5AvSMOP1NHHyfyQHouPqWOfQBsqW\/ue8vSt1p846o6tabnudSRP4obGnjT6UevkmjTaHGKEvN26yC63yOpLfSkDMjCHAQRZt5sVaGwkffMhPpaNmY0pcdn8EA+k17ypjzrYWGvcUPm64eea+qmHPg5tuuQZsrRPOepBPJBe+9c332zolE8bua79pd1ejvjkr6KAPpBe6891r7v6mDLV1vpzHf\/WdNqrc1jTuR7yRdL2xVNuqP6MAR\/nOn3q\/9Un1BWbMeS\/xqWOzkRNT920t68O4nu7+Kz3L2HK5Br\/pS\/5r+0fup6zmFjGTUgGZEAGlmOgCzPCFy3QhjbGbIRsUIgHbBU62bSyqfYNscZRrm5wyd836Jq+5PWQ+KhCi3Q257Q9FJf4Wq72MZt79QuChjyMNxa\/khaLj2odNT2+og5ERU2nvdRT4\/s14+rtEJ\/x9TIJp\/0+XxlHb6\/O+1A9xO2rL2MkT7Vpp\/ttqI6USfy+evBTrXuJaxfZ5RZZfakvZUAG5jCAIOv24gVa32gTRghwnfDQxpcNMWn9nw2V8nUjRGzUuHNdIz6qKKlCi0279z\/hWib9q+XoL\/XHEkedhDNe6u++Jg9+Il+tr\/p4n4iiTcr3vqcd+noojfK1n+l\/b3dpgZb+pU7az5jxTdru7CW95iFv4npe0vAR4aXsnMXEMm5CMiADMrAcA12YEb54gdY334SHBFbi+uY3tHnWjQ\/hUeNSx9DmWvMsdT0kSur4SK+CaF\/btRx5hsp3IcB4ia\/ih3qqTTsRKsQhOmgr6aQNWXzex0T5IYFW66Gf5Ev\/e5vnEGi1Dxk\/bcZ27uKTIYbwVa2La8ZFeCnrIrvcIqsv9aUMyMAcBhBk3W5eoLExDwmDbH5VDGTTSpi8bPZsZkmrmyWbHps5+bC9fOIRLOSJpZ6hTbfmm3NdN3v6gwBNfbme0m58VcvRl8QhJhhH9WkdL+3HUr5b6iC+ig7SaI881TLfcwVa6kr\/01au+7gz3qT3MSRfZaP2qV5nPGP+Tj2MkTEznpRN+0N1JG5fH6in9mWJ6zmLiWXchGRABmRgOQa6MCO8eYGWTQhhkI2tb67ZCInvaZRjI2PzTz7i2PhqHWyuvXzKVMHS6xjadMkz19KH9C\/iIuEutBAdjKGm9zTy0J\/qk6QRJr2PF38z1ljqxCJGUkcXHYwHIUJ9lI1FXKX8UHrypJ6kU18tT1odA+lJS9s9T9qhT5QbshkPY086\/qL+2JqePHUMSUu45qllua5zmDrgdKhPp8S5yC63yOpLfSkDMjCHAQRZtxch0E7ZgCw77xFA+m3Yb12wXrqf5iwmlnETkgEZkIHlGOjCjLACbcUb1Y5t7o\/v3+\/++OrV00nRP16\/3iUcm3KGn8cf\/\/3hh9\/4+\/HHH59Os87p\/zfffLP795s3R833GEv70l1kl1tk9aW+lAEZmMMAgqxbBdqGBdo\/X7\/e\/fz27e7P3333tFn\/\/e5O+\/797rn98PjTT09+x56r\/b\/e3e3+8+7d7pe3b3e\/vHu3+8vIvJP\/b3d3TyJynwg7FD9nMbGMm5AMyIAMLMdAF2aEFWgbFmjZWP915EnKOU920h\/rP+\/J3Z9evXoSg3\/49tvfnNzF70P+T\/77779XoN0tt1i68ehLGZCB52QAQdbtZgXaczrHtnwxyoAMyIAMyIAMrMFAF2aEFWi+896tAaRtuhDKgAzIgAzIwB167HdWgaZAU6DJgAzIgAzIgAysxMDvlNnXCAXaShPiuwbfOcqADMiADMiADKwi0Li5Zm6+WW8+euhXZaQJrdDKgAzIgAzIgAxcOwOrCDTEFnd7JzzFXvuEOD4XHRmQARmQARmQgVUFWgRZTtHqI4DGRJrQCq0MyIAMyIAMyMC1M6BA87tmfgFUBmRABmRABmRgYwwo0DY2Idf+jsDx+a5XBmRABmRABsYZWF2gPTw87PJdtLGPNkl3UscnVR\/pIxmQARmQARm4bAZWF2gRXp8\/f376LtqUX3QK3GUD5\/w5fzIgAzIgAzIwzsDqAs0TtPFJEmR9JAMyIAMyIAO3xcDqAs1fcd4WcC4wzrcMyIAMyIAMjDOgQPNHAv5yRwZkQAZkQAZkYGMMKNA2NiG+qxh\/V6GP9JEMyIAMyMC1M6BAU6D5rkkGZEAGZEAGZGBjDKwq0HJ7jfxIgFtoTLHXrpgdn+8KZUAGZEAGZEAGVhFoPixd8Fx8ZEAGZEAGZEAG9jOwikCbclK2L4+TuX8y9Y2+kQEZkAEZkIHrYODZBZrgXAc4zqPzKAMyIAMyIAPnY0CBtrEvBQr7+WDXt\/pWBmRABmTgUhhQoCnQ\/OWODMiADMiADMjAxhhQoG1sQi5F2dtP34XKgAzIgAzIwPkYmCXQcnuMPKLp2Mc05Yv\/Tub5JlPf6lsZkAEZkAEZuA4GZgk0fmH56dMn72PmCZyiWwZkQAZkQAZkYGEGThJoHz58eDpFQ7BNsSr761D2zqPzKAMyIAMyIAPnY0CBtrDiFdbzwapv9a0MyIAMyMCtMKBAU6B5LC0DMiADMiADMrAxBk4SaPlIMz8UyKObpny8mTy3onwdp+\/yZEAGZEAGZEAG5jJwskCL6Pry5cvkX3TO7ajlhFwGZEAGZEAGZOBWGDhZoHmC5ovlVl4sjlPWZUAGZEAGnouBkwSav+IU1OcC1XZkTQZkQAZk4JYYUKBt7EuBtwSfY3WxlQEZkAEZkIFhBhRoCjR\/uCEDMiADMiADMrAxBhRoG5sQ30kMv5PQL\/pFBmRABmTglhg4SaDlUU\/5BefUW2x4mw1fXLf04nKs8i4DMiADMjCXgVkCzYelC9xc4CwnOzIgAzIgAzIwzsAsgXbMiVnP66SMT4o+0kcyIAMyIAMycNsMTBZo+zIarwf0gB7QA3pAD+gBPfA8HnjxPM3Yih7QA3pAD+gBPaAH9MBUDyjQpnrKfHpAD+gBPaAH9IAeeCYP\/A+OiKJunlZ8kgAAAABJRU5ErkJggg==\"\/><\/strong><\/p>\n<p>The above value of environment variable can be accessed through<\/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-17aca473927\" style=\"\">\n<p data-css=\"tve-u-17aca4766fa\" style=\"\">let tokenvalue = Cypress.env(\u2018token\u2019);<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p>If I want to change the value dynamically using command line I can do so.<\/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-17aca47a732\" style=\"\">\n<p data-css=\"tve-u-17aca47d9ff\" style=\"\">cypress run &#8211;env &#8220;token&#8221;=&#8221;ieoeeoeieoeie&#8221;;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1626888826282\"><a class=\"\" name=\"_Toc76233680\" style=\"outline: none;\">How can I change the baseUrl in cypress dynamically?<\/a><\/h3>\n<p>When we say executing multiple environment that means we are executing scripts on Staging, QA, production, Usually website remains same only website url changes. That is called baseUrl, we can change baseUrl dynamically by passing baseUrl in command line.<\/p>\n<p>First we need to configure cypres.json with baseUrl option<\/p>\n<p><strong>Code:<\/strong> &lt;cypress.json&gt;<\/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-17aca485cf8\" style=\"\">\n<p data-css=\"tve-u-17aca487e31\" style=\"\">&#8220;baseUrl&#8221;: &#8220;https:\/\/qa.web.com&#8221;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p>Then we can override this base url in command line while running our tests.<\/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-17aca48b697\" style=\"\">\n<p data-css=\"tve-u-17aca48ea30\" style=\"\">npx cypress run &#8211;config baseUrl=&#8221;https:\/\/www.staging-website.com\/&#8221;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p>the above code runs the tests on staging website. Earlier configured qa.web.com will be overridden with command line argument <em><strong>baseUrl <\/strong><\/em>value.<\/p>\n<h3 class=\"\" id=\"t-1626888826283\"><a class=\"\" name=\"_Toc76233681\" style=\"outline: none;\">What is Preserve cookies in Cypress? Why do we need that?<\/a><\/h3>\n<p>Cypress by default clear the cookies after every test. In order to stop clearing cookies we need to use preserve cookies option in cypress<\/p>\n<p><b>Example<\/b><strong>:<\/strong><\/p>\n<p>I have 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-17aca499218\" style=\"\">\n<p data-css=\"tve-u-17aca4a0e2e\" style=\"\">describe(&#8216;my test&#8217;, () =&gt; {<\/p>\n<p data-css=\"tve-u-17aca4a0e30\" style=\"\">it(&#8216;test1&#8217;, () =&gt; {<\/p>\n<p data-css=\"tve-u-17aca4a0e31\" style=\"\">\/\/Some code to test<\/p>\n<p data-css=\"tve-u-17aca4a0e32\" style=\"\">});<\/p>\n<p data-css=\"tve-u-17aca4a0e34\" style=\"\">it(&#8216;test2&#8217;, () =&gt; {<\/p>\n<p data-css=\"tve-u-17aca4a0e35\" style=\"\">\/\/Some code to test<\/p>\n<p data-css=\"tve-u-17aca4a0e36\" style=\"\">});<\/p>\n<p data-css=\"tve-u-17aca4a0e37\" style=\"\">it(&#8216;test3&#8217;, () =&gt; {<\/p>\n<p data-css=\"tve-u-17aca4a0e39\" style=\"\">\/\/Some code to test<\/p>\n<p data-css=\"tve-u-17aca4a0e3a\" style=\"\">});<\/p>\n<p data-css=\"tve-u-17aca4a0e3b\" style=\"\">})<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p>In the above code we have three tests namely test1, test2, test3,<br \/>Lets consider you have logged into your application in test1, after execution of test1 when it moves to test2, it again asks for login because login sessions and cookies are cleared after test1. <\/p>\n<p>This is default bevaior in cypress. We can overcome this problem by adding code in our tests 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-17aca4ae2a6\" style=\"\">\n<p data-css=\"tve-u-17aca4b0d88\" style=\"\">describe(&#8216;my test&#8217;, () =&gt; {<\/p>\n<p data-css=\"tve-u-17aca4b0d8a\" style=\"\">beforeEach(() =&gt; {<\/p>\n<p data-css=\"tve-u-17aca4b0d8c\" style=\"\">Cypress.Cookies.preserveOnce(&#8216;session_id&#8217;, &#8216;remember_token&#8217;)<\/p>\n<p data-css=\"tve-u-17aca4b0d8e\" style=\"\">});<\/p>\n<p data-css=\"tve-u-17aca4b0d8f\" style=\"\">it(&#8216;test1&#8217;, () =&gt; {<\/p>\n<p data-css=\"tve-u-17aca4b0d90\" style=\"\">\/\/Some code to test<\/p>\n<p data-css=\"tve-u-17aca4b0d91\" style=\"\">});<\/p>\n<p data-css=\"tve-u-17aca4b0d93\" style=\"\">it(&#8216;test2&#8217;, () =&gt; {<\/p>\n<p data-css=\"tve-u-17aca4b0d94\" style=\"\">\/\/Some code to test<\/p>\n<p data-css=\"tve-u-17aca4b0d95\" style=\"\">});<\/p>\n<p data-css=\"tve-u-17aca4b0d97\" style=\"\">it(&#8216;test3&#8217;, () =&gt; {<\/p>\n<p data-css=\"tve-u-17aca4b0d98\" style=\"\">\/\/Some code to test<\/p>\n<p data-css=\"tve-u-17aca4b0d99\" style=\"\">});<\/p>\n<p data-css=\"tve-u-17aca4b0d9a\" style=\"\">})<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1626888826284\"><a class=\"\" name=\"_Toc76233682\" style=\"outline: none;\">What is custom commands in Cypress?<\/a><\/h3>\n<p>Cypress comes with default set of commands like <strong>cy.visit<\/strong>, <strong>cy.relaod<\/strong> etc.. like this we can create our custom commands in cypress.<\/p>\n<p>For example: I can create some commands like <strong>cy.login()<\/strong>, which will enter the <strong>username<\/strong> and <strong>password<\/strong> and clicks on <strong>submit<\/strong>.<\/p>\n<p>We can accomplish the custom command with below lines of code<\/p>\n<p>All custom commands are first configured in <strong>cypress\/support\/command.js<\/strong> in this file we need to create a command like<\/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-17aca4bb847\" style=\"\">\n<p data-css=\"tve-u-17aca4bdfdd\" style=\"\">Cypress.Commands.add(&#8220;login&#8221;, (username, password) =&gt; {<\/p>\n<p data-css=\"tve-u-17aca4bdfdf\" style=\"\">\u00a0 \/\/adding a new command named login<\/p>\n<p data-css=\"tve-u-17aca4bdfe1\" style=\"\">\u00a0 cy.get(&#8220;#username&#8221;).type(username);<\/p>\n<p data-css=\"tve-u-17aca4bdfe2\" style=\"\">\u00a0 cy.get(&#8220;#password&#8221;).type(password);<\/p>\n<p data-css=\"tve-u-17aca4bdfe3\" style=\"\">\u00a0 cy.get(&#8220;#login&#8221;).click();<\/p>\n<p data-css=\"tve-u-17aca4bdfe4\" style=\"\">});<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p>Once we add the above command now we can use in our script 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-17aca4c19c6\" style=\"\">\n<p data-css=\"tve-u-17aca4c5ef7\" style=\"\">cy.visit(&#8220;http:\/\/mysite.com\/login.html&#8221;);<\/p>\n<p data-css=\"tve-u-17aca58df0e\" style=\"\">cy.login(&#8216;Myusername&#8217;,&#8217;My Passowrd&#8217;);<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1707804713029\"><a class=\"\" name=\"_Toc76233683\" style=\"outline: none;\">How can I type Keypress in Cypress?<\/a><\/h3>\n<p>Keypress can be done in cypress using <strong>.type()<\/strong> command, If we need to use the keys like <strong>CTRL<\/strong>, <strong>SHIFT<\/strong>, <strong>ALT<\/strong> etc then we need to specify in braces 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-17aca595ee6\" style=\"\">\n<p data-css=\"tve-u-17aca599d17\" style=\"\">cy.get(\u2018login\u2019).type(&#8216;{shift}{alt}hello&#8217;));<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1707804713030\"> <a class=\"\" name=\"_Toc76233684\" style=\"outline: none;\">How can I read the value from Cypress Configuration file?<\/a><\/h3>\n<p>We can read the cypress.config values from cypress using <strong>Cypress.config();<\/strong><\/p>\n<p><strong>Example:<\/strong><\/p>\n<p>If I have defined pageLoadTimeout in config file like blow.<\/p>\n<p>Below code is in <strong>cypress.json<\/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-17aca5a31b0\" style=\"\">\n<p data-css=\"tve-u-17aca5a8444\" style=\"\">{<\/p>\n<p data-css=\"tve-u-17aca5a8446\" style=\"\">\u00a0 &#8220;pageLoadTimeout&#8221;: 60000<\/p>\n<p data-css=\"tve-u-17aca5a6f06\" style=\"\">}<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p>I can access the same in my script like<\/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-17aca5afd24\" style=\"\">\n<p data-css=\"tve-u-17aca5b4b7a\" style=\"\">let timeout = Cypress.config(&#8216;pageLoadTimeout&#8217;)<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1707804713031\"><a class=\"\" name=\"_Toc76233685\" style=\"outline: none;\">How to get the title of the page?<\/a><\/h3>\n<p><strong>cy.title()<\/strong> : cy.title() can be used to get the title of the current active window<\/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-17aca5c53bd\" style=\"\">\n<p data-css=\"tve-u-17aca5cfd10\" style=\"\">cy.visit(&#8216;http:\/\/www.facebook.com&#8217;)<\/p>\n<p data-css=\"tve-u-17aca5cfd18\" style=\"\">cy.title().should(&#8216;eq&#8217;,&#8217;Facebook Login or Signup&#8217;)<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1707804713032\"><a class=\"\" name=\"_Toc76233686\" style=\"outline: none;\">How can I use the sleep in Cypress?<\/a><\/h3>\n<p><strong>cy.wait() <\/strong>: cy.wait is used to wait for specific amount of time.<\/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-17aca5d66f1\" style=\"\">\n<p data-css=\"tve-u-17aca5dbfe2\" style=\"\">cy.wait(1000)<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1707804713033\"><a class=\"\" name=\"_Toc76233687\" style=\"outline: none;\">How can I get the first and last child of the selected element?<\/a><\/h3>\n<p>.first() and .last() is used for getting first and last child of the element<\/p>\n<p>Consider example,<\/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-17aca5e0f0b\" style=\"\">\n<p data-css=\"tve-u-17aca5e0f0d\" style=\"\">cy.get(&#8216;input[name=&#8217;rows&#8217;])<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p>let\u2019s say this selectors returns array of elements say 6 elements.<\/p>\n<p>Then<\/p>\n<p>First child can be obtained using<\/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-17aca5ee6f1\" style=\"\">\n<p data-css=\"tve-u-17aca5f132c\" style=\"\">cy.get(&#8216;input[name=&#8217;rows&#8217;]).first()<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p>Last child can be obtained using<\/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-17aca5f5597\" style=\"\">\n<p data-css=\"tve-u-17aca5f9c0f\" style=\"\">cy.get(&#8216;input[name=&#8217;rows&#8217;]).last()<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" id=\"t-1707804713034\"><a class=\"\" name=\"_Toc76233688\" style=\"outline: none;\">What is shadow Dom? How can I access shadow DOM in cypress?<\/a><\/h3>\n<p>Shadow DOM allows hidden DOM trees to be attached to elements in the regular DOM tree \u2014 this shadow DOM tree starts with a shadow root.<\/p>\n<p><strong>Example: <\/strong>Consider we have shadow dom 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-17aca6014de\" style=\"\">\n<p data-css=\"tve-u-17aca605445\" style=\"\">&lt;div class=&#8221;shadow-host&#8221;&gt;<\/p>\n<p data-css=\"tve-u-17aca605447\" style=\"\">\u00a0 #shadow-root<\/p>\n<p data-css=\"tve-u-17aca605448\" style=\"\">\u00a0 &lt;button class=&#8221;my-button&#8221;&gt;Click me&lt;\/button&gt;<\/p>\n<p data-css=\"tve-u-17aca60544a\" style=\"\">&lt;\/div&gt;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p>We can access the above shadow dom using below code in cypress<\/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-17aca60dc1e\" style=\"\">\n<p data-css=\"tve-u-17aca60fbc4\" style=\"\">cy.get(&#8216;.shadow-host&#8217;).shadow().find(&#8216;.my-button&#8217;).click()<\/p>\n<\/div>\n<\/div>\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 What is Cypress? 2 How Cypress architecture is different from selenium? 3 Can I use Cypress framework with C# or Java just like Selenium? 4 Could you tell me about some differences between Cypress and Selenium? 5 What are the advantages of Cypress? 6 Can I use Junit or TestNG 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-760","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\/760","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=760"}],"version-history":[{"count":0,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/760\/revisions"}],"wp:attachment":[{"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=760"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=760"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=760"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}