2017 © Pedro Peláez
 

library page-factory

Php PageFactory for Selenium2

image

tzander/page-factory

Php PageFactory for Selenium2

  • Thursday, July 3, 2014
  • by torstenzander
  • Repository
  • 3 Watchers
  • 2 Stars
  • 4,850 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

PageFactory for PHP

Supports the PageObject pattern for PHP with Selenium2, (*1)

Installation

Install with composer, (*2)

``` json { "require": { "tzander/page-factory": "dev-master" } }, (*3)


Example -------- You need to include the Autoload.php and create a page class. ``` php 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., (*4)

Now in order to have an initialized object to return we need to to the following:, (*5)

``` php class SearchTest{, (*6)

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

}, (*7)


Using Annotation -------- You can also use the @find annotations in order to locate the element. ``` php /** * @find byXpath='a[@class=test]' */ public $link;

Or any of these find methods:, (*8)

byId, byName, byXpath, byCssSelector ,byClassName., (*9)

The Versions

03/07 2014

dev-master

9999999-dev http://tzander.de

Php PageFactory for Selenium2

  Sources   Download

MIT

The Requires

  • php >=5.3

 

phpunit selenium