devchid/wpselenium
Composer 安装命令:
composer require devchid/wpselenium
包简介
WPSelenium is a library that allows you to quickly get up and running testing your site with selenium and phpunit.
README 文档
README
WPSelenium is a library that allows you to quickly get up and running testing your site with selenium and phpunit.
WPSelenium is a library that quickly gets you up and running when you want to test your site using selenium and phpunit. It does this by installing and configuring phpunit, the selenium server, the php client webdriver (by facebook) and the correct drivers for the browser you want to test on. Once installed all you have to worry about is writing your selenium php tests.
WPSelenium also includes support for testing WordPress plugins and themes. It does this by providing WordPress specific hooks and configuration end points you can use.
Usage
Operand browser is required Usage: vendor/bin/wpselenium <browser> [options] Example: vendor/bin/wpselenium chrome --type wordpress Operands: <browser> Brower you want to test on. Chrome and Firefox supported by default. See documenation if you want to add others. Options: --type <arg> The type of site you are testing. e.g --type wordpress --loglevel <arg> Console loglevel - info, warn, error, debug. -?, --help Show this help and quit.
Getting Started
Requirements
In order to run WPSelenium you will need to have the following installed
- Java (and make sure its on your system path. Type java in your terminal or command line window to check)
- Php >= 7.2
- Composer
- Chrome or Firefox or any other browser you want to test on (given you have the drivers)
1. Install
To get started with WPselenium install it using composer using the following command:-
composer require --dev devchid/wpselenium
Note:- This command assumes that the working directory you are running it from is a composer project. If not, you can easily make it one buy running
composer initor adding acomposer.jsonfile.
Note:- WPSelnenium curently downloads the 76.0.3809.126 chrome drivers and the 0.24 firefox gecko drivers. If your browser needs a newer or older vesion of a driver (you will get error suggesting this if unsure) please specify an updated download url for the driver in the wpselenium.xml config file. Please see the documentation site for more details.
2. Configure
Having installed wpselenium you need to create a wpselenium.xml config file. This file should be in the same location as you composer.json file.
Below if a very basic sample configuration to get you going.
<wpselenium> <siteUrl>http://localhost:3000</siteUrl> <phpunit bootstrap="vendor/autoload.php"> <testsuites> <testsuite name="WPSelenium Sample Tests"> <file>vendor/devchid/wpselenium/src/Sample/SampleTest.php</file> </testsuite> </testsuites> </phpunit> </wpselenium>
You will need to replace siteUrl, with you own site you are trying to test.
Note:- The WPSelenium.xml can embed the phpunit config, using the phpunit endpoint (like above). This specified config is then loaded when testing your project with phpunit. However if you want to create your own phpunit config file (phpunit.xml) you can also do this (and not include it here). See documentation site for more details.
3. Run Tests
After this previous step you are in essence done. You can run the following command from the same location as your composer.json file (were browser_driver can either be chrome or firefox)
/vendor/bin/wpselenium [brower_driver]
If everything was configured properly you should see a browser window opened up to your site's home page (Example below). This window will close after about 10s .
Note:-
- On first run WPSelenium will download the required files and configure those appropriately. This means your first run will take a little bit long to start testing your site.
- WPSelenium currently comes with only support for chrome and firefox. However if there is another browser you want to test you can specify the link to the browser drivers in you wpselenium config. From there you can rerun the above command using the specified name of your driver (I.e /vendor/bin/wpselenium opera). See Configuration section for more details.
If you managed to see the home page of your site like the above example, everything is set up correct. You can now go ahead and write your tests.
WordPress Support
WPSelenium comes with inbuilt support for WordPress sites. This is particularly useful when building custom plugins or themes that might require UI testing. Please see documentation site for more details.
Documentation
The WPSelenium library is fully documented at https://wpselenium.centridsol.tech/. If you think of anything else that should be documented that's not there, please do give a shout.
Contributing
WPSelenium is an opensource project and contributions are valued.
If you are contributing a bug fix, please create a pull request with the following details
- The problem/bug you are addressing
- The version of WPSelenium the fix is for
- How you tested the fix
If it's a new feature, please add it as a issue with the label enhancement, detailing the new feature and why you think it's needed. Will discuss it there and once it's agreed upon you can create a pull request with the details highlighted above.
Authors
- Chido Warambwa - Initial Work - chidow@centridsol.tech
License
This project is licensed under the MIT License - see the LICENSE file for details
devchid/wpselenium 适用场景与选型建议
devchid/wpselenium 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 57 次下载、GitHub Stars 达 4, 最近一次更新时间为 2019 年 09 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「phpunit」 「composer」 「facebook」 「selenium」 「webdrivers」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 devchid/wpselenium 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 devchid/wpselenium 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 devchid/wpselenium 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
HiDev plugin for PHPUnit
Testing Suite For Lumen like Laravel does.
A cli tool which generates unit tests.
This composer plugin enables installation of GravityForms WordPress plugin and its addons.
PHPUnit DbUnit Native Array-based Fixtures
统计信息
- 总下载量: 57
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-09-10