搜尋分類、套件與程式碼儲存庫

套件詳情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 應用程式能以程式化方式控制瀏覽器。此套件非常適合撰寫端對端測試,模擬跨不同瀏覽器與平台的真實使用者互動。它支援現代網頁測試工作流程,並與 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 項

原始碼儲存庫

使用此套件的專案