CypressError: Timed out retrying

0

Current behavior:

I am getting the above error in my code, visiting a webpage and checking it contains the correct URL.

This logic works on other links within the webpage.

describe('Sectors Tab', function () {
    it('finds Software Development', function () {
        cy.visit('http://www.afd.co.uk/')
        cy.contains('Sectors')
            .click({force: true})
        cy.contains('Software Development')
            .click({force: true})
        cy.url()
            .should('include', '/sectors/software-development/')
    })

Desired behavior:

It should return a valid response back saying it has passed the test.

Just like it has done for my other tests:

it('finds Banking and Finance', function () {
    cy.visit('http://www.afd.co.uk/')
    cy.contains('Sectors')
        .click({force: true})
    cy.contains('Banking and Finance')
        .click({force: true})
    cy.url()
        .should('include', '/sectors/banks-and-finance/')
})

Image for Above Tests

Image of errors

Steps to reproduce: (app code and test code)

See above for information about test code.

Versions

Chrome: 76
Cypress: 3.4.1

I reported this question in GitHub already, and they closed the issue as it is not an issue with Cypress itself.

The member replied back with the following:

As the error shows, the url does not contain the /sectors/banks-and-finance/ portion.

You can see in the passing test that the page navigated to the /sectors/banks-and-finance/ url with the (NEW URL) being logged - in the failing test case this is not logged - the URL is never changing.

Cypress is displaying the correct error in this case. Why is your website not navigating? Is it not navigating because of a bug in Cypress? I would have no idea of knowing without a fully reproducible example to run.

Reference: https://github.com/cypress-io/cypress/issues/5069

So on that note, I have no idea what else to try. There are no examples I can give either, as this is an easy accessible webpage and have provided the code.

Kevdog777

Posted 2019-09-05T08:54:42.817

Reputation: 437

Answers

2

Update: Looking at the website, I see that there are multiple elements one the webpage that contain the sub-string "Software Development". Cypress finds and clicks the first one it finds, which is probably not the one that you intended.

As the element doesn't have an id or a any other unique attribute, I would do the following:

cy.get('.footer-menu-level-2').eq(1).contains('Software Development').click();

Obviously, if you can ask the developers to add a unique attribute, that would be preferable.

Original Answer:

Did you try to see if the URL changes when you do the same manually? It's sounds like it's a bug in the SUT...

Arnon Axelrod

Posted 2019-09-05T08:54:42.817

Reputation: 136

1

This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review

– CaldeiraG – 2019-09-05T11:44:28.113

1

Yes it does change manually. It goes to the correct page: http://www.afd.co.uk/sectors/software-development/, but it is something to do with Cypress not seeing the link then clicking on the link.

– Kevdog777 – 2019-09-05T11:48:32.533

1@CaldeiraG - I know, but I didn't see the option to add a comment. Either because I wrote the answer from my mobile phone, or because I wasn't registered with SuperUser yet (I was registered only to SO). – Arnon Axelrod – 2019-09-05T11:51:20.337

@ArnonAxelrod, Thank you so much! That is passing with flying colours - it has caused me so many issues on other pages, and this has helped :D – Kevdog777 – 2019-09-05T14:12:15.033

Is there no way I could try and get it from the tab at the top? I have tried this cy.get('.dropdown-menu menu-level-2').find('Software Development').contains('Software Development').click() but not even that worked. – Kevdog777 – 2019-09-05T15:53:01.750