cypress - 获取“无法设置只有getter的属性名称”
问题描述
不久前,测试脚本完美运行。据我所知,唯一的更改是 URL。
这是有问题的测试之一。请注意,我们已将 URL 替换为假 URL。
我们尝试过全新安装 Cypress。我们的支持文件等中没有任何内容。
我在代码中没有任何地方尝试设置属性。无论哪种方式,在运行我的测试之前似乎都会抛出错误。
错误是:
"cannot set property name of which has only a getter"
/// <reference types="cypress" />
describe('Sign up', () => {
it('Sign up - fill details', () => {
//make new account
cy.visit('https://my.website/sign-in')
// cy.wait(2000)
// cy.contains('Sign-up').click()
// fill form
// cy.get('#firstName').type('userName')
// cy.get('#lastName').type('userLastName')
// cy.get('#mobile').type('+61000000000)
// cy.get('#email').type('email@gmail.com')
// cy.get('#password').type('ASDfgh_123')
// //cy.contains('Next').click()
})
})
堆栈跟踪:
TypeError: Cannot set property name of which has only a getter
at onError (https://[MY_WEBSITE]/__cypress/runner/cypress_runner.js:156647:18) From previous event:
at Object.run (https://[MY_WEBSITE]/__cypress/runner/cypress_runner.js:170479:13)
at Object.run (https://[MY_WEBSITE]/__cypress/runner/cypress_runner.js:156658:15)
at $Cy.cy.<computed> [as visit] (https://[MY_WEBSITE]/__cypress/runner/cypress_runner.js:157812:17)
at __stackReplacementMarker (https://[MY_WEBSITE]/__cypress/runner/cypress_runner.js:157121:13)
at Context.runnable.fn (https://[MY_WEBSITE]/__cypress/runner/cypress_runner.js:158036:21)
at callFn (https://[MY_WEBSITE]/__cypress/runner/cypress_runner.js:112788:21)
at Test.../driver/node_modules/mocha/lib/runnable.js.Runnable.run (https://[MY_WEBSITE]/__cypress/runner/cypress_runner.js:112775:7)
at https://[MY_WEBSITE]/__cypress/runner/cypress_runner.js:164502:28 From previous event:
at Object.onRunnableRun (https://[MY_WEBSITE]/__cypress/runner/cypress_runner.js:164487:17)
at $Cypress.action (https://[MY_WEBSITE]/__cypress/runner/cypress_runner.js:154145:28)
at Test.Runnable.run (https://[MY_WEBSITE]/__cypress/runner/cypress_runner.js:162234:13)
at Runner.../driver/node_modules/mocha/lib/runner.js.Runner.runTest (https://[MY_WEBSITE]/__cypress/runner/cypress_runner.js:113447:10)
at https://[MY_WEBSITE]/__cypress/runner/cypress_runner.js:113573:12
at next (https://[MY_WEBSITE]/__cypress/runner/cypress_runner.js:113356:14)
at https://[MY_WEBSITE]/__cypress/runner/cypress_runner.js:113366:7
at next (https://[MY_WEBSITE]/__cypress/runner/cypress_runner.js:113268:14)
at https://[MY_WEBSITE]/__cypress/runner/cypress_runner.js:113334:5
at timeslice (https://[MY_WEBSITE]/__cypress/runner/cypress_runner.js:107260:27)
解决方案
我们今天遇到了同样的问题并通过chromeWebSecurity: false
设置cypress.json
这就是我们cypress.json
让它工作的样子。
{
"chromeWebSecurity": false
}
带有测试的规范文件如下所示:
describe('Single Sign On Test', () => {
it('Visit Single Sing On Page', () => {
cy.visit('https://example.com/signin')
cy.get('#username').should('be.visible').type('username')
cy.get('#next').click()
cy.get('#password').should('be.visible').type('password')
cy.get('#signin').click()
})
})
推荐阅读
- domain-driven-design - 在对事件源域模型进行建模时可以有“技术”事件吗?
- java - 更新共享首选项值得到致命信号 6 (SIGABART) 错误和应用程序崩溃
- mysql - 名字和姓氏的首字母仅在数据库查询中
- jenkins - Jenkins 和 Slack(Jenkins Slack 应用程序不能在脚本中使用)
- php - 在 PHPUnit 中使用 SQLite 会导致磁盘 I/O 错误
- python - 如何将负 (<0) RGB 颜色值放入 PIL 中的图像?
- mysql - 根据某些条件管理我的查询结果
- c# - AWS 认知托管 UI 在 asp.net 核心 Web 应用程序中显示登录用户名
- r - 左截断 Gamma 拟合
- java - 在我的回文函数中输入一个空字符串