├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── composer.json ├── composer.lock ├── phpunit.xml └── tests ├── GitHubTest.php ├── bootstrap.php └── support ├── WebDriverAssertions.php └── WebDriverDevelop.php /.gitignore: -------------------------------------------------------------------------------- 1 | vendor/ 2 | .idea/ -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | php: 3 | - '5.4' 4 | - '5.5' 5 | - '5.6' 6 | - '7.0' 7 | - hhvm 8 | - nightly 9 | 10 | before_script: 11 | - "export DISPLAY=:99.0" 12 | - "sh -e /etc/init.d/xvfb start" 13 | - sleep 3 14 | - wget http://goo.gl/qTy1IB -O selenium-server-standalone.jar 15 | - java -jar selenium-server-standalone.jar & 16 | - composer self-update 17 | - composer install 18 | 19 | script: 20 | - vendor/bin/phpunit 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Michael Bodnarchuk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | php-webdriver-demo 2 | ================== 3 | 4 | [![Build Status](https://travis-ci.org/shoaibali/php-webdriver-demo.svg?branch=master)](https://travis-ci.org/shoaibali/php-webdriver-demo) 5 | 6 | Using facebook/php-webdriver library with PHPUnit 7 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require-dev": { 3 | "phpunit/phpunit": "*", 4 | "facebook/webdriver": "dev-master" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" 5 | ], 6 | "hash": "9d76815ba546e6546bdeb6daff9beda8", 7 | "packages": [ 8 | 9 | ], 10 | "packages-dev": [ 11 | { 12 | "name": "facebook/webdriver", 13 | "version": "dev-master", 14 | "source": { 15 | "type": "git", 16 | "url": "https://github.com/facebook/php-webdriver.git", 17 | "reference": "2aa16533196529ad025c83e63a58c30fb2b59c7b" 18 | }, 19 | "dist": { 20 | "type": "zip", 21 | "url": "https://api.github.com/repos/facebook/php-webdriver/zipball/2aa16533196529ad025c83e63a58c30fb2b59c7b", 22 | "reference": "2aa16533196529ad025c83e63a58c30fb2b59c7b", 23 | "shasum": "" 24 | }, 25 | "require": { 26 | "php": ">=5.3.19" 27 | }, 28 | "type": "library", 29 | "autoload": { 30 | "classmap": [ 31 | "lib/" 32 | ] 33 | }, 34 | "notification-url": "https://packagist.org/downloads/", 35 | "license": [ 36 | "Apache-2.0" 37 | ], 38 | "description": "A php client for WebDriver", 39 | "homepage": "https://github.com/facebook/php-webdriver", 40 | "time": "2013-11-14 19:10:09" 41 | }, 42 | { 43 | "name": "phpunit/php-code-coverage", 44 | "version": "1.2.13", 45 | "source": { 46 | "type": "git", 47 | "url": "https://github.com/sebastianbergmann/php-code-coverage.git", 48 | "reference": "466e7cd2554b4e264c9e3f31216d25ac0e5f3d94" 49 | }, 50 | "dist": { 51 | "type": "zip", 52 | "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/466e7cd2554b4e264c9e3f31216d25ac0e5f3d94", 53 | "reference": "466e7cd2554b4e264c9e3f31216d25ac0e5f3d94", 54 | "shasum": "" 55 | }, 56 | "require": { 57 | "php": ">=5.3.3", 58 | "phpunit/php-file-iterator": ">=1.3.0@stable", 59 | "phpunit/php-text-template": ">=1.1.1@stable", 60 | "phpunit/php-token-stream": ">=1.1.3@stable" 61 | }, 62 | "require-dev": { 63 | "phpunit/phpunit": "3.7.*@dev" 64 | }, 65 | "suggest": { 66 | "ext-dom": "*", 67 | "ext-xdebug": ">=2.0.5" 68 | }, 69 | "type": "library", 70 | "extra": { 71 | "branch-alias": { 72 | "dev-master": "1.2.x-dev" 73 | } 74 | }, 75 | "autoload": { 76 | "classmap": [ 77 | "PHP/" 78 | ] 79 | }, 80 | "notification-url": "https://packagist.org/downloads/", 81 | "include-path": [ 82 | "" 83 | ], 84 | "license": [ 85 | "BSD-3-Clause" 86 | ], 87 | "authors": [ 88 | { 89 | "name": "Sebastian Bergmann", 90 | "email": "sb@sebastian-bergmann.de", 91 | "role": "lead" 92 | } 93 | ], 94 | "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", 95 | "homepage": "https://github.com/sebastianbergmann/php-code-coverage", 96 | "keywords": [ 97 | "coverage", 98 | "testing", 99 | "xunit" 100 | ], 101 | "time": "2013-09-10 08:14:32" 102 | }, 103 | { 104 | "name": "phpunit/php-file-iterator", 105 | "version": "1.3.4", 106 | "source": { 107 | "type": "git", 108 | "url": "https://github.com/sebastianbergmann/php-file-iterator.git", 109 | "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb" 110 | }, 111 | "dist": { 112 | "type": "zip", 113 | "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb", 114 | "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb", 115 | "shasum": "" 116 | }, 117 | "require": { 118 | "php": ">=5.3.3" 119 | }, 120 | "type": "library", 121 | "autoload": { 122 | "classmap": [ 123 | "File/" 124 | ] 125 | }, 126 | "notification-url": "https://packagist.org/downloads/", 127 | "include-path": [ 128 | "" 129 | ], 130 | "license": [ 131 | "BSD-3-Clause" 132 | ], 133 | "authors": [ 134 | { 135 | "name": "Sebastian Bergmann", 136 | "email": "sb@sebastian-bergmann.de", 137 | "role": "lead" 138 | } 139 | ], 140 | "description": "FilterIterator implementation that filters files based on a list of suffixes.", 141 | "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", 142 | "keywords": [ 143 | "filesystem", 144 | "iterator" 145 | ], 146 | "time": "2013-10-10 15:34:57" 147 | }, 148 | { 149 | "name": "phpunit/php-text-template", 150 | "version": "1.1.4", 151 | "source": { 152 | "type": "git", 153 | "url": "https://github.com/sebastianbergmann/php-text-template.git", 154 | "reference": "5180896f51c5b3648ac946b05f9ec02be78a0b23" 155 | }, 156 | "dist": { 157 | "type": "zip", 158 | "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5180896f51c5b3648ac946b05f9ec02be78a0b23", 159 | "reference": "5180896f51c5b3648ac946b05f9ec02be78a0b23", 160 | "shasum": "" 161 | }, 162 | "require": { 163 | "php": ">=5.3.3" 164 | }, 165 | "type": "library", 166 | "autoload": { 167 | "classmap": [ 168 | "Text/" 169 | ] 170 | }, 171 | "notification-url": "https://packagist.org/downloads/", 172 | "include-path": [ 173 | "" 174 | ], 175 | "license": [ 176 | "BSD-3-Clause" 177 | ], 178 | "authors": [ 179 | { 180 | "name": "Sebastian Bergmann", 181 | "email": "sb@sebastian-bergmann.de", 182 | "role": "lead" 183 | } 184 | ], 185 | "description": "Simple template engine.", 186 | "homepage": "https://github.com/sebastianbergmann/php-text-template/", 187 | "keywords": [ 188 | "template" 189 | ], 190 | "time": "2012-10-31 18:15:28" 191 | }, 192 | { 193 | "name": "phpunit/php-timer", 194 | "version": "1.0.5", 195 | "source": { 196 | "type": "git", 197 | "url": "https://github.com/sebastianbergmann/php-timer.git", 198 | "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c" 199 | }, 200 | "dist": { 201 | "type": "zip", 202 | "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c", 203 | "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c", 204 | "shasum": "" 205 | }, 206 | "require": { 207 | "php": ">=5.3.3" 208 | }, 209 | "type": "library", 210 | "autoload": { 211 | "classmap": [ 212 | "PHP/" 213 | ] 214 | }, 215 | "notification-url": "https://packagist.org/downloads/", 216 | "include-path": [ 217 | "" 218 | ], 219 | "license": [ 220 | "BSD-3-Clause" 221 | ], 222 | "authors": [ 223 | { 224 | "name": "Sebastian Bergmann", 225 | "email": "sb@sebastian-bergmann.de", 226 | "role": "lead" 227 | } 228 | ], 229 | "description": "Utility class for timing", 230 | "homepage": "https://github.com/sebastianbergmann/php-timer/", 231 | "keywords": [ 232 | "timer" 233 | ], 234 | "time": "2013-08-02 07:42:54" 235 | }, 236 | { 237 | "name": "phpunit/php-token-stream", 238 | "version": "1.2.1", 239 | "source": { 240 | "type": "git", 241 | "url": "https://github.com/sebastianbergmann/php-token-stream.git", 242 | "reference": "5220af2a7929aa35cf663d97c89ad3d50cf5fa3e" 243 | }, 244 | "dist": { 245 | "type": "zip", 246 | "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/5220af2a7929aa35cf663d97c89ad3d50cf5fa3e", 247 | "reference": "5220af2a7929aa35cf663d97c89ad3d50cf5fa3e", 248 | "shasum": "" 249 | }, 250 | "require": { 251 | "ext-tokenizer": "*", 252 | "php": ">=5.3.3" 253 | }, 254 | "type": "library", 255 | "extra": { 256 | "branch-alias": { 257 | "dev-master": "1.2-dev" 258 | } 259 | }, 260 | "autoload": { 261 | "classmap": [ 262 | "PHP/" 263 | ] 264 | }, 265 | "notification-url": "https://packagist.org/downloads/", 266 | "include-path": [ 267 | "" 268 | ], 269 | "license": [ 270 | "BSD-3-Clause" 271 | ], 272 | "authors": [ 273 | { 274 | "name": "Sebastian Bergmann", 275 | "email": "sb@sebastian-bergmann.de", 276 | "role": "lead" 277 | } 278 | ], 279 | "description": "Wrapper around PHP's tokenizer extension.", 280 | "homepage": "https://github.com/sebastianbergmann/php-token-stream/", 281 | "keywords": [ 282 | "tokenizer" 283 | ], 284 | "time": "2013-09-13 04:58:23" 285 | }, 286 | { 287 | "name": "phpunit/phpunit", 288 | "version": "3.7.28", 289 | "source": { 290 | "type": "git", 291 | "url": "https://github.com/sebastianbergmann/phpunit.git", 292 | "reference": "3b97c8492bcafbabe6b6fbd2ab35f2f04d932a8d" 293 | }, 294 | "dist": { 295 | "type": "zip", 296 | "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3b97c8492bcafbabe6b6fbd2ab35f2f04d932a8d", 297 | "reference": "3b97c8492bcafbabe6b6fbd2ab35f2f04d932a8d", 298 | "shasum": "" 299 | }, 300 | "require": { 301 | "ext-dom": "*", 302 | "ext-pcre": "*", 303 | "ext-reflection": "*", 304 | "ext-spl": "*", 305 | "php": ">=5.3.3", 306 | "phpunit/php-code-coverage": "~1.2.1", 307 | "phpunit/php-file-iterator": ">=1.3.1", 308 | "phpunit/php-text-template": ">=1.1.1", 309 | "phpunit/php-timer": ">=1.0.4", 310 | "phpunit/phpunit-mock-objects": "~1.2.0", 311 | "symfony/yaml": "~2.0" 312 | }, 313 | "require-dev": { 314 | "pear-pear/pear": "1.9.4" 315 | }, 316 | "suggest": { 317 | "ext-json": "*", 318 | "ext-simplexml": "*", 319 | "ext-tokenizer": "*", 320 | "phpunit/php-invoker": ">=1.1.0,<1.2.0" 321 | }, 322 | "bin": [ 323 | "composer/bin/phpunit" 324 | ], 325 | "type": "library", 326 | "extra": { 327 | "branch-alias": { 328 | "dev-master": "3.7.x-dev" 329 | } 330 | }, 331 | "autoload": { 332 | "classmap": [ 333 | "PHPUnit/" 334 | ] 335 | }, 336 | "notification-url": "https://packagist.org/downloads/", 337 | "include-path": [ 338 | "", 339 | "../../symfony/yaml/" 340 | ], 341 | "license": [ 342 | "BSD-3-Clause" 343 | ], 344 | "authors": [ 345 | { 346 | "name": "Sebastian Bergmann", 347 | "email": "sebastian@phpunit.de", 348 | "role": "lead" 349 | } 350 | ], 351 | "description": "The PHP Unit Testing framework.", 352 | "homepage": "http://www.phpunit.de/", 353 | "keywords": [ 354 | "phpunit", 355 | "testing", 356 | "xunit" 357 | ], 358 | "time": "2013-10-17 07:27:40" 359 | }, 360 | { 361 | "name": "phpunit/phpunit-mock-objects", 362 | "version": "1.2.3", 363 | "source": { 364 | "type": "git", 365 | "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", 366 | "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875" 367 | }, 368 | "dist": { 369 | "type": "zip", 370 | "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/5794e3c5c5ba0fb037b11d8151add2a07fa82875", 371 | "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875", 372 | "shasum": "" 373 | }, 374 | "require": { 375 | "php": ">=5.3.3", 376 | "phpunit/php-text-template": ">=1.1.1@stable" 377 | }, 378 | "suggest": { 379 | "ext-soap": "*" 380 | }, 381 | "type": "library", 382 | "autoload": { 383 | "classmap": [ 384 | "PHPUnit/" 385 | ] 386 | }, 387 | "notification-url": "https://packagist.org/downloads/", 388 | "include-path": [ 389 | "" 390 | ], 391 | "license": [ 392 | "BSD-3-Clause" 393 | ], 394 | "authors": [ 395 | { 396 | "name": "Sebastian Bergmann", 397 | "email": "sb@sebastian-bergmann.de", 398 | "role": "lead" 399 | } 400 | ], 401 | "description": "Mock Object library for PHPUnit", 402 | "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", 403 | "keywords": [ 404 | "mock", 405 | "xunit" 406 | ], 407 | "time": "2013-01-13 10:24:48" 408 | }, 409 | { 410 | "name": "symfony/yaml", 411 | "version": "v2.3.7", 412 | "target-dir": "Symfony/Component/Yaml", 413 | "source": { 414 | "type": "git", 415 | "url": "https://github.com/symfony/Yaml.git", 416 | "reference": "c1bda5b459d792cb253de12c65beba3040163b2b" 417 | }, 418 | "dist": { 419 | "type": "zip", 420 | "url": "https://api.github.com/repos/symfony/Yaml/zipball/c1bda5b459d792cb253de12c65beba3040163b2b", 421 | "reference": "c1bda5b459d792cb253de12c65beba3040163b2b", 422 | "shasum": "" 423 | }, 424 | "require": { 425 | "php": ">=5.3.3" 426 | }, 427 | "type": "library", 428 | "extra": { 429 | "branch-alias": { 430 | "dev-master": "2.3-dev" 431 | } 432 | }, 433 | "autoload": { 434 | "psr-0": { 435 | "Symfony\\Component\\Yaml\\": "" 436 | } 437 | }, 438 | "notification-url": "https://packagist.org/downloads/", 439 | "license": [ 440 | "MIT" 441 | ], 442 | "authors": [ 443 | { 444 | "name": "Fabien Potencier", 445 | "email": "fabien@symfony.com" 446 | }, 447 | { 448 | "name": "Symfony Community", 449 | "homepage": "http://symfony.com/contributors" 450 | } 451 | ], 452 | "description": "Symfony Yaml Component", 453 | "homepage": "http://symfony.com", 454 | "time": "2013-10-17 11:48:01" 455 | } 456 | ], 457 | "aliases": [ 458 | 459 | ], 460 | "minimum-stability": "stable", 461 | "stability-flags": { 462 | "facebook/webdriver": 20 463 | }, 464 | "platform": [ 465 | 466 | ], 467 | "platform-dev": [ 468 | 469 | ] 470 | } 471 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | tests 5 | 6 | 7 | -------------------------------------------------------------------------------- /tests/GitHubTest.php: -------------------------------------------------------------------------------- 1 | 'firefox'); 16 | $this->webDriver = RemoteWebDriver::create('http://localhost:4444/wd/hub', $capabilities); 17 | 18 | } 19 | 20 | public function tearDown() 21 | { 22 | $this->webDriver->quit(); 23 | } 24 | 25 | public function testGitHubHome() 26 | { 27 | $this->webDriver->get($this->url); 28 | // checking that page title contains word 'GitHub' 29 | $this->assertContains('GitHub', $this->webDriver->getTitle()); 30 | } 31 | 32 | public function testSearch() 33 | { 34 | $this->webDriver->get($this->url . '/search'); 35 | 36 | // find search field by its id 37 | $search = $this->webDriver->findElement(WebDriverBy::cssSelector('.input-block')); 38 | $search->click(); 39 | 40 | // typing into field 41 | $this->webDriver->getKeyboard()->sendKeys('php-webdriver'); 42 | 43 | // pressing "Enter" 44 | $this->webDriver->getKeyboard()->pressKey(WebDriverKeys::ENTER); 45 | 46 | $firstResult = $this->webDriver->findElement( 47 | // select link for php-webdriver 48 | WebDriverBy::partialLinkText('facebook') 49 | ); 50 | 51 | $firstResult->click(); 52 | 53 | // we expect that facebook/php-webdriver was the first result 54 | $this->assertContains("php-webdriver",$this->webDriver->getTitle()); 55 | 56 | $this->assertEquals('https://github.com/facebook/php-webdriver', $this->webDriver->getCurrentURL()); 57 | 58 | $this->assertElementNotFound(WebDriverBy::className('name')); 59 | 60 | // $this->waitForUserInput(); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /tests/bootstrap.php: -------------------------------------------------------------------------------- 1 | webDriver->findElements($by); 7 | if (count($els)) { 8 | $this->fail("Unexpectedly element was found"); 9 | } 10 | // increment assertion counter 11 | $this->assertTrue(true); 12 | } 13 | 14 | } -------------------------------------------------------------------------------- /tests/support/WebDriverDevelop.php: -------------------------------------------------------------------------------- 1 |