How to add a new page object?ΒΆ

Openjet uses a solution inspired by SensioLabs/PageObjectExtension, which provides an infrastructure to create pages that encapsulates all the user interface manipulation in page objects.

To create a new page object it is needed to add a service into one of the following files admin.xml/superAdmin.xml/crud.xml/ops.xml/sales.xml/groundManager.xml in src/Openjet/Behat/Resources/config/services/pages/ folder:

<service id="openjet.behat.page.PAGE_NAME" class="%openjet.behat.page.PAGE_NAME.class%" parent="openjet.behat.symfony_page" public="false" />

Note

There are some boilerplates for common pages, which you may use. The available parents are openjet.behat.page (FriendsOfBehat\PageObjectExtension\Page\Page) and openjet.behat.symfony_page (FriendsOfBehat\PageObjectExtension\Page\SymfonyPage). It is not required for a page to extend any class as pages are POPOs (Plain Old PHP Objects). Then you will need to add that service as a regular argument in context service. The simplest Symfony-based page looks like:

use FriendsOfBehat\PageObjectExtension\Page\SymfonyPage;

class LoginPage extends SymfonyPage
{
    public function getRouteName()
    {
        return 'openjet_airline_login';
    }
}