首页 > 解决方案 > 第二次启动cypress测试,url登陆错误页面

问题描述

我正在尝试使用 cypress 运行测试,第一次运行测试时,它转到指定的 URL,即http://demo.nopcommerce.com/,但第二次运行测试时,我被重定向到https:/ /demo.nopcommerce.com/page-not-found#/tests/integration\examples\Locators.spec.js

这是我的脚本:

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')
    })
  })
})

在此处输入图像描述

标签: cypress

解决方案


您能否尝试一下https://demo.nopcommerce.com/,而不是http://在 cy.visit() 中,也请"chromeWebSecurity" : false在 cypress.json 中添加。当我尝试使用 https:// 时,它在重新运行测试时工作正常。

nopcommerce.com与开发团队检查域/子域是否配置正确以接受http://请求可能是一个好主意。


推荐阅读