Part 19 Cypress Data Driven Tests | Working with Files/Fixtures

Поделиться
HTML-код
  • Опубликовано: 11 сен 2024
  • In this video I've shown
    1. Working with Files/Fixtures in Cypress?
    2. Data Driven Tests
    3. Run Test Against Multiple Set of Data
    4. Cypress Commands used
    a. cy.fixture()
    b. cy.readFile() &
    c. cy.writeFile()
    JAVASCRIPT
    • JavaScript Tutorial fo...
    FRAMEWORK, ASSERTION, REPORT
    • JavaScript Testing Fra...
    ELEMENT LOCATOR
    jQuery -
    • jQuery - find UI eleme...
    CSS SELECTOR
    • Learn CSS Selectors (i...
    XPath
    • Master XPath for UI Au...
    Nodejs Basics • Nodejs Basics
    WEB & API CONCEPTS
    Important API Testing Concepts - API TESTING 101
    • Important API Testing ...
    Learn API Testing using Postman
    • Learn API Testing usin...
    Github Link: -
    github.com/qab...
    Conduit App link: -
    react-redux.re...

Комментарии • 18

  • @balaone836
    @balaone836 3 года назад +2

    Nice course! Possible to add one for data handling for cypress through excel sheet or .csv?

    • @QABoxLetsTest
      @QABoxLetsTest  3 года назад +2

      Sure, I will try to add it

    • @balaone836
      @balaone836 3 года назад

      @@QABoxLetsTest Sure, that would be really nice, since we couldn't find any single content across for cypress data automation via excel sheet :) ! & Thanks for the quick response though!!!

  • @bharathca16
    @bharathca16 3 года назад

    I tried to perform fetching of data from the fixtures but I am getting "Cannot read property 'userDetails' of undefined
    "
    inside the describe suite, i have created a it block
    before the it block, i have used before each and used the fixtures to get the data and store it in the variable
    tried to use the variable to fetch the data and use them in the script.
    Could you please help in here?

    • @QABoxLetsTest
      @QABoxLetsTest  3 года назад

      Kindly check the code here
      www.github.com/qaboxletstest/Cypress-Demo/tree/master/cypress%2Fintegration%2FQABOX%2FTC_15_DataDriven.spec.js

  • @vickykumar-eh9om
    @vickykumar-eh9om 3 года назад +1

    What if i have multiple data like 100 set of data for login in single fixture file how can i iterate and test it

    • @QABoxLetsTest
      @QABoxLetsTest  3 года назад +2

      Even simpler than what I've explained, follow the steps
      1. cy.fixture your data file with array of credential objects
      2. Use then method and in then method callback you will have array of credentials as an argument, let's call it creds
      3. Inside then callback function do creds.forEach and afterwards it's straightforward
      Write describe and it blocks like I've shown in the video and supply the data from each cred object like cred.email and cred.password
      Hope that answers your question

    • @vickykumar-eh9om
      @vickykumar-eh9om 3 года назад +1

      @@QABoxLetsTest
      No still i am not able to do so
      My data is in this format
      {
      "cred": [
      {
      "un": "cat",
      "pw": "ca1"
      },
      {
      "un": "dog",
      "pw": "da1"
      }
      ]
      }
      So how can i iterate this data

    • @QABoxLetsTest
      @QABoxLetsTest  3 года назад

      If you use this format then you have to say nameofimport.cred.forEach and then follow the steps mentioned above.

  • @swatisabharwal
    @swatisabharwal 3 года назад

    Could you explain Writing to the fixture file as well? I have to cover SIgn-up flow and want a different username every time.
    Thanks

    • @QABoxLetsTest
      @QABoxLetsTest  3 года назад

      You have to use both cy.readFile() and cy.writeFile() to achieve this. You can write something like:
      cy.readFile("cypress/fixtures/dataFile.json", (err, data) => {
      if (err) {
      return console.error(err);
      };
      }).then((data) => {
      data.table[0].number = 3
      data.table[1].number = 4
      cy.writeFile("cypress/fixtures/dataFile.json", JSON.stringify(data))
      })
      Assuming the fixture file would read
      {
      table: [
      {
      name: 'Joe',
      number: 1,
      },
      {
      name: 'Bob',
      number: 2,
      },
      ],
      };

  • @anucoonjan3348
    @anucoonjan3348 2 года назад

    Hello, i have a json file which loads and does not change when i select from dropdown.
    For example my fixture file has both negative and positive values.
    how to make it display only positive values when i select positive.
    the data are not getting refreshed

    • @QABoxLetsTest
      @QABoxLetsTest  2 года назад

      Hey, couldn't make out what you are doing in here. You select and drop-down and want your json file to be filtered. These are two different operations, one happens on app and other on file.

    • @lululula5783
      @lululula5783 2 года назад

      @@QABoxLetsTest no what i want is that my mock network request display the correct info when i select from a dropdown
      Current it is displaying just the fixture file without applying the select

    • @QABoxLetsTest
      @QABoxLetsTest  2 года назад

      So you loaded the drop-down via fixture file by mocking the api call. Now you want some default item to be selected in that. Right?
      If so then an item is selected when it has a selected attribute added to it. So, if that isn't added, which may happen because at time developers use Javascript to add attributes, you need to add an attribute by yourself. Mocking might have not called the application javascript.

  • @abidagulzar6895
    @abidagulzar6895 Год назад

    How to read data form xml file please?

  • @NikitaFondekar-rz3mb
    @NikitaFondekar-rz3mb 3 месяца назад

    how to read data from .csv file in cypress

    • @QABoxLetsTest
      @QABoxLetsTest  2 месяца назад

      Use a relevant npm package to read csv file and rest of it remains the same as explained in this series