PHPackages                             tzander/page-factory - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. tzander/page-factory

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

tzander/page-factory
====================

Php PageFactory for Selenium2

25.1k2PHP

Since Jul 3Pushed 11y ago3 watchersCompare

[ Source](https://github.com/torstenzander/PageFactory)[ Packagist](https://packagist.org/packages/tzander/page-factory)[ RSS](/packages/tzander-page-factory/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

PageFactory for PHP
===================

[](#pagefactory-for-php)

Supports the PageObject pattern for PHP with Selenium2

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

[](#installation)

Install with [composer](http://getcomposer.org/download)

```
{
    "require": {
        "tzander/page-factory": "dev-master"
    }
}
```

Example
-------

[](#example)

You need to include the Autoload.php and create a page class.

```
 require_once __DIR__ . '/library/Autoload.php';

 class BingSearchPage {

    /**
     * @var PHPUnit_Extensions_Selenium2TestCase_Element
     */
     public $sb_form_q;

     public function search() {
         $this->sb_form_q->value('selenium');
         $this->sb_form_q->submit();
         return PageFactory::initElements($this->getTestCase(), 'SearchResultPage');
     }
 }
```

The property must be public and either the name or the id attribute of the element.

Now in order to have an initialized object to return we need to to the following:

```
  class  SearchTest{

    public function shouldfindSelenium(){
          $page = PageFactory::initElements($this, 'BingSearchPage');
          $resultPage = $page->search();
          $this->assertInstanceOf('SearchResultPage', $resultPage);
    }
  }
```

Using Annotation
----------------

[](#using-annotation)

You can also use the @find annotations in order to locate the element.

```
  /**
  * @find byXpath='a[@class=test]'
  */
  public $link;
```

Or any of these find methods:

byId, byName, byXpath, byCssSelector ,byClassName.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/9efa178f9d0267f1b012624dc7661b59a219fe09f1442e4b746f3f254b847460?d=identicon)[torstenzander](/maintainers/torstenzander)

---

Top Contributors

[![torstenzander](https://avatars.githubusercontent.com/u/980484?v=4)](https://github.com/torstenzander "torstenzander (51 commits)")[![lukassteiner](https://avatars.githubusercontent.com/u/7202168?v=4)](https://github.com/lukassteiner "lukassteiner (1 commits)")

### Embed Badge

![Health badge](/badges/tzander-page-factory/health.svg)

```
[![Health](https://phpackages.com/badges/tzander-page-factory/health.svg)](https://phpackages.com/packages/tzander-page-factory)
```

###  Alternatives

[dynamic/silverstripe-locator

SilverStripe Locator Module. Show locations on a map. Search by geoposition.

2113.2k1](/packages/dynamic-silverstripe-locator)[tempusdominus/core

A date/time picker component designed for Momentjs.

119.4k2](/packages/tempusdominus-core)[bolt/bolt-extension-starter-extended

A description about your extension should go here.

151.1k](/packages/bolt-bolt-extension-starter-extended)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
