运行Cypress第一个测试脚本
一.启动Cypress
进入cypress安装目录,输入yarn run cypress open 启动cypress

二.启动测试项目
进入到项目文件夹启动测试项目

三.编写测试脚本
在生成的integration文件夹下编写测试用例testLogin.js
//testLogin.js
///<reference types="cypress"/>
describe(‘登录‘, function(){
//此用户名密码服务器默认
const username = ‘jane.lane‘
const password = ‘password123‘
context(‘HTML 表单登录测试‘,function(){
it(‘登陆成功,跳转到dashboard页‘,function(){
cy.visit(‘http://localhost:7077/login‘)
cy.get(‘input[name=username]‘).type(username)
cy.get(‘input[name=password]‘).type(password)
cy.get(‘form‘).submit()
//断言,验证登陆成功则跳转dashbard页面
//断言,验证用户名存在
cy.url().should(‘include‘, ‘/dashboard‘)
cy.get(‘h1‘).should(‘contain‘,‘jane.lane‘)
}
)
}
)
}
) 
四.在Cypress中运行测试脚本
在启动的Cypress中点击添加的测试脚本,运行。

五.查看断言结果及相关页面

相关推荐
TuxedoLinux 2020-09-11
maxelliot 2020-06-28
chichichi0 2020-06-10
higheels 2020-06-03
ITstudied 2020-05-12
xiechao000 2020-05-03
测试自动化顾问 2020-05-01
goodby 2020-04-30
today0 2020-04-22
jszy 2020-04-20
lucialee 2020-02-23
luanyu 2020-02-18
goodby 2020-01-05
mohanzb 2019-12-21
jszy 2019-12-14
大牛牛 2019-11-08