Cypress 由一个免费的、开源的、本地安装的 Test Runner 和一个用于记录测试的 Dashboard 服务组成.
Cypress 不受与 Selenium 相同的限制.
cypress可以编写更快、更容易和更可靠的测试。
cypress能够测试任何在浏览器中运行的东西。css
桌面版安装:
下载地址: http://download.cypress.io/desktopnode
命令行安装
首先查看本身的npm版本是不是新版本,若是不是最新则进行升级python
npm -v npm install npm -g
npm install cypress --save-dev
安装可能会出现速度慢的问题,能够试一下下面的方法npm
首先安装cnpm命令浏览器
npm install --global cnpm
npm install cypress --registry=http://registry.npm.taobao.org
npm config set registry http://registry.npm.taobao.org
检查配置是否成功测试
npm config get registry
node_modules\.bin\cypress open
启动cypress若是报文件找不到的错误:Can't start server EEXIST: file already exists, mkdir 'C:**\node_modules.bin\cypress'
能够将命令改成全局启动
url
node_modules\.bin\cypress open --global
建立一个.js的测试文件命令行
describe('个人第一个测试', () => { it('测试用例', () => { expect(true).to.equal(true); } ) } )
打开编写的测试用例并运行
3d
describe('个人第一个测试',function(){ it('百度测试用例:',function(){ cy.visit('http://www.baidu.com') //访问url cy.title().should('contain','百度一下,你就知道') //验证页面 title 是否正确 cy.get('#kw').type('python') //根据 css 定位搜索输入框 .should('have.value','python') //验证关键字自动是否展现正确 cy.get('#su').click() //根据 css 定位搜索按钮并点击 cy.url().should('include','wd=python') //验证目标url 是否正确包含关键字 cy.title().should('contain','python_百度搜索') //验证页面 title 是否正确 cy.get('[id="1"]').should('contain','python') // 验证第一个结果中是否包含TesterHome cy.screenshot() }) })