Skip to content

Simplify and speedup Elements #74

@spolischook

Description

@spolischook

For now we have two types of Elements, but they do the same things, and have the same purpose.
First of all Elements configuration must be unified.
I suggest to add names for Custom elements, and add classes for Inline Elements - it's only that needed for merge them.
So we will have the next configuration in behat.yml:

default:
  extensions:
    SensioLabs\Behat\PageObjectExtension:
      elements:
        Search form:
          selector: 'form#search'
          class: SensioLabs\Behat\PageObjectExtension\PageObject\InlineElement
        Navigation:
          selector: {'css': '.header div.navigation'}
          class: Acme\DemoBundle\Tests\Behat\Page\Element\Navigation

And configuration for Inline Elements:

<?php

namespace Page;

use SensioLabs\Behat\PageObjectExtension\PageObject\Page;

class Homepage extends Page
{
    // ...

    protected $elements = array(
        'Search form' => [
          'selector' => 'form#search',
          'class' => 'SensioLabs\Behat\PageObjectExtension\PageObject\InlineElement',
        ],
        'Navigation' => array(
          'selector' => ['css' => '.header div.navigation'],
          'class' => Acme\DemoBundle\Tests\Behat\Page\Element\Navigation,
        )
      );

    // ...

So what do you think about it?
As side effect you don't need to guess Element class anymore (that can be performance issue by the way), you are always know what instance you must create.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions