more follow-up to r65715: coding style tweaks, etc.
[lhc/web/wiklou.git] / maintenance / tests / selenium / Selenium.php
1 <?php
2 /**
3 * Selenium connector
4 * This is implemented as a singleton.
5 */
6
7 if ( !defined( 'MEDIAWIKI' ) || !defined( 'SELENIUMTEST' ) ) {
8 echo "This script cannot be run standalone";
9 exit( 1 );
10 }
11
12 class Selenium extends Testing_Selenium {
13 protected static $_instance = null;
14 public $isStarted = false;
15
16 public static function getInstance() {
17 global $wgSeleniumTestsBrowsers, $wgSeleniumTestsSeleniumHost, $wgSeleniumTestsUseBrowser;
18 if ( null === self::$_instance ) {
19 self::$_instance = new self( $wgSeleniumTestsBrowsers[$wgSeleniumTestsUseBrowser], $wgSeleniumTestsSeleniumHost );
20 }
21 return self::$_instance;
22 }
23
24 public function start() {
25 global $wgSeleniumTestsBrowsers, $wgSeleniumTestsSeleniumHost;
26 parent::start();
27 $this->isStarted = true;
28 }
29
30 public function stop() {
31 parent::stop();
32 $this->isStarted = false;
33 }
34
35 public function login() {
36 global $wgSeleniumTestsWikiUser, $wgSeleniumTestsWikiPassword, $wgSeleniumTestsWikiUrl;
37
38 $this->open( $wgSeleniumTestsWikiUrl . '/index.php?title=Special:Userlogin' );
39 $this->type( 'wpName1', $wgSeleniumTestsWikiUser );
40 $this->type( 'wpPassword1', $wgSeleniumTestsWikiPassword );
41 $this->click( "//input[@id='wpLoginAttempt']" );
42 $value = $this->doCommand( 'assertTitle', array( 'Anmeldung erfolgreich*' ) );
43 }
44
45 public function loadPage( $title, $action ) {
46 global $wgSeleniumTestsWikiUrl;
47 $this->open( $wgSeleniumTestsWikiUrl . '/index.php?title=' . $title . '&action=' . $action );
48 }
49
50 // Prevent external cloning
51 protected function __clone() {}
52 // Prevent external construction
53 //protected function __construct() {}
54 }