Anjani Kumar
Anjani Kumar

Reputation: 396

Lauching cypress test for the 2nd time, url lands on error page

I am trying to run a test using cypress, 1st time the test runs, it goes to the URL specified i.e. http://demo.nopcommerce.com/, but 2nd time I run the test, the I am redirected to https://demo.nopcommerce.com/page-not-found#/tests/integration\examples\Locators.spec.js

Here is my Script:

describe('Locating Elements', function() {
  it('Verify Types of locators', function() {
    cy.visit('http://demo.nopcommerce.com/')
    cy.get('#small-searchterms').type('Apple MacBook Pro 13-inch')
    cy.get('.button-1.search-box-button[value="Search"]').click()
    cy.get('.button-2.product-box-add-to-cart-button[value="Add to cart"]').click()
    cy.get('#product_enteredQuantity_4').clear().type('3')
    cy.get('input[type="button"][id="add-to-cart-button-4"]').click()
    cy.contains('The product has been added to your').should('be.visible')
    cy.get('.close').click()
    cy.contains('Shopping cart').click()
    cy.get('.estimate-shipping-button').click()
    cy.get('.estimate-shipping-popup').then(function() {
      cy.log('Hello.......')
      cy.get('#CountryId').select('India')
    })
  })
})

enter image description here

Upvotes: 0

Views: 114

Answers (1)

soccerway
soccerway

Reputation: 12011

Could you please try https://demo.nopcommerce.com/ instead of http:// inside cy.visit(), also please add "chromeWebSecurity" : false in cypress.json. When i tried with https://, it is working fine while rerunning the test.

May be a good idea to check with the dev team whether the nopcommerce.com domain/subdomain is configured properly to accepts http:// requests.

Upvotes: 1

Related Questions