手动设置
本页面介绍直接驱动 tauri-driver,无需 @wdio/tauri-service。如果你不使用 Node.js、偏好 Selenium,或将 WebDriver 集成到自定义测试框架中,请使用它。对于大多数项目来说,使用服务更为简单 —— 它会自动处理下面的所有内容,并且还支持 macOS。请参阅 [WebDriver 概览] 以开始使用它。
🌐 This page covers driving tauri-driver directly, without the @wdio/tauri-service. Reach for it if you are not
using Node.js, prefer Selenium, or are integrating WebDriver into a custom test harness. For most projects the service
is the easier path — it automates everything below and additionally supports macOS. See the WebDriver overview to get
started with it.
在直接驱动 tauri-driver 时,桌面端仅支持 Windows 和 Linux,因为 macOS 没有可用的 WKWebView 驱动工具。iOS 和 Android 可以通过 Appium 2 工作,但该过程目前尚未优化。
🌐 When driving tauri-driver directly, only Windows and Linux are supported on desktop, as macOS has no WKWebView driver
tool available. iOS and Android work through Appium 2, but the process is not currently streamlined.
🌐 System Dependencies
通过运行以下命令安装最新的 tauri-driver 或更新现有安装:
🌐 Install the latest tauri-driver or update an existing installation by running:
cargo install tauri-driver --locked因为我们目前使用平台本地的 WebDriver 服务器,所以在支持的平台上运行 tauri-driver 有一些要求。
🌐 Because we currently utilize the platform’s native WebDriver server, there are some requirements for running
tauri-driver on supported platforms.
我们在 Linux 平台上使用 WebKitWebDriver。通过运行 which WebKitWebDriver 命令检查这个二进制文件是否已经存在,因为某些发行版将其与常规的 WebKit 包打包在一起。其他平台可能有单独的包,比如基于 Debian 的发行版中的 webkit2gtk-driver。
🌐 We use WebKitWebDriver on Linux platforms. Check if this binary exists already by running the which WebKitWebDriver command as
some distributions bundle it with the regular WebKit package. Other platforms may have a separate package for them, such
as webkit2gtk-driver on Debian-based distributions.
Windows
Section titled “Windows”请确保下载与应用构建和测试所使用的 Windows Edge 版本匹配的 [Microsoft Edge 驱动程序] 版本。这几乎总是应该是最新稳定版本,适用于最新的 Windows 安装。如果两个版本不匹配,你可能会在 WebDriver 测试套件尝试连接时遇到挂起的问题。
🌐 Make sure to grab the version of Microsoft Edge Driver that matches your Windows Edge version that the application is being built and tested on. This should almost always be the latest stable version on up-to-date Windows installs. If the two versions do not match, you may experience your WebDriver testing suite hanging while trying to connect.
你可以使用 msedgedriver-tool 下载合适的 Microsoft Edge 驱动程序:
🌐 You can use the msedgedriver-tool to download the appropriate Microsoft Edge Driver:
cargo install --git https://github.com/chippers/msedgedriver-tool& "$HOME/.cargo/bin/msedgedriver-tool.exe"下载内容包含一个名为 msedgedriver.exe 的二进制文件。tauri-driver 会在 $PATH 中查找该二进制文件,因此请确保它在路径中可用,或者在 tauri-driver 上使用 --native-driver 选项。你可能希望在 CI 设置过程中自动下载它,以确保 Windows CI 计算机上的 Edge 和 Edge Driver 版本保持同步。关于如何执行此操作的指南可能会在以后添加。
🌐 The download contains a binary called msedgedriver.exe. tauri-driver looks for that binary in the $PATH so make
sure it’s either available on the path or use the --native-driver option on tauri-driver. You may want to download this automatically as part of the CI setup process to ensure the Edge, and Edge Driver versions
stay in sync on Windows CI machines. A guide on how to do this may be added at a later date.
🌐 Example Applications
下面是分步指南,展示如何创建一个经过 WebDriver 测试的最小示例应用。
🌐 Below are step-by-step guides to show how to create a minimal example application that is tested with WebDriver.
如果你想查看指南的结果并浏览一个使用该指南的完整最小代码库,你可以查看 https://github.com/tauri-apps/webdriver-example。
🌐 If you prefer to see the result of the guide and look over a finished minimal codebase that utilizes it, you can look at https://github.com/tauri-apps/webdriver-example.
持续集成 (CI)
Section titled “持续集成 (CI)”🌐 Continuous Integration (CI)
上述示例也附带了一个用于 GitHub Actions 测试的 CI 脚本,但你可能仍然会对下面的 WebDriver CI 指南感兴趣,因为它对概念进行了更多解释。
🌐 The above examples also comes with a CI script to test with GitHub Actions, but you may still be interested in the below WebDriver CI guide as it explains the concept a bit more.
Tauri 中文网 - 粤ICP备13048890号
Nodejs.cn 旗下网站