viewpoint-test
Test framework for browser automation with Playwright-style assertions.
This is the main crate for the Viewpoint browser automation framework. It provides everything you need to write browser tests in Rust.
Features
TestHarnessfor easy test setup with automatic cleanup- Fluent async assertions with auto-waiting
- Element and page assertions
- Fixture scoping (test, module, shared)
- Re-exports
viewpoint-corefor convenience
Quick Start
[]
= "0.2"
= { = "1", = ["macros", "rt-multi-thread"] }
use ;
async
Assertions
use ;
use Duration;
// Element assertions
expect.to_be_visible.await?;
expect.to_be_hidden.await?;
expect.to_have_text.await?;
expect.to_contain_text.await?;
expect.to_have_attribute.await?;
expect.to_have_class.await?;
expect.to_be_enabled.await?;
expect.to_be_disabled.await?;
expect.to_be_checked.await?;
expect.to_have_count.await?; // Exactly 3 matching elements
// Page assertions
expect_page.to_have_url.await?;
expect_page.to_have_url_containing.await?;
expect_page.to_have_title.await?;
// Negation - prepend .not()
expect.not.to_be_visible.await?;
// Custom timeout
expect
.timeout
.to_be_visible
.await?;
Soft Assertions
Collect multiple assertion failures without stopping test execution:
use SoftAssertions;
async
TestHarness Configuration
use TestHarness;
use Duration;
// Default configuration
let harness = new.await?;
// Custom configuration
let harness = builder
.headless // Show browser window for debugging
.timeout // Custom timeout
.build
.await?;
// Fixture Scoping for faster tests
// Test-scoped (default): New browser per test
let harness = new.await?;
// Module-scoped: Share browser, fresh context per test
let harness = from_browser.await?;
// Shared context: Share context, fresh page per test
let harness = from_context.await?;
ARIA Accessibility Testing
Verify accessibility tree structure with ARIA snapshots:
use ;
async
Requirements
- Rust 1.85+
- Chromium browser (set
CHROMIUM_PATHor have it in PATH)
License
MIT