第二次启动cypress测试,URL登陆错误页面

时间:2020-08-18 18:25:39

标签: cypress

我正在尝试使用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')
    })
  })
})

enter image description here

1 个答案:

答案 0 :(得分:1)

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

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

相关问题