navigation.spec.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /// <reference types="cypress" />
  2. context('Navigation', () => {
  3. beforeEach(() => {
  4. cy.visit('https://example.cypress.io')
  5. cy.get('.navbar-nav').contains('Commands').click()
  6. cy.get('.dropdown-menu').contains('Navigation').click()
  7. })
  8. it('cy.go() - go back or forward in the browser\'s history', () => {
  9. // https://on.cypress.io/go
  10. cy.location('pathname').should('include', 'navigation')
  11. cy.go('back')
  12. cy.location('pathname').should('not.include', 'navigation')
  13. cy.go('forward')
  14. cy.location('pathname').should('include', 'navigation')
  15. // clicking back
  16. cy.go(-1)
  17. cy.location('pathname').should('not.include', 'navigation')
  18. // clicking forward
  19. cy.go(1)
  20. cy.location('pathname').should('include', 'navigation')
  21. })
  22. it('cy.reload() - reload the page', () => {
  23. // https://on.cypress.io/reload
  24. cy.reload()
  25. // reload the page without using the cache
  26. cy.reload(true)
  27. })
  28. it('cy.visit() - visit a remote url', () => {
  29. // https://on.cypress.io/visit
  30. // Visit any sub-domain of your current domain
  31. // Pass options to the visit
  32. cy.visit('https://example.cypress.io/commands/navigation', {
  33. timeout: 50000, // increase total time for the visit to resolve
  34. onBeforeLoad (contentWindow) {
  35. // contentWindow is the remote page's window object
  36. expect(typeof contentWindow === 'object').to.be.true
  37. },
  38. onLoad (contentWindow) {
  39. // contentWindow is the remote page's window object
  40. expect(typeof contentWindow === 'object').to.be.true
  41. },
  42. })
  43. })
  44. })