jeromeerasmus/selenium-automate 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

jeromeerasmus/selenium-automate

Composer 安装命令:

composer require jeromeerasmus/selenium-automate

包简介

PHP bindings for BrowserStack Local

README 文档

README

This library is to assist Selenium and Browserstack Continious Integration with for BeHat testing in native PHP. There are three ways to setup and run the tests:

  • Running Selenium tests locally
  • Running Selenium tests in Docker (with bitbucket Pipelines)
  • Running the Browserstack

The library can be installed into your PHP project using the below composer command which will install the library from Packagist.

require jeromeerasmus/selenium-automate:dev-master

Running Selenium tests locally

Requirements

Requires Firefox v39.0 with Selenium v1.4.0 You can download the correct version of Firefox here: https://ftp.mozilla.org/pub/firefox/releases/39.0/ Remember to turn automatic updates off Firefox as soon as it is installed.

Setup

First grab the latest JRE and install it on your machine as Selenium runs on the JRE. You first need to install selenium on your machine in order to run the Selenium tests. On OSX this should be as easy as:

brew install selenium-server-standalone

Next configure your composer.json file with the below commands to be able to run the Selenium tests locally.

"scripts": {
    "start-selenium": "vendor/bin/manager start",
    "run-selenium": "vendor/bin/behat --config=conf.selenium.yml -f pretty -o std -f junit -o results"
  }

Next, copy dist.conf.selenium.yml and dist.conf.browserstack.yml to conf.selenium.yml and conf.browserstack.yml and then edit them to match your project specifications. You will only need to edit the base_url field for this config.

Executing the tests

Then perform the below: First start Selenium in a new terminal window. Leave it running.

composer start-selenium

Then open up a new terminal window and run the sample tests with:

composer run-selenium

Running Selenium tests in Docker (with bitbucket Pipelines)

This configuration allows you to run your tests with Docker.

Requirements

Docker and Docker Compose installed on your machine. (of course)

Setup

In the root folder perform the below steps:

  1. Create a Dockerfile with the below contents:

    FROM mycrm/base
    
    COPY . /var/specs
    WORKDIR /var/specs
    
    # Config
    ENTRYPOINT ["vendor/bin/behat"]
    
  2. Create a docker-compose file with the below contents:

    version: '2'
    services:
      specs:
        build: .
        volumes:
          - .:/var/specs
        container_name: mycrm-specs
        links:
         - firefox-server
        environment:
          BEHAT_PARAMS: '{"extensions" : {"Behat\\MinkExtension" : {"base_url" : "https://it.wikipedia.org/"}}}'
    
      firefox-server:
        container_name: mycrm-specs-server
        #image: selenium/standalone-firefox-debug:2.53.0
        image: selenium/standalone-firefox:2.53.0
        ports:
          - "4444:4444"
          - "5900:5900"
    

Now you can execute the below command which will build the Docker images and run the tests.

docker-compose -f docker-compose.yml run --rm specs  --config=conf.selenium-docker.yml

Setup Bitbucket Pipelines script

You can run the tests on Bitbucket Pipelines by creating the below bitbucket-pipelines.yml file in your root folder. You can use the below script for the contents.

pipelines:
  default:
    - step:
        image: jeromeerasmus/docker-alpine-php-composer:7.0
        services:
          - docker
        script: 
          - composer install
          - docker-compose -f docker-compose.yml run --rm specs  --config=conf.selenium-docker.yml

Selenium Automate (with Browserstack)

Behat Integration with BrowserStack.

Setup

  • Clone the repo into your project root
  • Cd into the repo folder on your local machine
  • Install dependencies composer install
  • First copy dist.conf.selenium.yml and dist.conf.browserstack.yml to conf.selenium.yml and conf.browserstack.yml and then edit them to match your project specifications.
  • Then copy the dist.env file to .env and update with your browserstack keys

Creating the capabilities config

You define a capabilities configuration file to explicity set which browsers / devices / operating systems you will test on. To get the full updated list of capabilities from browserstack run the following command:

composer capabilities

This will bring down an exhaustive list of ALL capabilities. Look through the list and pick out the capabilities you want to run your tests on. You can use these capabilities to update your .yml files

Once the above is done correctly you will be able to run your tests.













## Running the Selenium tests 
First grab the latest JRE and install it on your machine as Selenium runs on the JRE. You first need to install selenium on your machine in order to run the Selenium tests. On OSX this should be as easy as: 

brew install selenium-server-standalone



Then perform the below:
First start Selenium 

composer start-selenium


Then run the test 

composer run-selenium


## Running the Browserstack tests 
To run a test in browserstack execute 

composer run-bs



### Manufaturing tests by the dozen
The below is some basic workflow tips to save you some time. The below is not essential to running your tests.

Scaffold a BeHat project structure and key files

./bin/behat --init


After writing your .feature file run the below to create the code snippet and auotmoatically place it into the 
Feature context file

./bin/behat --append-snippets


## Notes
* You can view your test results on the [BrowserStack Automate dashboard](https://www.browserstack.com/automate)
* To test on a different set of browsers, check out  [platform configurator](https://www.browserstack.com/automate/php#setting-os-and-browser)
  

jeromeerasmus/selenium-automate 适用场景与选型建议

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2018-08-26