Cypress run statement before page load

Viewed 402

I am trying to run the following statement when i open a page in one of my cypress tests:

    cy.window().then(win => {
    Cypress.$.event.trigger({type: "BarcodeScanned",message: "BARCODEGOESHERE",time: new 
    Date()});
    })

But this never gets executed when i am on the page. The page is constantly loading as expected but as i understand, cypress will not execute the statement until the page has fully loaded. Is there a way to execute the above statement even if the page hasn't finished loading?

Below is what i get when i am running my test and it just stays like that..

(page load) --waiting for new page to load--

0 Answers
Related