Search code examples
javascriptcypresscypress-component-test-runner

Expected to find element : but never found it(not a normal assertion)


//I have tried alias,asserts,wait,etc..,but can't click the element because the page is not loaded.I don't want to use wait() or pause() command. I need a solution to interact with the elements however the network or testing environment is slow or speed.

My code is as follows :

///

it('Test ship',function(){

cy.viewport(1120,800)

  cy.visit('url')

 cy.get('#NFR_LoginForm-nfr_login_authname').type('KKV2C123')

 cy.get('#NFR_LoginForm-nfr_login_authid').type('paSSword1{enter}')

 cy.on('uncaught:exception', (err, runnable) => {
     return false
 })
 
 cy.wait[ cy.xpath('//span[normalize-space()="Work Space"]')
      
           .click({force: true})]

Here is my screenshot.

Assertion error image


Solution

  • Bump the wait time on your click(). Is 3 minutes enough?

    cy.xpath('//span[normalize-space()="Work Space"]', {timeout:180000})
      .click()