英文:
Repeat in cypress
问题
我现在正在进行负载测试,需要创建14000张票来查看应用程序的响应。
我的问题是如何重复简单的自动测试,直到我获得14000张票的注册。
/// <reference types="cypress" />
Cypress._.times(1000, () => {
const timestamp = new Date().getTime();
describe('Load', () => {
it('Loadtest', () => {
cy.visit('link') // 访问站点
cy.get('#email').type('name') // 输入用户名
cy.get('#password').type('password') // 输入密码
cy.get('._btn_1wzi7_1').click() // 单击登录按钮
cy.get('.css-19bb58m').type('Microsoft Outlook 2').type('{enter}')
cy.get('#title').type(`Random Text ${timestamp}`)
cy.get('#note').type(`Another Random Text ${timestamp} Another Random Text ${timestamp} Another Random Text ${timestamp} Another Random Text ${timestamp}
Another Random Text ${timestamp} Another Random Text ${timestamp} Another Random Text ${timestamp} Another Random Text ${timestamp} Another Random Text ${timestamp}
Another Random Text ${timestamp} Another Random Text ${timestamp} Another Random Text ${timestamp} Another Random Text ${timestamp} Another Random Text ${timestamp}`)
cy.get('#checkbox').click() // 按下应该被按下的复选框
cy.get('._btn_1wzi7_1').click()
cy.get('._title_1jitq_37').should('have.text', '10000') // 这个数字是创建的票的ID,每创建一张票后会递增。
})
})
})
现在它将重复这个测试1000次,当我将它设为2000时,它运行得更慢。
我需要在cy.get('._title_1jitq_37').should('have.text', '10000')
变成24000时重复执行。
英文:
I am doing load test right now and need to create 14000 tickets to see how app will response.
My question is about how to repeat simple auto test, until I get 14 000 ticket registration.
<!-- language: js -->
/// <reference types="cypress" />
Cypress._.times(1000, ()=>{
const timestamp = new Date().getTime();
describe('Load', ()=>{
it('Loadtest', ()=>{
cy.visit('link')// visit site
cy.get('#email').type('name')//insert username
cy.get('#password').type('password')//insert password
cy.get('._btn_1wzi7_1').click() //click login button
cy.get('.css-19bb58m').type('Microsoft Outlook 2').type('{enter}')
cy.get('#title').type(`Random Text ${timestamp}`)
cy.get('#note').type(`Another Random Text ${timestamp} Another Random Text ${timestamp} Another Random Text ${timestamp} Another Random Text ${timestamp}
Another Random Text ${timestamp} Another Random Text ${timestamp} Another Random Text ${timestamp} Another Random Text ${timestamp} Another Random Text ${timestamp}
Another Random Text ${timestamp} Another Random Text ${timestamp} Another Random Text ${timestamp} Another Random Text ${timestamp} Another Random Text ${timestamp}`)
cy.get('#checkbox').click() //press check box which should be pressed
cy.get('._btn_1wzi7_1').click()//
cy.get('._title_1jitq_37').should('have.text', '10000') //this number is the id of created ticket and it increments after each created ticket.
})
})
})`
Right now it repeats that test 1000 times and when I make it 2000 it works slower.
I need it repeated when this cy.get('._title_1jitq_37').should('have.text', '10000')
become to 24000.
答案1
得分: 2
不要翻译的内容:Rather than looping 14_000 times in your test, try it with cypress-grep burn parameter.
For example
npx cypress run --env burn=5 --spec cypress/integration/A.js
I haven't tried it with that many iterations, so can't say it will be quicker, but the way you have tried generates a very large spec that must be parsed into a queue and stored in memory.
As I understand it, cypress-grep controls the burn from the Cypress node (background) process so the memory footprint is likely to be smaller.
Ref: Current home page with install instructions and usage details.
英文:
Rather than looping 14_000 times in your test, try it with cypress-grep burn parameter.
For example
npx cypress run --env burn=5 --spec cypress/integration/A.js
I haven't tried it with that many iterations, so can't say it will be quicker, but the way you have tried generates a very large spec that must be parsed into a queue and stored in memory.
As I understand it, cypress-grep controls the burn from the Cypress node (background) process so the memory footprint is likely to be smaller.
Ref: Current home page with install instructions and usage details.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论