README 只给了抽象层,实际驱动(如 GoutteDriver)需自行安装对应后端包;示例中的 MyCustomDriver 需自己实现,不能直接运行;需先安装 Composer 才能执行安装命令
curl -sS https://getcomposer.org/installer | php
php composer.phar install 硬件要求按 README 说明
README 未说明,纯 PHP 库,无 GPU 或显存要求
PHP 浏览器模拟抽象层,用统一 API 驱动多种浏览器后端做 Web 测试
PHP 的浏览器模拟抽象层,统一封装多种无头浏览器驱动,让自动化测试和网页抓取代码不绑定具体实现。
核心能力
- 用统一 Session 与 Driver 接口抽象不同浏览器后端
- 支持注册多个命名会话并在同一测试中混用
- 通过 getPage 提供 findLink 等页面元素查找与点击
- 默认会话机制让无参 getSession 直接返回指定会话
- 可自定义 Driver 接入自有浏览器实现
容易踩的坑
内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README
- v1.13.01.13.0最新正式版2025-11-22 · 2025-11-22 12:21 UTC
New features:
- Added support for
symfony/css-selector8 - Improve PHPStorm's autocomplete for
DriverInterfacemethods
Testsuite:
- Added CI jobs for PHP 8.5
- Added support for
- v1.12.01.12.02024-10-30 · 2024-10-30 18:49 UTC
查看更新说明
Bug fixes:
- Explicitly mark method parameters with
nulldefault values as nullable to avoid deprecation notice in PHP 8.4
- Explicitly mark method parameters with
- v1.11.01.11.02023-12-09 · 2023-12-09 11:25 UTC
查看更新说明
New features:
- Added support for
symfony/css-selector7 - Added constants for the supported key modifiers
- Improved types to help static analysis
- Added parameter types for most methods
Testsuite:
- Added CI jobs for PHP 8.2 and 8.3
- Added static analysis in our CI
- Added support for
- v1.10.01.10.02022-03-28 · 2022-03-28 14:24 UTC
查看更新说明
New features:
- Added support for
symfony/css-selector6 - Added
WebAssert::elementAttributeNotExists
Removed:
- Removed support for PHP <7.2
- Removed support for
symfony/css-selector<4.4
Bug fixes:
- Fixed phpdoc for a bunch of arguments that were not properly marked as nullable
- Added support for
- v1.9.01.9.02021-10-11 · 2021-10-11 12:00 UTC
查看更新说明
New features:
- Fixed deprecation warnings on PHP 8.1
- Improved responsiveness of
Element::waitFor - Allowed selectors and replacements to be registered late
Removed:
- Removed support for PHP 5.3
Testsuite:
- Added CI jobs for PHP 8.0 and 8.1
用户点评
登录用户的真实使用记录,可按版本和硬件筛选共 0 条
还没有人点评。第一个说出真实体验的人最有价值。
Mink
Useful Links
- The main website with documentation is at https://mink.behat.org
- Official Google Group is at https://groups.google.com/group/behat
- Note on Patches/Pull Requests
Usage Example
<?php
use Behat\Mink\Mink,
Behat\Mink\Session,
Behat\Mink\Driver\GoutteDriver,
Behat\Mink\Driver\Goutte\Client as GoutteClient;
$startUrl = 'http://example.com';
// init Mink and register sessions
$mink = new Mink(array(
'goutte1' => new Session(new GoutteDriver(new GoutteClient())),
'goutte2' => new Session(new GoutteDriver(new GoutteClient())),
'custom' => new Session(new MyCustomDriver($startUrl))
));
// set the default session name
$mink->setDefaultSessionName('goutte2');
// visit a page
$mink->getSession()->visit($startUrl);
// call to getSession() without argument will always return a default session if has one (goutte2 here)
$mink->getSession()->getPage()->findLink('Downloads')->click();
echo $mink->getSession()->getPage()->getContent();
// call to getSession() with argument will return session by its name
$mink->getSession('custom')->getPage()->findLink('Downloads')->click();
echo $mink->getSession('custom')->getPage()->getContent();
// this all is done to make possible mixing sessions
$mink->getSession('goutte1')->getPage()->findLink('Chat')->click();
$mink->getSession('goutte2')->getPage()->findLink('Chat')->click();
Install Dependencies
$> curl -sS https://getcomposer.org/installer | php
$> php composer.phar install
Contributors
- Konstantin Kudryashov everzet [lead developer]
- Christophe Coevoet stof [lead developer]
- Alexander Obuhovich aik099 [lead developer]
- Other awesome developers