1

登录网站后,我给出了两个网址,首先我应该访问第一个网址,然后等待大约 20 秒,然后我应该访问第二个网址。之后,我应该会看到一些 json 数据显示在站点中。如果我们不等待 20 秒,我将不会获得 json 数据。我在下面尝试过,但看不到 json 数据。我还应该怎么做才能看到这些数据?

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
    

第一个网址:https ://somedomain.com/student/add/generateSomeStatements.php

第二个网址: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);
        })
      )
    
});
4

0 回答 0