定制 playwright-php/accessibility 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

playwright-php/accessibility

最新稳定版本:v1.0.0

Composer 安装命令:

composer require --dev playwright-php/accessibility

包简介

Accessibility testing for Playwright PHP using axe-core. Check web pages for WCAG compliance.

README 文档

README

Playwright PHP

  PHP Version   CI   Release   License

Playwright PHP - Accessibility

Important

This package is experimental. Its API may still change before the upcoming 1.0 release.

Curious or interested? Try it out, share your feedback, or ideas!

Perform real accessibility audits on web pages using Playwright PHP and axe-core,
checking for WCAG, ARIA, color contrast, and best-practice compliance.

Installation

This package relies on Playwright PHP - to install it, follow the instructions in Playwright PHP’s installation guide.

composer require --dev playwright-php/accessibility

Usage

Basic Analysis

use Playwright\Accessibility\AxeBuilder;

$builder = new AxeBuilder($page);
$results = $builder->analyze();

if ($results->hasViolations()) {
    foreach ($results->violations as $violation) {
        echo "{$violation->id}: {$violation->help}\n";
    }
}

PHPUnit Integration

use Playwright\Accessibility\AssertsAccessibility;

class MyTest extends TestCase
{
    use AssertsAccessibility;

    public function testPageIsAccessible(): void
    {
        $page->goto('https://example.com');
        $this->assertIsAccessible($page);
    }
}

Advanced Configuration

// Scope to specific regions
$builder->within('#main-content')->analyze();

// Filter by WCAG level
$builder->withTags([WcagTag::WCAG_2_1_AA])->analyze();

// Disable specific rules
$builder->withoutRules([RuleId::COLOR_CONTRAST])->analyze();

// Exclude elements
$builder->exclude('.advertisement')->analyze();

License

This package is released by the Playwright PHP project under the MIT License. See the LICENSE file for details.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-13