定制 jhoopes/laravel-selenium-driver 二次开发

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

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

jhoopes/laravel-selenium-driver

Composer 安装命令:

composer require jhoopes/laravel-selenium-driver

包简介

A package wrapper that works with selenium to test laravel applications in the browser, inspired from laracasts integrated package

README 文档

README

This package is designed around much of what the integrated package from Jeffery Way. It emulates much of the API from Laravel's existing testing packages for PHP Unit.

Set Up / Install

  1. Download the latest version of selenium 2 from here: https://github.com/SeleniumHQ/selenium/releases
  2. If you are going to be using firefox as your browser, running the selenium server is all you need.
  3. After you have downloaded those 2 things, install the package via composer

Configuration and setting up your first test

  • This package uses a selenium .env file for certain settings. You can create this file based on the sample below

Sample .env.seleniumConfig


# Application environment
APP_ENV=testing

# Which browser you'd like to use
BROWSER=chrome 

# The base url for the application on your local machine
BASE_URL=http://test.dev 

# Whether or not you'd like to boot up a laravel application during your testing
#   this is so you can use things like "seeInDatabase"
USE_LARAVEL=true

#If you booted laravel, set this to 1 if you'd like your database connection to be auto migrated
MIGRATE=0

#If you booted laravel, set this to 1 if you'd like your database connection to be auto seeded
SEED=0

#OPTIONAL:  You can optionally set the window's witdth and height with these values.  Be sure that they are integers
WINDOW_WIDTH=1250
WINDOW_HEIGHT=900
  • This configuration file is used in consort with the phpunit.xml file.
    • For example, to connect to the database through phpunit and working with laravel, you will need to set your database configuration information there.
    • Or make sure the database configuration setup in your normal .env file.
    • e.g. For when using homestead, this is what I would put in your phpunit.xml file
   <?xml version="1.0" encoding="UTF-8"?>
   <phpunit backupGlobals="false"
            backupStaticAttributes="false"
            bootstrap="bootstrap/autoload.php"
            colors="true"
            convertErrorsToExceptions="true"
            convertNoticesToExceptions="true"
            convertWarningsToExceptions="true"
            processIsolation="false"
            stopOnFailure="false">
       <testsuites>
           <testsuite name="Application Test Suite">
               <directory>./tests/</directory>
           </testsuite>
       </testsuites>
       <filter>
           <whitelist>
               <directory suffix=".php">app/</directory>
           </whitelist>
       </filter>
       <php>
           <env name="APP_ENV" value="testing"/>
           <env name="CACHE_DRIVER" value="array"/>
           <env name="SESSION_DRIVER" value="array"/>
           <env name="QUEUE_DRIVER" value="sync"/>
           <env name="DB_CONNECTION" value="mysql"/>
           <env name="DB_HOST" value="127.0.0.1:33060"/>
           <env name="DB_DATABASE" value="yourDatabase" />
           <env name="DB_USERNAME" value="homestead" />
           <env name="DB_PASSWORD" value="secret" />
       </php>
   </phpunit>
  • If you are using Laravel Valet, Your database should be local to your host, and so phpunit should be able to connect to it via the normal .env file
  • Once you have the configuration set up, please see examples to further understand how to set up your tests.

Writing tests

  • Additional documentation is forthcoming, but I wanted to note that it is important to remember that selenium will be running a live session inside of your browser on the application.
    • Because of this, your phpunit session (if using laravel) when running tests will be entirely different than the one running within the browser.
    • Keep this in mind when performing "session" items within your test code and not running it within the web browser

Running Tests

  • The first step before running tests is that you will need to start your selenium server
    • To do that, simply run java -jar /path/to/selenium-server/selenium-server.jar
  • To run your tests, you can run an entire directory or a single class with acceptance tests.
  • e.g.
phpunit tests/acceptance
phpunit tests/acceptance/ExampleTest.php
  • What should occur is that your web browser opens, and runs through the acceptance test

Documentation

  • Documentation is currently in the works.
  • To see what is in the current API look through the traits directory for function names.

Future features

  • A more fleshed out API
  • Additional helpers for JS widgets like selectize, dropzone, etc.
  • Tests for this package
  • Better documentation

jhoopes/laravel-selenium-driver 适用场景与选型建议

jhoopes/laravel-selenium-driver 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.57k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2016 年 09 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 jhoopes/laravel-selenium-driver 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 jhoopes/laravel-selenium-driver 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-09-07