什么是TestCafe?
TestCafe是一个基于Node.js,反对多平台(Linux,Windows,macOS)的端到端web测试框架
装置指南
最简略的形式是通过npm包管理工具进行装置,以下命令会在电脑上全局装置testcafe
npm i -g testcafe
形成
TestCafe测试基于Node.js脚本执行,可通过新创建TypeScript或JavaScript文件开始进行测试用例编写,TestCafe的测试文件由fixtures和tests组成,一个fixture是一组共享初始URL的test函数组成的
倡议:在每一个test文件中仅应用一个fixture,如用例集中蕴含不同初始URL的测试,最好将其调配至不同的测试文件中——通过初始URL进行分类
通过如下形式进行fixture的创立:
fixture("Getting Started")
而后应用page办法为fixture指定初始的URL:
fixture("Getting Started").page("https://devexpress.github.io/testcafe/example")
最初,通过应用test方面进行测试用例的申明:
fixture("Getting Started").page("https://devexpress.github.io/testcafe/example") test("My first test", async (t) => { // Test code here })
测试动作
testcafe以后反对的页面操作:
Click(点击)
点击操作又可分为:Click、Double Click、Right Click,示例:
import {Selector} from 'testcafe'; fixture `Interact With the Page`.page`example`; test("Click Test", async (t) => { const btn = Selector("button").withText("Test") // await t.doubleClick(btn) // await t.rightClick(btn) await t.click(btn) })
- Press Key(键盘输入)
- Type Text(输出文字)
- Select Text (抉择文本)
- Hover(高亮)
- Scroll(滑动)
- Drag Element(拖动元素)
- Upload Files
- Work with iframes
testcafe以后反对的浏览器操作:
1.Navigate to a URL
(继续更新至齐全~)