Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding MinkPhantomJSDriver to the documentation #71

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ ALLSPHINXOPTS = -c . -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " livehtml to see the changes done to documentation real time in your local machine"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
Expand Down
4 changes: 2 additions & 2 deletions guides/drivers.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Drivers
=======
Official Drivers
======================

How does Mink provide a consistent API for very different browser library
types, often written in different languages? Through drivers! A Mink driver
Expand Down
11 changes: 11 additions & 0 deletions guides/third-party-drivers.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Third party Drivers
======================

Thanks to the ``Behat\Mink\Driver\DriverInterface`` interface, anyone can create a driver.

Drivers that have implemented the mentioned interface and respect the driver test suite:

.. toctree::
:maxdepth: 1

/third-party-drivers/phantomjs.rst
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, the third-party drivers could be a section at the end of the drivers page instead of a separate page containing only the list, which has a single element for now.
This could be changed in the future if we have tens of third-party drivers, but I doubt it will be the case.

4 changes: 3 additions & 1 deletion index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ The recommended way to install Mink with all its dependencies is through

For local installations of composer you must call it like this:
``$ php composer.phar require behat/mink`` .
In this case you must use the different call
In this case you must use the different call
``php composer.phar`` everywhere instead of the simple command ``composer``.

Everything will be installed inside ``vendor`` folder.
Expand All @@ -54,6 +54,7 @@ Finally, include Composer autoloading script to your project:
- SeleniumDriver - ``behat/mink-selenium-driver``
- SahiDriver - ``behat/mink-sahi-driver``
- WUnitDriver - ``behat/mink-wunit-driver``
- PhantomJSDriver - ``jcalderonzumba/mink-phantomjs-driver`` (third-party driver)

If you're newcomer or just don't know what to choose, you should probably
start with the GoutteDriver and the Selenium2Driver (you will be able
Expand All @@ -73,6 +74,7 @@ Learn Mink with the topical guides:
guides/manipulating-pages
guides/interacting-with-pages
guides/drivers
guides/third-party-drivers
guides/managing-sessions
contributing

Expand Down
85 changes: 85 additions & 0 deletions third-party-drivers/phantomjs.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
PhantomJSDriver
Copy link
Member

@stof stof Nov 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should be maintaining the doc for third-party drivers ourselves. You are the one knowing the driver and so you should be maintaining its doc.
The list of third-party drivers should have external links to your doc instead.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have a good point here, i'll create a phantomjsdriver.readthedocs.org page with the Driver info and link it here then.
I already have a gastonjs.readthedocs.org documentation so it makes senses to have a similar doc site for phantomjsdriver.
I'll update the PR once the new doc page is up and running.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it is small, you could also use github itself to host the documentation (write it in markdown in this case though, as their rST renderer is not as good as their markdown one) (putting the doc in the /docs folder of the repo for instance)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, for the moment is small and mostly everything that i have written in this PR is contained in the README.md of the repo.

======================

PhantomJSDriver provides a bridge for the `PhantomJS`_ headless browser, it uses native `APIs`_ to interact with the browser which makes it generally faster than `Selenium2 (webdriver)`_.

If you want to use a headless browser in your automation tests, with PhantomJSDriver you can.

Installation
------------

PhantomJSDriver is available through Composer:

.. code-block:: bash

$ composer require jcalderonzumba/mink-phantomjs-driver

In order to talk with phantomjs, you must install and configure it
first:

1. Download the phantomjs browser from the `project website`_.

2. Install PhantomJSDriver via Composer.

3. Run the browser with the following command:

.. code-block:: bash

$ phantomjs --ssl-protocol=any --ignore-ssl-errors=true vendor/jcalderonzumba/gastonjs/src/Client/main.js 8510 1024 768 2>&1 >> /tmp/gastonjs.log &

.. tip::

The PhantomJSDriver relies on the `GastonJS`_ project to talk to phantomjs, this means you can do more things that are outside of the scope of the Mink Driver interface.

The testsuite of the driver is still triggering some failures because of bugs in phantomJS or in GastonJS that need to be fixed.

Usage
------------

That's it, now you can use PhantomJSDriver:

.. code-block:: php

$driver = new Zumba\Mink\Driver\PhantomJSDriver('http://localhost:8510');

PhantomJSDriver Feature Support
---------------------------------

====================== =================
Feature PhantomJSDriver
====================== =================
Page traversing Yes
Form manipulation Yes
HTTP Basic auth Yes
Windows management Yes
iFrames management Yes
Request headers access Yes
Response headers Yes
Cookie manipulation Yes
Status code access Yes
Mouse manipulation Yes
Drag'n Drop Yes
Keyboard actions Yes
Element visibility Yes
JS evaluation Yes
Window resizing Yes
Window maximizing No
====================== =================

FAQ
---------

1. Is this a selenium based driver?

**NO**, it has nothing to do with Selenium it's inspired on the `Poltergeist project`_.

2. What features does this driver implements?

**ALL** of the features defined in Mink DriverInterface. maximizeWindow is the only one not implemented since is a headless browser it does not make sense to implement it.

.. _PhantomJS: http://phantomjs.org/
.. _APIs: http://phantomjs.org/api/webpage/
.. _Selenium2 (webdriver): http://seleniumhq.org/
.. _project website: http://phantomjs.org/download.html
.. _GastonJS: http://gastonjs.readthedocs.io/en/latest/
.. _Poltergeist project: https://github.com/teampoltergeist/poltergeist