Giter Club home page Giter Club logo

diffy-behat's Introduction

Use diffy with behat

Usage

Here is an example how your behat integration could look like:

Feature: Diffy example
  Provide simple example how to use
  Diffy in Behat.

  @javascript
  Scenario: Create set of screenshots, send to Diffy and run comparison

    # Create screenshots from two pages and send them to Diffy
    Given I am on "/"
    Then I take screenshots for all breakpoints

    Given I am on "/wordpress"
    Then I take screenshots for all breakpoints

    Then Send screenshots to diffy with name "first test"

    # Create screenshots from two pages with different breakpoints and send them to Diffy
    Given I am on "/"
    When I resize window to "1200"
    Then I take screenshot

    Given I am on "/about-us"
    When I resize window to "600"
    Then I take screenshot
    Then Send screenshots to diffy with name "second test"

    # Create Diffy comparison between two sets of screenshots created in the previous steps of the test
    Then Create diffy comparison

Install dependencies

run composer install

Install docker

We are using docker for run selenium. If you already has own selenium installation just skip these steps.

Use this link to install docker:

https://docs.docker.com/engine/install/ubuntu/

Run selenium in docker

Run docker-compose -f docker/docker-compose.yml up

Configure behat settings

Edit ./behat.yml

Configure parametrs:

parameters:
      projectId: {diffyProjectID}
      apiKey: {diffyApiKey}
      screenshotsDir: screenshots
      breakpoints: [640, 1200]
      windowHeight: 2000

Where:

Parameter Description
projectId Project ID from Diffy
apiKey Api key from Diffy (You can get it on this page: https://app.diffy.website/#/keys)
screenshotsDir Path to temporary folder where will be stored screenshots
breakpoints Breakpoints array (they should be available in the Diffy project)
windowHeight Height of screenshots

Configure mink extension:

Behat\MinkExtension\Extension:
      base_url: https://diffy.website
      goutte: ~
      javascript_session: selenium2
      browser_name: chrome
      selenium2:
        wd_host: "http://localhost:4444/wd/hub"

Where:

Parameter Description
base_url Base URL of the tested site
browser_name chrome - by default in docker-compose.yml installed only chrome browser. But you can uncomment other browsers.
selenium2:wd_host If you are using own selenium installation, please specify here your selenium url.

Run behat test

Run php ./bin/behat

After the test is being completed, two screenshots one comparison will be created on Diffy.

Down docker with selenium

Run docker-compose -f docker/docker-compose.yml down

diffy-behat's People

Contributors

svipsa avatar ygerasimov avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

svipsa samiullah

diffy-behat's Issues

Getting error when running default tests from this repo

Hi , i cloned this repo and did composer.install
Added my project id and API key
When running behat tests I get following error
hen I take screenshots for all breakpoints # DiffyContext::iTakeScreenshotsForAllBreakpoints() Then Send screenshots to diffy with name "first test" # DiffyContext::sendScreenshots() Data list contain not valid data. Each item of list should be array with items: ['file'=> '', 'url'=> '', 'breakpoint'=> '']

Need help for same

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.