pear channel-discover pear.phpunit.de
pear install phpunit/PHPUnit-beta
java -jar selenium-server.jar
* This source code was highlighted with Source Code Highlighter .
- <? php
- require_once 'PHPUnit / Extensions / SeleniumTestCase.php' ;
- class WebTest extends PHPUnit_Extensions_SeleniumTestCase
- {
- protected function setUp ()
- {
- $ this -> setBrowser ( '* firefox' );
- $ this -> setBrowserUrl ( 'http://www.example.com/' );
- }
- public function testTitle ()
- {
- $ this -> open ( 'http://www.example.com/' );
- $ this -> assertTitleEquals ( 'Example WWW Page' );
- }
- }
- ?>
phpunit WebTest
PHPUnit 3.4.0beta4 by Sebastian Bergmann.
E
Time: 14 seconds
There was 1 error:
1) WebTest::testTitle
BadMethodCallException: Method assertTitleEquals not defined.
WebTest.php:15
FAILURES!
Tests: 1, Assertions: 0, Errors: 1.
Please note that the following commands had to be renamed:
assertAlertPresent() has been renamed to assertAlert()
assertNoAlertPresent() has been renamed to assertNotAlert()
assertNoConfirmationPresent() has been renamed to assertConfirmationNotPresent()
assertLocationEquals() has been renamed to assertLocation()
assertLocationNotEquals() has been renamed to assertNotLocation()
assertNoPromptPresent() has been renamed to assertPromptNotPresent()
assertNothingSelected() has been renamed to assertNotSomethingSelected()
assertTitleEquals() has been renamed to assertTitle()
assertTitleNotEquals() has been renamed to assertNotTitle()
PHPUnit 3.4.0beta4 by Sebastian Bergmann.
F
Time: 9 seconds
There was 1 failure:
1) WebTest::testTitle
Current URL: www.example.com
Failed asserting that <string:Example Web Page> matches PCRE pattern "/Example WWW Page/".
WebTest.php:15
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
* This source code was highlighted with Source Code Highlighter .
- <? php
- require_once 'PHPUnit / Extensions / SeleniumTestCase.php' ;
- class WebTest extends PHPUnit_Extensions_SeleniumTestCase
- {
- protected $ captureScreenshotOnFailure = TRUE;
- protected $ screenshotPath = 'd: \ apache2 \ htdocs \ screenshots' ;
- protected $ screenshotUrl = 'http: // localhost / screenshots' ;
- protected function setUp ()
- {
- $ this -> setBrowser ( '* firefox' );
- $ this -> setBrowserUrl ( 'http://www.example.com/' );
- }
- public function testTitle ()
- {
- $ this -> open ( 'http://www.example.com/' );
- $ this -> assertTitle ( 'Example WWW Page' );
- }
- }
- ?>
PHPUnit 3.4.0beta4 by Sebastian Bergmann.
F
Time: 8 seconds
There was 1 failure:
1) WebTest::testTitle
Current URL: www.example.com
Screenshot: localhost/screenshots/ed26432dcfb69cbbdd4e0c01fade4682.png
Failed asserting that <string:Example Web Page> matches PCRE pattern "/Example WWW Page/".
WebTest.php:19
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
* This source code was highlighted with Source Code Highlighter .
- < a onclick = "FB.Connect.requireSession (function () {window.location = 'index.php';}); return false;" href = "#" >
- < img alt = "Connect" src = "http://static.ak.fbcdn.net/images/fbconnect/login-buttons/connect_light_medium_long.gif" id = "fb_login_image" />
- </ a >
* This source code was highlighted with Source Code Highlighter .
- <? php
- require_once 'PHPUnit / Extensions / SeleniumTestCase.php' ;
- class LoginTest extends PHPUnit_Extensions_SeleniumTestCase
- {
- protected $ captureScreenshotOnFailure = TRUE;
- protected $ screenshotPath = 'd: \ apache2 \ htdocs \ screenshots' ;
- protected $ screenshotUrl = 'http: // localhost / screenshots' ;
- protected function setUp ()
- {
- $ this -> setBrowser ( '* firefox' );
- $ this -> setBrowserUrl ( 'http: //% site_url% /' );
- }
- public function testTitle ()
- {
- $ this -> open ( '/' );
- // Click Login
- $ this -> click ( "fb_login_image" );
- }
- }
- ?>
* This source code was highlighted with Source Code Highlighter .
- <? php
- require_once 'PHPUnit / Extensions / SeleniumTestCase.php' ;
- class LoginTest extends PHPUnit_Extensions_SeleniumTestCase
- {
- protected $ captureScreenshotOnFailure = TRUE;
- protected $ screenshotPath = 'd: \ apache2 \ htdocs \ screenshots' ;
- protected $ screenshotUrl = 'http: // localhost / screenshots' ;
- protected function setUp ()
- {
- $ this -> setBrowser ( '* firefox' );
- $ this -> setBrowserUrl ( 'http: //% site_url% /' );
- }
- public function testTitle ()
- {
- $ this -> open ( '/' );
- // Click Login
- $ this -> click ( "fb_login_image" );
- $ this -> type ( "email" , "test@test.com" );
- $ this -> type ( "pass" , "password" );
- $ this -> click ( "login" );
- }
- }
- ?>
PHPUnit 3.4.0beta4 by Sebastian Bergmann.
E
Time: 25 seconds
There was 1 error:
1) WebTest::testTitle
RuntimeException: Response from Selenium RC server for testComplete().
ERROR: Element email not found.
WebTest.php:32
FAILURES!
Tests: 1, Assertions: 1, Errors: 1.
* This source code was highlighted with Source Code Highlighter .
- <? php
- require_once 'PHPUnit / Extensions / SeleniumTestCase.php' ;
- class LoginTest extends PHPUnit_Extensions_SeleniumTestCase
- {
- protected $ captureScreenshotOnFailure = TRUE;
- protected $ screenshotPath = 'd: \ apache2 \ htdocs \ screenshots' ;
- protected $ screenshotUrl = 'http: // localhost / screenshots' ;
- protected function setUp ()
- {
- $ this -> setBrowser ( '* firefox' );
- $ this -> setBrowserUrl ( 'http: //% site_url% /' );
- }
- public function testTitle ()
- {
- // Open the main page
- $ this -> open ( '/' );
- // Check the title (did we get to that site?)
- $ this -> assertTitle ( '% page_title%' );
- // Click login
- $ this -> click ( "fb_login_image" );
- // Waiting for popup to pop out
- $ this -> waitForPopUp ( "_blank" , "30000" );
- // Choose our popup
- $ this -> selectWindow ( "_blank" );
- // fill in the fields and click Connect
- $ this -> type ( "email" , "test@test.com" );
- $ this -> type ( "pass" , "password" );
- $ this -> click ( "login" );
- // Select the main window
- $ this -> selectWindow ( "null" );
- // Waiting for it to load
- $ this -> waitForPageToLoad ( "30000" );
- // Check the title
- $ this -> assertTitle ( '% page_title%' );
- // Check whether or not logged in (does the text signout exist on the page)
- $ this -> verifyTextPresent ( 'signout' );
- }
- }
Source: https://habr.com/ru/post/64240/
All Articles