How to search for a specific data from a JSON file with array in Cypress? #21107
Unanswered
Deivisom1979
asked this question in
Questions and Help
Replies: 1 comment 2 replies
-
Hi @Deivisom1979, If it works as expected by testing your API on its own, it means the data is filtered on API side. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone!!
I really appreciate if someone help me in my question.
In this case, the scenario is: Type a TERM# on the #nroTerminal input, click on the Search button and show the results with that TERM#.
I have a JSON file where I mocked it from the API and I need to validate a web page with 3 input fields.
So, I'm trying to type for a specific terminal# and check if it works and it is not working. Instead of to show only the terminal# on the results, it is showing all the JSON content data. I did the same test validation on the API service and it worked as expected.
Pre Requirement: User should be logged in.
JSON file (attached as TXT file): carta-cancelamento.txt

Screenshot:
This is my code in Cypress (search.spec.js)
describe('Search validation', () => {
cy.intercept(
'GET',
'/mc-extratos/',
{fixture: 'financeiro/carta-cancelamento'},
).as('verCartas')
cy.visit('/carta-de-cancelamento')
cy.get('[data-cy="consultarCartas"]') //button
.should('be.visible')
.click()
cy.wait('@verCartas')
.its('response.statusCode').should('eq', 200)
})
it('Search by Terminal', () => {
cy.get('#nroTerminal')
.should('be.visible')
.type('05009867')
cy.get('[data-cy="consultarCartas"]').click()
cy.wait('@verCartas')
}
)
Beta Was this translation helpful? Give feedback.
All reactions