【发布时间】:2021-07-08 00:27:33
【问题描述】:
我目前正在构建一个测试,似乎在第二次和第三次测试之后,beforeEach 没有得到我需要的信息,并告诉我我遇到了以下问题:
cy.type() can only accept a string or number. You passed in: undefinedLearn more
我的文件如下:
describe('Test all', function () {
beforeEach(() => {
cy.fixture('onlineApp.json').then(function (data) {
this.data = data
})
cy.fixture('onlineAppUsers.json').then(function (info) {
this.info = info
})
})
// Getting into the site to start testing
it('Build remodel ', function () {
// Get into the producs page
Cypress.config().baseUrl
cy.visit(Cypress.env('url_products'))
cy.buildRemodel()
cy.onlineappCreateProfileForm()
cy.businessInfo()
cy.logOut()
})
it('Buy a Business', function () {
// Get into the login page
Cypress.config().baseUrl
cy.visit(Cypress.env('url_login'))
// Login | Use the information from the Fixture file created at the time that we create an account
cy.get('#email').type(this.data.email)
cy.get('#password').type('Abcd1234')
cy.get('.app-submit-btn-text').should('be.visible').click()
// Start a new Application
cy.get(':nth-child(2) > .small-text > a').should('be.visible').click()
// Start Loan Application
cy.buyBusiness()
// Fill out form
cy.get('#full_name').type(this.info.userGoodCredit.name)
cy.get('#company').type(this.info.userGoodCredit.company)
cy.get('#phone_number').type(this.info.userGoodCredit.phone)
cy.get('#email')
cy.wait(10000)
cy.get('.app-submit-btn-text', { delay: 100 }).should('be.visible').click()
cy.businessInfo()
cy.logOut()
})
it('Expand a Business', function () {
// Get into the login page
Cypress.config().baseUrl
cy.visit(Cypress.env('url_login'))
// Login | Use the information from the Fixture file created at the time that we create an account
cy.get('#email').type(this.data.email)
cy.get('#password').type('Abcd1234')
cy.get('.app-submit-btn-text', { time: 100000 }).should('be.visible').click()
// Start a new Application
cy.get(':nth-child(2) > .small-text > a').should('be.visible').click()
// Start Loan Application
cy.expandBusiness()
// Fill out form
cy.get('#full_name').type(this.data.fullName)
cy.get('#company').type(this.info.userGoodCredit.company)
cy.get('#phone_number').type(this.info.userGoodCredit.phone)
})
})
我的问题是在扩展业务测试之后开始的。我不知道是否必须在 beforeEach 语句下传递任何其他函数,或者是否需要进行不同的设置。
我应该如何使用 beforeEach?该文件以前可以工作,但由于某种原因开始失败。可以请教吗?
【问题讨论】:
标签: javascript testing automation cypress qa