Unable to see the json data after chaining the cy.visit()

166 Views Asked by At

After login to a site, I have given two urls, first I should be visiting the first url and then approx waiting for around 20 seconds, then I should be visiting the second url. After that I should see some json data displaying in site. If we didn't wait for 20 seconds I won't be getting the json data. I have tried below, but not able to see the json data. What else should I do to see that data ?

cypress version : 6.1.0

cypress-cucumber-preprocessor

LoadJSON.feature

Feature: LoadJson Data

    Scenario: Access url
        Given I open the build URL
        
    Scenario: Login and see JSON DATA
        Given I am logged in as Cypress user
        When I send a awesome request to site to json data
    

first url : https://somedomain.com/student/add/generateSomeStatements.php

second url: https://somedomain.com/student/readInstructions.php

Step definitions

/* Login step */ 
When('I am logged in as Cypress user', () => {
  cy.get('[name=Username]').type(Cypress.env('USERNAME'));
  cy.get('[name=Password]').type(Cypress.env('PASSWORD'), { sensitive: true });
  cy.contains('Login').click();
})

/* Load JSON data step*/ 
And('I send a awesome request to site to json data', () => {
    cy.visit('add/generateSomeStatements.php')
      .wait(25000)
      .then(
          async () => await cy.visit('readInstructions.php').then((resp)=>{
            console.log(resp);
        })
      )
    
});
0

There are 0 best solutions below