定制 devchid/wpselenium 二次开发

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

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

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 init or adding a composer.json file.

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 .

example_login

Note:-

  1. 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.
  2. 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

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 我们能提供哪些服务?
定制开发 / 二次开发

基于 devchid/wpselenium 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-09-10