一、环境构建
1. 下载并安装Node.js
2. 创建一个项目文件夹,执行npm init -y,然后npm install cyperss
3. npx cyperss open
二、小试牛刀
1. 运行一遍examples代码,即可看到https://example.cypress.io/的示例代码都执行了一遍
三、研究示例帮助和API
1. 自行学习examples代码,分析每个示例脚本,教会了哪些必备技能
Commands
Commands drive your tests in the browser like a real user would. They let you perform actions like typing, clicking, xhr requests, and can also assert things like "my button should be disabled".
- Querying(querying.spec.js)
- Traversal(traversal.spec.js)
- Actions(actions.spec.js)
- Window(window.spec.js)
- Viewport(viewport.spec.js)
- Location(location.spec.js)
- Navigation(navigation.spec.js)
- Assertions(assertions.spec.js)
- Misc(misc.spec.js)
- Connectors(connectors.spec.js)
- Aliasing(aliasing.spec.js)
- Waiting(waiting.spec.js)
- Network Requests(network_requests.spec.js)
- Files(files.spec.js)
- Local Storage(local_storage.spec.js)
- Cookies(cookies.spec.js)
- Spies, Stubs & Clocks(spies_stubs_clocks.spec.js)
Utilities(utilities.spec.js)
Utilities give you access to methods from other commonly used libraries.
Cypress API(cypress_api.spec.js)
The Cypress API enables you to configure the behavior of how Cypress works internally. You can do things like access Environment Variables, change configuration, create custom commands, and more.
四、项目实践
在你的项目中,从登录/登出开始,逐步完成前端UI自动化验证脚本设计和实现;