running-webdriverio-tests
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRunning WebdriverIO Tests
运行WebdriverIO测试
Main Command
主命令
bash
npx wdioConfig is in by default.
wdio.conf.jsbash
npx wdio默认配置文件为。
wdio.conf.jsDuration
测试时长
Tests take 20 seconds to 5 minutes. Do not treat a slow test as a failure.
测试耗时在20秒到5分钟之间。不要将运行缓慢的测试视为失败。
Selecting Tests to Run
选择要运行的测试
By spec file
通过测试文件(spec file)
bash
undefinedbash
undefinedSingle file
单个文件
npx wdio --spec=test/specs/home.js
npx wdio --spec=test/specs/home.js
Multiple files
多个文件
npx wdio --spec=test/specs/home.js --spec=test/specs/register.js
undefinednpx wdio --spec=test/specs/home.js --spec=test/specs/register.js
undefinedBy suite
通过测试套件(suite)
Suite names are defined in the WebdriverIO config file under the property.
suitesbash
npx wdio --suite=auth套件名称在WebdriverIO配置文件的属性中定义。
suitesbash
npx wdio --suite=authExcluding files
排除文件
bash
npx wdio --exclude=test/specs/home.jsCan be mixed with or .
--spec--suitebash
npx wdio --exclude=test/specs/home.js可与或搭配使用。
--spec--suiteKey CLI Options
关键CLI选项
| Option | Description |
|---|---|
| Run specific spec file(s) or wildcard |
| Run a named suite from wdio.conf.js |
| Exclude spec file(s) from run |
| |
| Stop after N failures (default: 0 = run all) |
| Number of parallel browser instances (2–10) |
| Override base URL for |
| Repeat specs/suites N times |
| 选项 | 描述 |
|---|---|
| 运行指定的测试文件或使用通配符 |
| 运行wdio.conf.js中定义的命名测试套件 |
| 从运行中排除指定测试文件 |
| 日志级别: |
| 出现N次失败后停止测试(默认值:0 = 运行全部测试) |
| 并行浏览器实例数量(2–10) |
| 覆盖 |
| 重复运行测试文件/套件N次 |
Log Level
日志级别
- Use when debugging (maximum output)
--logLevel=trace - Use default () when confirming tests pass (less noise)
info
bash
npx wdio --logLevel=trace --spec=test/specs/home.js- 调试时使用(输出最详细信息)
--logLevel=trace - 确认测试通过时使用默认值(,减少冗余输出)
info
bash
npx wdio --logLevel=trace --spec=test/specs/home.jsBail
失败停止
bash
npx wdio --bail=1bash
npx wdio --bail=1Max Instances
最大并行实例数
bash
npx wdio --maxInstances=3bash
npx wdio --maxInstances=3Base URL
基础URL
Changes the base server used with relative paths (e.g., ).
browser.url('./homepage.html')bash
npx wdio --baseUrl=https://example.com/修改相对路径使用的基础服务器(例如,)。
browser.url('./homepage.html')bash
npx wdio --baseUrl=https://example.com/Isolating Individual Tests (Mocha)
隔离单个测试(Mocha)
Edit the test file temporarily to add or .
.only.skip临时编辑测试文件,添加或。
.only.skipRun only specific tests
仅运行特定测试
js
describe.only("Form Fields", function () { ... });
it.only("should submit form", function () { ... });js
describe.only("Form Fields", function () { ... });
it.only("should submit form", function () { ... });Skip specific tests
跳过特定测试
js
it.skip("should return -1 unless present", function () { ... });Remember to revert / changes after debugging.
.only.skipjs
it.skip("should return -1 unless present", function () { ... });调试完成后,请记得还原/的修改。
.only.skip