fixture读取数据
describe('登陆web网站案例', function() {
beforeEach(() => {
cy.visit('http://ip:8080/zentao/user-login.html');
cy.fixture('login.json').as('login')
})it("登陆案例", function ()
{
cy.log("读取login.json文件账号:"+this.login.username)
cy.log("读取login.json文件密码:"+this.login.password)
// let 定义变量
let username = this.login.username
let password = this.login.password
let include = this.login.include
let text = this.login.text
let zentaosid = this.login.zentaosid
//输入用户名
cy.get('#account').type(username)
.should('have.value', username)
// 输入密码
cy.get('[name="password"]').type(password)
.should('have.value', password)
// 提交表单
cy.get('#submit').click()
// 判断页面跳转到 /zentao/my/
cy.url().should('include', include)
// and '欢迎您:admin' in page
cy.get('body').should('contain', text)
// 判断存在cookie值 'zentaosid'
cy.getCookie('zentaosid').should(zentaosid)
})
})