cypress - 第二次启动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')
})
})
})
解决方案
您能否尝试一下https://demo.nopcommerce.com/
,而不是http://
在 cy.visit() 中,也请"chromeWebSecurity" : false
在 cypress.json 中添加。当我尝试使用 https:// 时,它在重新运行测试时工作正常。
nopcommerce.com
与开发团队检查域/子域是否配置正确以接受http://
请求可能是一个好主意。
推荐阅读
- php - Symfony5 项目的 Phan/phan 配置
- logic - 用谓词逻辑表达句子
- jenkins - 如何编写 sed 命令以仅提取“选择”查询并将输出保存到 CSV
- c# - FileNorFoundException - Microsoft.TeamFoundation.WorkItemTracking.Client.DataStoreLoader
- html - 我该如何制作,以便背景图像作为“整体”加载,而不是部分加载,然后以黑白颜色加载?
- c - 缓冲区溢出 - 查找 EIP
- mysql - 如何消除 SQL 中的错误
- json - 创建一个 Json 文件作为 ffmpeg 命令行的输出
- python - Python BeautifulSoup 仅从表格单元格打印
- django - 如何使用 django 表单保留 2 个字段