WebDriver
WebDriver 是一种标准化接口,用于与主要用于自动化测试的 Web 文档进行交互。Tauri 通过利用跨平台封装器 tauri-driver
下的原生平台的 WebDriver 服务器来支持 WebDriver 接口。在桌面上,由于 macOS 没有可用的 WKWebView 驱动程序工具,因此仅支持 Windows 和 Linux。iOS 和 Android 通过 Appium 2 工作,但该流程目前尚未简化。
¥WebDriver is a standardized interface to interact with web documents primarily intended for automated testing.
Tauri supports the WebDriver interface by leveraging the native platform’s WebDriver server underneath a
cross-platform wrapper tauri-driver
. On desktop, only Windows and Linux are supported due to macOS not having
a 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
我们在 Linux 平台上使用 WebKitWebDriver
。检查此二进制文件是否已存在(命令 which WebKitWebDriver
),因为某些发行版将其与常规 WebKit 包打包在一起。其他平台可能有单独的软件包,例如基于 Debian 的发行版上的 webkit2gtk-driver
。
¥We use WebKitWebDriver
on Linux platforms. Check if this binary exists already (command which WebKitWebDriver
) 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
确保获取与正在构建和测试应用的 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.exe
的二进制文件。tauri-driver
在 $PATH
中查找该二进制文件,因此请确保它在路径上可用或在 tauri-driver
上使用 --native-driver
选项。你可能希望在 CI 设置过程中自动下载此文件,以确保 Edge 和 Edge Driver 版本在 Windows CI 机器上保持同步。稍后可能会添加有关如何执行此操作的指南。
¥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/chippers/hello_tauri。
¥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/chippers/hello_tauri.
持续集成(CI)
¥Continuous Integration (CI)
上面的示例还附带了一个 CI 脚本,可以使用 GitHub Actions 进行测试,但你可能仍然对下面的 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 v2.4 中文网 - 粤ICP备13048890号
Nodejs.cn 旗下网站