-3

If you try cy.visit('/') with a baseURL of https://www.tutorialspoint.com/html/index.htm you'll see that the viewport doesn't resemble the website at all: NOTE: seems like there's a difference between using baseURL or you just the full URL inside cy.visit(). Either case cy.visit ends up failing:

Your page did not fire its load event within 60000ms

visitig with baseURL

I can't seem to go past visiting the website. Meaning, I can't perform any validations inside it. Cy.visit (or any other navigation hacks and custom commands I've tired) end up failing in different ways.

Probably the website is expecting some resource that never loads, can I just stop the website to load any further?

user3303019
  • 142
  • 1
  • 11
  • 2
    I can't reproduce the issue, works fine here. – J.Ollie.Rogers Jun 30 '23 at 21:45
  • I see that it looks good if you cy visit directly. I was using that url in baseurl and visiting '/'. Try that. Either case, visiting it directly makes cy.visit fail and I can't go on to test anything. Can you? – user3303019 Jul 01 '23 at 14:36
  • The page https://www.tutorialspoint.com/html/index.htm shows multiple errors in Google Chrome F12 Console. It continues contacting 3rd party sites after the original page has been displayed and in the Network tab it never reports that the page has been loaded. – MikeMcC399 Jul 10 '23 at 11:46

3 Answers3

4

Quodos to Nunzio for a good solution. I would take the whitelist approach instead, makes for a much faster execution.

Include the base domain, also bing.com since a page script is relying on that domain.

const whitelist = ['tutorialspoint.com', 'bing.com']
cy.intercept('*', (req) => {
  if (!whitelist.some(wl => req.url.includes(wl))) {
    req.reply({})
  }
})

cy.visit('https://www.tutorialspoint.com/html/index.htm');
cy.get('h1').contains('HTML Tutorial')
cy.contains('li', 'HTML - Iframes').click()
cy.get('h1').contains('HTML - Iframes')         // on the new page now
Lola Ichingbola
  • 3,035
  • 3
  • 16
3

The failure to page-load appears to be due to trackers and advertisers, perhaps historical and no longer functional.

Unless specifically testing those "features", you can stub them out and proceed with testing the page.

For example, here's a couple I picked out that seem to resolve the page-load problem

it('tests tutorialpoint', () => {
  cy.intercept('https://usersync.gumgum.com/**', {})          // tracking?
  cy.intercept('https://image6.pubmatic.com', {})             // advertising?

  cy.visit('https://www.tutorialspoint.com/html/index.htm')
  cy.get('h1').contains('HTML Tutorial')                      // passes
})

Realistically you would want to test a web site without interference from links that clog the network traffic.

Nunzio
  • 144
  • 7
  • You can also use `blockHosts` to stop trackers affecting the page load. See https://docs.cypress.io/guides/references/configuration#Browser – MikeMcC399 Jul 11 '23 at 05:00
  • it is also happening in very light testing web apps like saucedemo.com now https://stackoverflow.com/questions/76868590/cypress-runner-issue-with-page-load-event – user3303019 Aug 09 '23 at 14:11
0

The page https://www.tutorialspoint.com/html/index.htm never completes loading. When viewed in Google Chrome F12 Network (without using Cypress) it shows continual requests and no data for the time it took to complete the page load. Which suggests that the page load was never complete.

tutorialspoint network

Compare this to loading the Cypress documentation page https://docs.cypress.io/guides/overview/why-cypress which shows a completed load time.

cypress network

MikeMcC399
  • 173
  • 1
  • 10