Part 17: Cypress E2E Web Automation | How To Create Custom commands

Поділитися
Вставка
  • Опубліковано 15 жов 2024
  • #cypress#automation#e2etesting#customCommands
    Topics:
    -------
    1) Create new custom commands
    2) Overwrite existing commands
    3) How to use custom commands in the test scripts
    #########################
    Udemy Courses:
    #########################
    Manual Testing+Agile with Jira Tool
    **********************************
    ► shorturl.at/xNXZ4
    Selenium with Java+Cucumber
    ********************************
    ► shorturl.at/aIKMW
    Selenium with Python & PyTest
    ********************************
    ► shorturl.at/ELW09
    Selenium with python using Robot framework
    ****************************************
    ► shorturl.at/bcDPZ
    API Testing(Postman, RestAssured & SoapUI)
    *****************************************
    ► shorturl.at/uAWY7
    Web & API Automation using Cypress with Javascript
    ********************************************
    ► rb.gy/4uum2n
    Playwright with Javascript
    **************************
    ► shorturl.at/gALZ1
    Jmeter-Performance Testing
    ************************
    ► rb.gy/ocj7r2
    SDET Essencials(Full Stack QA)
    *************************
    ► rb.gy/hlnf2v
    Appium-Mobile Automation Testing
    ************************************
    ► rb.gy/wmzv64
    Java Collections
    *****************
    ► bit.ly/3S66ezE
    Python Programming
    *********************
    ► urlis.net/gdsf...
    Cucumber BDD Framework
    ***************************
    ► bit.ly/3F7d69r
    Protractor with Javascript
    ***************************
    ► urlis.net/4udd...
    ####################################
    UA-cam Playlists:
    ####################################
    Manual Testing & Agile
    ***********************
    ► bit.ly/3ujvaYa
    ► bit.ly/3OYzxQj
    SQL
    *************************
    ► bit.ly/3R6XjeG
    ► bit.ly/3nE0a1s
    ► bit.ly/3IeKuuJ
    linux & Shell Scripting
    **********************
    ► bit.ly/3up1Z6a
    ► bit.ly/3nzvGxx
    Java
    **********************
    ► bit.ly/3R9QfOs
    ► bit.ly/3AoRMKM
    ► bit.ly/3IbTTDn
    ► bit.ly/3ybXInv
    ► bit.ly/3yCoHdw
    Selenium With Java+Cucumber
    ********************************
    ► bit.ly/3P2FMm4
    ► bit.ly/3yhiIt4
    ► bit.ly/3uokzet
    ► bit.ly/3a7XIND
    ► bit.ly/3umN2S9
    ► bit.ly/3aar7GW
    ► bit.ly/3y9kD2S
    ► bit.ly/3uhLskn
    Python
    ********************************
    ► bit.ly/3agNgU0
    ► bit.ly/3NJNnoy
    ► bit.ly/2CTQ4mR
    ► bit.ly/3OIYWh1
    Selenium With Python,Pytest&Behave
    ***************************************
    ► bit.ly/3OHHoC9
    ► bit.ly/3IeNLdv
    ► bit.ly/2J4tPeT
    ► bit.ly/3ydSkAq
    Selenium With Python Using Robert Framework
    (Web&API Testing)
    *************************************************
    ► bit.ly/3nUvlpr
    ► bit.ly/3nUvE3z
    API Testing (Postman,SoapUi,&Rest Assured)
    **********************************************
    ► bit.ly/3OXacWY
    ► bit.ly/3yh0UhE
    ► bit.ly/3nC9DWQ
    ► bit.ly/3yGfhNS
    ► bit.ly/3OJa11H
    ► bit.ly/3P2slCC
    Mobile App Testing Appium
    ****************************
    ► bit.ly/3Al49HG
    Performance Testing Jmeter
    *******************************
    ► bit.ly/3nz4fE7
    Maven,Jenkins,Git,Github,CI/CD
    *******************************
    ► bit.ly/3P16HPj
    ► bit.ly/3yhlUVA
    ► bit.ly/3afYfwT
    ► bit.ly/3yGzweG
    ► bit.ly/3yF73Ws
    ► bit.ly/3NCOmH7
    SQL,DB Testing&ETL,Bigdata
    *******************************
    ► bit.ly/3NKOcNY
    ► bit.ly/3OVpDyI
    ► bit.ly/3NEvUy0
    ► bit.ly/3IryxlT
    ► bit.ly/3RkWBLh
    JavaScript Based Automation Tools
    ********************************
    ► bit.ly/3nUx51X
    ► bit.ly/3AqI6Q0
    ► bit.ly/3yeurbT
    ► bit.ly/3ujzpTK
    Selector Hub Tools
    ********************
    ►rb.gy/h3h424
    GraphQL
    ******************
    ► rb.gy/sj3gys
    Cypress API Testing
    ********************
    ► shorturl.at/fjKPX
    Cypress Web Testing
    **********************
    ► shorturl.at/agjlK
    Playwright with Javascipt
    *********************
    ► shorturl.at/adSTY
    #CypressAutomation
    #E2EWebTesting
    #CustomCommands
    #UA-camAutomation
    #WebTestingSolutions
    #AutomateUA-cam
    #CypressFramework
    #WebAutomationTools
    #YTChannelAutomation
    #E2ETestingFramework
    #CypressTestCases
    #CustomCypressCommands
    #UA-camChannelGrowth
    #WebAppAutomation
    #CypressTesting
    #UA-camContentAutomation
    #AutomateWebTesting
    #CypressTipsAndTricks
    #YTChannelManagement
    #EndToEndTesting
    #CypressExtensions
    #UA-camMarketingAutomation
    #WebTestingBestPractices
    #CypressTestAutomation
    #UA-camVideoAutomation
    #WebAppTesting
    #CypressJavaScript
    #YTChannelGrowthHacks
    #UIAutomation
    #CypressCustomization
    #UA-camSEOAutomation
    #CypressTestingFramework
    #WebAutomationJourney
    #CypressTestingTips
    #YTChannelEngagement
    #AutomatedTesting
    #CypressCommandsTutorial
    #UA-camAnalyticsAutomation
    #CypressAutomationTricks
    #YTChannelMonetization
    #ContinuousTesting
    #CypressWebTesting
    #UA-camAlgorithmsAutomation

КОМЕНТАРІ • 44

  • @jaminDNB
    @jaminDNB 10 місяців тому +1

    Thx Sir Pavan, I am very grateful for your videos!

  • @VIKRAMKAMBLE-x9c
    @VIKRAMKAMBLE-x9c Рік тому +13

    now this works
    Cypress.Commands.overwriteQuery(
    "contains",
    function (contains, filter, text, userOptions = {}) {
    // This is parameter resolution from Cypress v12.7.0 source
    if (Cypress._.isRegExp(text)) {
    // .contains(filter, text)
    // Do nothing
    } else if (Cypress._.isObject(text)) {
    // .contains(text, userOptions)
    userOptions = text
    text = filter
    filter = ''
    } else if (Cypress._.isUndefined(text)) {
    // .contains(text)
    text = filter
    filter = ''
    }
    userOptions.matchCase = false;
    let contains0 = contains.bind(this) // this line fixes the error
    return contains0(filter, text, userOptions)
    }
    )

  • @aggyo400
    @aggyo400 Рік тому +1

    this commands has crushed my cypress app.

  • @SarahOwusu-o5c
    @SarahOwusu-o5c Рік тому +3

    @Jaskierify
    1 month ago
    Unfortunately last two custom commands (overwrite/login app) result in cypress error: Cannot read properties of undefined (reading 'hasPreviouslyLinkedCommand')
    I did exactly the same way as presented in the video.
    i am also facing this error could you help me resolve

    • @violetapetrovic3471
      @violetapetrovic3471 Місяць тому

      You can add this in the it block at the top: Cypress.on('uncaught:exception', (err, runnable) => {
      if (err.message.includes('Cannot read properties of undefined')) {

      return false;
      }
      return true;
      });

  • @nadiakoluzaeva6800
    @nadiakoluzaeva6800 Рік тому +3

    Hello Sir
    I am getting errors for overwriting contains() command
    CypressError
    The following error originated from your test code, not from Cypress.
    > Cannot overwrite the contains the query. Queries cannot be overwritten.
    When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.
    Cypress could not associate this error with any specific test.
    We dynamically generated a new test to display this failure. Learn more
    Hoping for your reply soon!

    • @JoolieEm
      @JoolieEm Рік тому +1

      I have the same error.

    • @UpputuriMounika
      @UpputuriMounika 9 місяців тому

      0 seconds ago
      try to comment un used custom commands in commands.js@@JoolieEm

  • @drghungroo7956
    @drghungroo7956 Рік тому +1

    I am getting this error
    Argument of type '(a: string, b: any, c: string) => void' is not assignable to parameter of type 'CommandFn'.

  • @Swas2225
    @Swas2225 8 місяців тому

    TQ,Sir, nice expansion,please provide Cypress meterial

  • @Lee-rp3ey
    @Lee-rp3ey Рік тому +1

    hi sir while accessing custom commands in main file im getting a type erroe ( TypeError: cy.login is not a function ) can you please help me

  • @naimtkhalid3159
    @naimtkhalid3159 8 місяців тому +1

    Thank you so much sir

  • @vuthiquynhvan4873
    @vuthiquynhvan4873 Рік тому +3

    Thanks Sir for great video. I am getting issue with over writing command contains even through I wrote the code like you. I got the message following error:
    An uncaught error was detected outside of a testfailed
    No commands were issued in this test.
    CypressError
    The following error originated from your test code, not from Cypress.
    > Cannot overwite the contains query. Queries cannot be overwritten.
    When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.
    Cypress could not associate this error to any specific test.
    We dynamically generated a new test to display this failure
    Hoping for your reply soon!

    • @chiragbansod4003
      @chiragbansod4003 Рік тому +1

      facing same issue

    • @chiragbansod4003
      @chiragbansod4003 Рік тому

      we need to use 10.7 to make this work

    • @surajkamble3538
      @surajkamble3538 11 місяців тому

      I'm also facing same issue

    • @jaminDNB
      @jaminDNB 10 місяців тому +1

      Hey. Try to use this command for the overwrite 'contains' command:
      // -- The custom command for overwriting contains() method --
      Cypress.Commands.overwrite("contains", function (contains, filter, text, userOptions = {}) {
      if (Cypress._.isRegExp(text)) {
      // .contains(filter, text)
      // Do nothing
      } else if (Cypress._.isObject(text)) {
      // .contains(text, userOptions)
      userOptions = text
      text = filter
      filter = ''
      } else if (Cypress._.isUndefined(text)) {
      // .contains(text)
      text = filter
      filter = ''
      }
      userOptions.matchCase = false;
      let contains0 = contains.bind(this)
      return contains0(filter, text, userOptions)
      }
      )

  • @enawala
    @enawala 11 місяців тому

    I need your help, i writing similar command to get value from textbox by return value but not success, can you help me

  • @surajkamble3538
    @surajkamble3538 11 місяців тому

    Sir now cypress shows error for that over write - ut says cannot overwrite the contains query.querries can be overwritten with with
    Cypress.Commands.overwriteQuerry().

  • @Sam-ng1ft
    @Sam-ng1ft Рік тому +2

    Thank sir! Nice video❤️

  • @JoolieEm
    @JoolieEm Рік тому +2

    Unfortunately last two custom commands (overwrite/login app) result in cypress error: Cannot read properties of undefined (reading 'hasPreviouslyLinkedCommand')
    I did exactly the same way as presented in the video.

    • @jaminDNB
      @jaminDNB 10 місяців тому +1

      Try to use this code:
      // -- The custom command for overwriting contains() method --
      Cypress.Commands.overwrite("contains", function (contains, filter, text, userOptions = {}) {
      if (Cypress._.isRegExp(text)) {
      // .contains(filter, text)
      // Do nothing
      } else if (Cypress._.isObject(text)) {
      // .contains(text, userOptions)
      userOptions = text
      text = filter
      filter = ''
      } else if (Cypress._.isUndefined(text)) {
      // .contains(text)
      text = filter
      filter = ''
      }
      userOptions.matchCase = false;
      let contains0 = contains.bind(this)
      return contains0(filter, text, userOptions)
      }
      )

    • @JoolieEm
      @JoolieEm 10 місяців тому

      @@jaminDNB Thank you Ivan :)

  • @vikrantchaudhari7017
    @vikrantchaudhari7017 Рік тому +1

    At time 34:41, you have added cy.wait(3000). What is the point of adding static wait when cypress supports autowait and auto synchronisation?

  • @PradnyaDeshpande-bo8iw
    @PradnyaDeshpande-bo8iw Рік тому

    Hello Sir
    I am getting error for over writing contains() command
    CypressError
    The following error originated from your test code, not from Cypress.
    > Cannot overwite the contains query. Queries cannot be overwritten.
    When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.
    Cypress could not associate this error to any specific test.
    We dynamically generated a new test to display this failure.Learn more

    • @UpputuriMounika
      @UpputuriMounika 9 місяців тому

      try to comment un used custom commands in commands.js

  • @sandhyakveena36
    @sandhyakveena36 Рік тому +2

    Video is not clear sir