# 自动化 · 文档 | Lagsmith

> 通过 XCTest UI 测试、lagsmith 命令行工具、lagsmith:// 链接和本地 HTTP API 控制 Lagsmith。

Source: https://lagsmith.com/zh/docs/automation

# 自动化

你在菜单栏中能做的一切，也都可以通过测试和脚本完成，因此慢速网络和离线测试也能在 CI 中运行。

## XCTest UI 测试辅助工具

在启动 App 之前通过 UI 测试设置它的网络，让每个测试都从所需的网络条件开始。

## 命令行：`lagsmith`

`lagsmith` 命令行工具可以从终端和 CI 脚本控制 Lagsmith。

`lagsmith run` 以单独的网络条件运行一条命令：只有该命令及其启动的进程会受到影响，命令结束后它的规则就会被移除。它接受与 `lagsmith set` 相同的选项，只是不需要 `--app`。[为 Python 脚本限速](https://lagsmith.com/zh/throttle-python-script-mac)。

```
lagsmith run --preset 3G -- python3 fetch.py
lagsmith run --failure timeout --hosts api.example.com -- pytest
```

## URL scheme：`lagsmith://`

打开 `lagsmith://` 链接，即可在任何能打开 URL 的地方控制 Lagsmith。

## HTTP API

Lagsmith 在 `127.0.0.1` 上提供本地 HTTP API，只能从你的 Mac 访问。

## AI 智能体

AI 编程智能体可以使用内置的 MCP 服务器。[MCP 设置](https://lagsmith.com/zh/docs/mcp)。

[下载 Mac 版](https://downloads.lagsmith.com/Lagsmith.dmg)

免费下载，含 14 天 Pro 试用。无需账户，无需银行卡。macOS 13 Ventura 或更高版本。
