I have the below scenario: I search for an element in search box. when the element appears (it may take some time), I click on the element which loads a new view. Then I try to click on some button in new view. since it takes some time to load the search result, the new view does not load. Any way I can avoid wait()?
This is what I have:
cy.get('[data-cy="search"][data-component="input_box"]').type('Find me{enter}')
cy.wait(200) // How to avoid this???
cy.get('[data-name="Find me"]').contains('Find me').click()// Should load a new view
cy.get('[data-cy = "filter"]').click() // failing here as new view is not loaded
Any suggestions will be highly appreciated.
Similar one:
describe('Tutorialspoint Test', function () {
// test case
it('Test Case1', function (){
// test step to launch a URL
cy.visit("https://www.tutorialspoint.com/videotutorials/index.php");
// enter test in the edit box
cy.get("#search-strings").type("Java");
// wait for some time
cy.wait(3000); // ---> how to avoid this?
// using jQuery selector to identify only visible elements
// assertion to validate the number of search results
cy.get('.clsHeadQuestion:visible'). should('have.length',19);
});
});