added settings to run tests against a selenium grid
authorMarkus Glaser <mglaser@users.mediawiki.org>
Sat, 23 Oct 2010 15:52:12 +0000 (15:52 +0000)
committerMarkus Glaser <mglaser@users.mediawiki.org>
Sat, 23 Oct 2010 15:52:12 +0000 (15:52 +0000)
maintenance/tests/RunSeleniumTests.php
maintenance/tests/selenium/Selenium.php
maintenance/tests/selenium/SeleniumConfig.php

index e705e61..2ff72a7 100644 (file)
@@ -51,7 +51,8 @@ class SeleniumTester extends Maintenance {
                $this->addOption( 'verbose', 'Be noisier.' );
                $this->addOption( 'startserver', 'Start Selenium Server (on localhost) before the run.' );
                $this->addOption( 'stopserver', 'Stop Selenium Server (on localhost) after the run.' );
-               $this->addOption( 'jUnitLogFile', 'Log results in a specified JUnit log file.', false, true );
+               $this->addOption( 'jUnitLogFile', 'Log results in a specified JUnit log file. Default: empty', false, true );
+               $this->addOption( 'runAgainstGrid', 'The test will be run against a Selenium Grid. Default: false.', false, true );
                $this->deleteOption( 'dbpass' );
                $this->deleteOption( 'dbuser' );
                $this->deleteOption( 'globals' );
@@ -180,10 +181,12 @@ class SeleniumTester extends Maintenance {
                if ( !isset( $seleniumSettings['userPassword'] ) ) $seleniumSettings['userPassword'] = '';
                if ( !isset( $seleniumSettings['testBrowser'] ) ) $seleniumSettings['testBrowser'] = 'firefox';
                if ( !isset( $seleniumSettings['jUnitLogFile'] ) ) $seleniumSettings['jUnitLogFile'] = false;
+               if ( !isset( $seleniumSettings['runAgainstGrid'] ) ) $seleniumSettings['runAgainstGrid'] = false;
 
                // Setup Selenium class
                $this->selenium = new Selenium( );
                $this->selenium->setAvailableBrowsers( $seleniumBrowsers );
+               $this->selenium->setRunAgainstGrid( $this->getOption( 'runAgainstGrid', $seleniumSettings['runAgainstGrid'] ) );                
                $this->selenium->setUrl( $this->getOption( 'wikiUrl', $seleniumSettings['wikiUrl'] ) );
                $this->selenium->setBrowser( $this->getOption( 'testBrowser', $seleniumSettings['testBrowser'] ) );
                $this->selenium->setPort( $this->getOption( 'port', $seleniumSettings['port'] ) );
index 25f1037..662e282 100644 (file)
@@ -22,6 +22,7 @@ class Selenium {
        protected $timeout = 30000;
        protected $verbose;
        protected $junitlogfile; //processed by phpUnderControl
+       protected $runagainstgrid = false;
 
        /**
         * @todo this shouldn't have to be static
@@ -145,7 +146,15 @@ class Selenium {
                return $this->junitlogfile;
        }       
        
+       public function setRunAgainstGrid( $runagainstgrid ) {
+               $this->runagainstgrid = $runagainstgrid;
+       }
+       
        public function setBrowser( $b ) {
+               if ($this->runagainstgrid) {
+                       $this->browser = $b;
+                       return true;
+               }
                if ( !isset( $this->browsers[$b] ) ) {
                        throw new MWException( "Invalid Browser: $b.\n" );
                }
index a7ceca5..ca438a8 100644 (file)
@@ -49,6 +49,7 @@ class SeleniumConfig {
                        $seleniumSettings['stopserver'] = $configArray['SeleniumSettings']['stopserver'];
                        $seleniumSettings['seleniumserverexecpath'] = $configArray['SeleniumSettings']['seleniumserverexecpath'];
                        $seleniumSettings['jUnitLogFile'] = $configArray['SeleniumSettings']['jUnitLogFile'];
+                       $seleniumSettings['runAgainstGrid'] = $configArray['SeleniumSettings']['runAgainstGrid'];
 
                        wfRestoreWarnings();
                }