pear channel-discover pear.phpunit.depear install phpunit/PHPUnit-beta
java -jar selenium-server.jar
<?phprequire_once 'PHPUnit / Extensions / SeleniumTestCase.php' ;WebTest クラスは PHPUnit_Extensions_SeleniumTestCaseを拡張します{保護された関数setUp(){$ this-> setBrowser( '* firefox' );$ this-> setBrowserUrl( 'http://www.example.com/' );}パブリック関数testTitle(){$ this-> open( 'http://www.example.com/' );$ this-> assertTitleEquals( 'WWWページの例' );}}?>*このソースコードは、 ソースコードハイライターで強調表示されました。
phpunit WebTest
PHPUnit 3.4.0beta4 by Sebastian Bergmann.ETime: 14 secondsThere was 1 error:1) WebTest::testTitleBadMethodCallException: Method assertTitleEquals not defined.WebTest.php:15FAILURES!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.FTime: 9 secondsThere was 1 failure:1) WebTest::testTitleCurrent URL: www.example.comFailed asserting that <string:Example Web Page> matches PCRE pattern "/Example WWW Page/".WebTest.php:15FAILURES!Tests: 1, Assertions: 1, Failures: 1.
<?phprequire_once 'PHPUnit / Extensions / SeleniumTestCase.php' ;WebTest クラスは PHPUnit_Extensions_SeleniumTestCaseを拡張します{protected $ captureScreenshotOnFailure = TRUE;protected $ screenshotPath = 'd:\ apache2 \ htdocs \ screenshots' ;protected $ screenshotUrl = 'http:// localhost / screenshots' ;保護された関数setUp(){$ this-> setBrowser( '* firefox' );$ this-> setBrowserUrl( 'http://www.example.com/' );}パブリック関数testTitle(){$ this-> open( 'http://www.example.com/' );$ this-> assertTitle( 'WWWページの例' );}}?>*このソースコードは、 ソースコードハイライターで強調表示されました。
PHPUnit 3.4.0beta4 by Sebastian Bergmann.FTime: 8 secondsThere was 1 failure:1) WebTest::testTitleCurrent URL: www.example.comScreenshot: localhost/screenshots/ed26432dcfb69cbbdd4e0c01fade4682.pngFailed asserting that <string:Example Web Page> matches PCRE pattern "/Example WWW Page/".WebTest.php:19FAILURES!Tests: 1, Assertions: 1, Failures: 1.
< a onclick = "FB.Connect.requireSession(function(){window.location = 'index.php';}); return false;" href = "#" >< img alt = "接続" src = "http://static.ak.fbcdn.net/images/fbconnect/login-buttons/connect_light_medium_long.gif" id = "fb_login_image" /></ a >*このソースコードは、 ソースコードハイライターで強調表示されました。
<?phprequire_once 'PHPUnit / Extensions / SeleniumTestCase.php' ;クラス LoginTestはPHPUnit_Extensions_SeleniumTestCaseを拡張します{protected $ captureScreenshotOnFailure = TRUE;protected $ screenshotPath = 'd:\ apache2 \ htdocs \ screenshots' ;protected $ screenshotUrl = 'http:// localhost / screenshots' ;保護された関数setUp(){$ this-> setBrowser( '* firefox' );$ this- > setBrowserUrl( 'http://%site_url%/' );}パブリック関数testTitle(){$ this-> open( '/' );// [ログイン]をクリックします$ this- > click( "fb_login_image" );}}?>*このソースコードは、 ソースコードハイライターで強調表示されました。
<?phprequire_once 'PHPUnit / Extensions / SeleniumTestCase.php' ;クラス LoginTestはPHPUnit_Extensions_SeleniumTestCaseを拡張します{protected $ captureScreenshotOnFailure = TRUE;protected $ screenshotPath = 'd:\ apache2 \ htdocs \ screenshots' ;protected $ screenshotUrl = 'http:// localhost / screenshots' ;保護された関数setUp(){$ this-> setBrowser( '* firefox' );$ this- > setBrowserUrl( 'http://%site_url%/' );}パブリック関数testTitle(){$ this-> open( '/' );// [ログイン]をクリックします$ this- > click( "fb_login_image" );$ this- > type( "email" 、 "test@test.com" );$ this-> type( "pass" 、 "password" );$ this- >クリック( "ログイン" );}}?>*このソースコードは、 ソースコードハイライターで強調表示されました。
PHPUnit 3.4.0beta4 by Sebastian Bergmann.ETime: 25 secondsThere was 1 error:1) WebTest::testTitleRuntimeException: Response from Selenium RC server for testComplete().ERROR: Element email not found.WebTest.php:32FAILURES!Tests: 1, Assertions: 1, Errors: 1.
<?phprequire_once 'PHPUnit / Extensions / SeleniumTestCase.php' ;クラス LoginTestはPHPUnit_Extensions_SeleniumTestCaseを拡張します{protected $ captureScreenshotOnFailure = TRUE;protected $ screenshotPath = 'd:\ apache2 \ htdocs \ screenshots' ;protected $ screenshotUrl = 'http:// localhost / screenshots' ;保護された関数setUp(){$ this-> setBrowser( '* firefox' );$ this- > setBrowserUrl( 'http://%site_url%/' );}パブリック関数testTitle(){//メインページを開きます$ this-> open( '/' );//タイトルを確認します(そのサイトに着きましたか?)$ this-> assertTitle( '%page_title%' );//ログインをクリックします$ this- > click( "fb_login_image" );//ポップアップが表示されるまで待ちます$ this- > waitForPopUp( "_blank" 、 "30000" );//ポップアップを選択$ this-> selectWindow( "_blank" );//フィールドに入力して、[接続]をクリックします$ this- > type( "email" 、 "test@test.com" );$ this-> type( "pass" 、 "password" );$ this- >クリック( "ログイン" );//メインウィンドウを選択します$ this-> selectWindow( "null" );//ロードされるのを待ちます$ this-> waitForPageToLoad( "30000" );//タイトルを確認します$ this-> assertTitle( '%page_title%' );//ログインしているかどうかを確認します(ページにサインアウトテキストがあります)$ this-> verifyTextPresent( 'signout' );}}*このソースコードは、 ソースコードハイライターで強調表示されました。
Source: https://habr.com/ru/post/J64240/More articles:小さな非同期サーバーを実装する+1を書きましょうiWallet-メモリー付きウォレット海外からウクライナに輸入されたiPhoneを合法化する方法ホスティングの関税計画の設計者は不利ですアスタリスク管理インターフェース(AMI)、パート2Acer Aspire One A110ネットブックのSSDの高速化完璧なページ404Web上のObjective-C:サーバー側のビュー$ 5 1990織機All Articles