* log browser used
authorMarkus Glaser <mglaser@users.mediawiki.org>
Mon, 2 Aug 2010 08:04:16 +0000 (08:04 +0000)
committerMarkus Glaser <mglaser@users.mediawiki.org>
Mon, 2 Aug 2010 08:04:16 +0000 (08:04 +0000)
* improve automated login of test user
credits to priyanka dhanda

maintenance/tests/selenium/Selenium.php

index 688a69f..4bd54ba 100644 (file)
@@ -10,8 +10,10 @@ class Selenium extends Testing_Selenium {
 
        public static function getInstance() {
                global $wgSeleniumTestsBrowsers, $wgSeleniumTestsSeleniumHost, $wgSeleniumTestsUseBrowser;
-               global $wgSeleniumServerPort;
+               global $wgSeleniumServerPort, $wgSeleniumLogger;
+
                if ( null === self::$_instance ) {
+                       $wgSeleniumLogger->write( "Browser: " . $wgSeleniumTestsBrowsers[$wgSeleniumTestsUseBrowser] );
                        self::$_instance = new self( $wgSeleniumTestsBrowsers[$wgSeleniumTestsUseBrowser],
                                                        self::getBaseUrl(),
                                                        $wgSeleniumTestsSeleniumHost,
@@ -46,13 +48,27 @@ class Selenium extends Testing_Selenium {
                $this->type( 'wpName1', $wgSeleniumTestsWikiUser );
                $this->type( 'wpPassword1', $wgSeleniumTestsWikiPassword );
                $this->click( "//input[@id='wpLoginAttempt']" );
-               $value = $this->doCommand( 'assertTitle', array( 'Login successful*' ) );
+               $this->waitForPageToLoad(5000);
+               //after login we redirect to the main page. So check whether the "Prefernces" top menu item exists
+               $value = $this->isElementPresent( "//li[@id='pt-preferences']" );
+               if ( $value != true ) {
+                       throw new Testing_Selenium_Exception( "Login Failed" );
+               }
+               
        }
 
        public function loadPage( $title, $action ) {
                $this->open( self::getBaseUrl() . '/index.php?title=' . $title . '&action=' . $action );
        }
-
+       
+       /*
+        * Log to console or html depending on the value of $wgSeleniumTestsRunMode
+        */
+       public function log( $message ) {
+               global $wgSeleniumLogger;
+               $wgSeleniumLogger->write( $message );
+       }
+       
        // Prevent external cloning
        protected function __clone() { }
        // Prevent external construction