2017 © Pedro Peláez
 

library pigeon-webkit

image

etsy/pigeon-webkit

  • Wednesday, April 20, 2016
  • by bertrandmoulard
  • Repository
  • 3 Watchers
  • 4 Stars
  • 7,037 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 10 Versions
  • 2 % Grown

The README.md

pigeon

Functional testing tool for PHP built on top of capybara-webkit, (*1)

Build Status, (*2)

Installation

The following instructions outline installation using Composer. If you don't have Composer, you can download it from https://getcomposer.org/, (*3)

  • Install QT following these [instructions] (https://github.com/thoughtbot/capybara-webkit/wiki/Installing-Qt-and-compiling-capybara-webkit).
  • Install capybara-webkit
$ gem install capybara-webkit -v "1.8.0"

or, (*4)

$ sudo gem install capybara-webkit -v "1.8.0"
  • Run the following command:
$ php composer.phar global require etsy/pigeon-webkit:dev-master

How it works

capybara-webkit provides a headless web browser (built on QT Webkit). When the browser starts, it opens up a port to accept commands. Pigeon Webkit starts the browser, opens a TCP connection to that port and sends commands to the browser to "drive" it and run assertions., (*5)

FunctionalPigeon is extending CapybaraWebkitDriver, which is an implementation of Behat Mink's [DriverInterface] (https://github.com/minkphp/Mink/blob/master/src/Behat/Mink/Driver/DriverInterface.php). As a result, most of the methods defined by the interface are available. The ones that are not implemented throw an UnsupportedException., (*6)

The css to xpath translation is handled by [the Symfony CssSelector component] (http://symfony.com/doc/current/components/css_selector.html), (*7)

Usage

$pigeon = new PigeonWebkit\FunctionalPigeon();
$pigeon->visit("https://etsy.com");
print_r($pigeon->body()); // HTML content of etsy.com
$pigeon->click("a#sign-in"); // opens the sign in modal
// ...etc

By default, Pigeon Webkit accepts css selectors. But it also has a xpath mode., (*8)

$pigeon->setXPathMode(true);
$pigeon->visit("https://etsy.com");
$pigeon->click("//a[@id='sign-in']");

Example usage with the [kahlan] (https://github.com/crysalead/kahlan) testing framework, (*9)

<?php

use PigeonWebkit\FunctionalPigeon;

describe("Visiting a URL", function() {
  before(function() {
    $this->p = new FunctionalPigeon();
  });

  it("loads the page", function() {
    $this->p->visit("https://etsy.com");
    expect($this->p->body())->toContain("Shop directly from people around the world.");
  });
});

For more examples, take a look at the specs for FunctionalPigeon and its base class, CapybaraWebkiDriver., (*10)

Some of the available methods, (*11)

  reset
  visit
  getCurrentUrl
  reload
  forward
  back
  setRequestHeader
  getResponseHeaders
  setCookie
  getCookie
  getStatusCode
  getContent
  find
  getTagName
  getText
  getHtml
  getOuterHtml
  getAttribute
  getValue
  setValue
  check
  uncheck
  isChecked
  selectOption
  isSelected
  submitForm
  click
  isVisible
  executeScript
  evaluateScript
  getScreenshot

The Versions

20/04 2016

dev-master

9999999-dev

  Sources   Download

The Requires

 

The Development Requires

06/04 2016

dev-patching_core_functions

dev-patching_core_functions

  Sources   Download

The Requires

 

The Development Requires

05/04 2016

0.1.5

0.1.5.0

  Sources   Download

The Requires

 

The Development Requires

04/04 2016

0.1.4

0.1.4.0

  Sources   Download

The Requires

 

The Development Requires

04/04 2016

dev-multiple_gem_paths

dev-multiple_gem_paths

  Sources   Download

The Requires

 

The Development Requires

30/03 2016

0.1.3

0.1.3.0

  Sources   Download

The Requires

 

The Development Requires

02/12 2014

0.1.2

0.1.2.0

  Sources   Download

The Requires

 

19/11 2014

0.1.1

0.1.1.0

  Sources   Download

The Requires

 

11/11 2014

0.1.0

0.1.0.0

  Sources   Download

The Requires

 

11/11 2014

v0.1-alpha

0.1.0.0-alpha

  Sources   Download

The Requires