搜索分类、插件与代码仓

插件详情v3.2.0

webdriver

为 Dart 提供 WebDriver 绑定。支持 WebDriver JSON 接口和 W3C 规范。需要使用 WebDriver 远程服务器。

近 30 天下载
1140万
喜欢数
67
Pub 分数
130

安装插件

flutter pub add webdriver

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

webdriver 包为 Dart 提供了 WebDriver 绑定,通过 WebDriver JSON 接口和 W3C 标准实现自动化浏览器测试。它需要一个独立的 WebDriver 远程服务器才能运行,使 Dart 应用程序能够以编程方式控制浏览器。该包非常适合编写端到端测试,模拟不同浏览器和平台上的真实用户交互。它支持现代 Web 测试工作流程,并与 test 或 integration_test 等测试框架良好集成。

适合场景

  • 自动化浏览器测试
  • Web应用程序的端到端测试
  • 跨浏览器兼容性测试
  • 使用真实浏览器进行集成测试
  • CI/CD 流水线中的测试自动化

主要特点

  • 支持 WebDriver JSON 和 W3C 规范
  • 需要外部 WebDriver 服务器
  • 通过 Dart 实现浏览器自动化
  • 促进真实用户交互模拟
  • 与 Dart 测试框架集成

适合对象

  • Dart 开发人员进行 Web 测试
  • 使用 CI/CD 流水线的团队
  • 测试工程师自动化浏览器工作流
  • 需要跨浏览器验证的项目
  • 遵循 W3C WebDriver 标准的开发者

使用建议

  • 需要一个正在运行的 WebDriver 服务器(例如 Selenium Server)
  • 在没有设置的情况下,不适用于仅无头场景
  • 仅限浏览器自动化,不支持移动或原生UI测试
  • 依赖外部服务器的稳定性
  • 可能需要为安全环境进行额外配置

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

CI pub package package publisher

Provides WebDriver bindings for Dart. These use the WebDriver JSON interface, and as such, require the use of the WebDriver remote server.

Using package:webdriver

In your Dart code, you can use:

import 'package:webdriver/io.dart';

WebDriver driver = createDriver(...);

This will use by default the asynchronous, JSON wire spec implementation. You now can also use a synchronous version of WebDriver:

import 'package:webdriver/sync_io.dart';

final driver = createDriver(...);

This version of WebDriver supports both the JSON wire spec and W3C spec, allowing use with modern versions of Firefox. This defaults to the JSON wire spec, but can also be configured to use the W3C spec or even to try and automatically infer the spec during session creation:

final w3cDriver = createDriver(spec: WebDriverSpec.W3c);  // Use W3C spec.

final anyDriver = createDriver(spec: WebDriverSpec.Auto); // Infer spec.

Testing

Unfortunately using bazel with Dart libraries and Dart WebDriver is not yet supported. We hope to add this at some point, but for now pub still works.

As a consequence, running tests is a bit more complicated than we'd like:

  1. Launch a WebDriver binar(ies).

    First, bring up chromedriver / geckodriver. Other conforming WebDriver binaries should work as well, but we test against these:

    chromedriver --port=4444 --url-base=wd/hub --verbose
    geckodriver --port=4445
    

    ChromeDriver is used to test our JSON wire spec implementation, and geckodriver is used to test our W3C spec implementation.

    Synchronous tests are labeled as Chrome/Firefox. All async tests run exclusively against Chrome (as async, like ChromeDriver supports only the old JSON wire spec).

  2. Run a test. All files suffixed with _test.dart are tests.

    dart test test/path/to/the_test.dart -r expanded -p vm
    

    Or to run all tests:

    dart test -r expanded -p vm
    

    You should probably go get a coffee or something, this is gonna take a while.

所属分类

依赖

依赖清单 5 项

源码仓库

使用此插件的项目