Selenium Test Case Methods

From Joomla! Documentation

Revision as of 19:11, 10 February 2010 by Betweenbrain (Talk | contribs)

News and Updates

2010 02 10 : Initial draft of this article


With the introduction of System tests in February 2010, there are also a number of Joomla! specific methods that can be used. These methods are part of the SeleniumJoomlaTestCase class, as defined by the file tests/system/SeleniumJoomlaTestCase.php

These methods exist so that none of the path or login information is coded into the tests. Instead, it comes from the config file located at tests/system/servers/configdef.php See Running_Automated_Tests_for_Version_1.6#Create_a_Selenium_Configuration_File

Available Selenium Test Case Methods

As of this writing, the following methods that belong to the SeleniumJoomlaTestCase class.

  • setUp()
  • doAdminLogin()
  • doAdminLogout()
  • gotoAdmin()
  • gotoSite()
  • doFrontEndLogin()
  • doFrontEndLogout()
  • setTinyText($text)


  • Loads the configuration variables defined in tests/system/servers/configdef.php and launches the test browser accordingly.
   public function setUp()
                $cfg = new SeleniumConfig();
                $this->cfg = $cfg; // save current configuration
                if(isset($cfg->selhost)) {
                echo ".\n".'Starting '.get_class($this).".\n";


  • Logs into the administrative side of Joomla!
   function doAdminLogin()
                echo "Logging in to admin.\n";
                $cfg = new SeleniumConfig();
                $this->open($cfg->path . "administrator/index.php?option=com_login");
                $this->type("mod-login-username", $cfg->username);
                $this->type("mod-login-password", $cfg->password);
                $this->click("link=Log in");


  • Logs out of the administrative side of Joomla!
   function doAdminLogout()
                echo "Logging out of back end.\n";


  • Navigates to the administrative side of Joomla!
   function gotoAdmin()
                echo "Browsing to admin.\n";
                $cfg = new SeleniumConfig();
                $this->open($cfg->path . "administrator");


  • Navigates to the front end of Joomla!
   function gotoSite()
                echo "Browsing to site.\n";
                $cfg = new SeleniumConfig();


  • Logs into the front end of Joomla!
   function doFrontEndLogin()
                echo "Logging into front end of site.\n";
                $this->type("modlgn_username", "admin");
                $this->type("modlgn_passwd", "password");


  • Logs out of the front end of Joomla!
   function doFrontEndLogout()
                echo "Logging out of front end of site.\n";


  • Allows the test to input data
   function setTinyText($text)
                $this->type("tinymce", $text);