a1518ff1bb38c477bbb08f263ecd4dc5c940189e
[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 {
14 protected static $_instance = null;
15 public $isStarted = false;
16 public static function getInstance()
17 {
18 global $wgSeleniumTestsBrowsers, $wgSeleniumTestsSeleniumHost, $wgSeleniumTestsUseBrowser;
19 if (null === self::$_instance)
20 {
21 self::$_instance = new self($wgSeleniumTestsBrowsers[$wgSeleniumTestsUseBrowser], $wgSeleniumTestsSeleniumHost);
22 }
23 return self::$_instance;
24 }
25
26 public function start()
27 {
28 global $wgSeleniumTestsBrowsers, $wgSeleniumTestsSeleniumHost;
29 parent::start();
30 $this->isStarted = true;
31 }
32
33 public function stop()
34 {
35 parent::stop();
36 $this->isStarted = false;
37 }
38
39 public function login()
40 {
41 global $wgSeleniumTestsWikiUser, $wgSeleniumTestsWikiPassword, $wgSeleniumTestsWikiUrl;
42
43 $this->open($wgSeleniumTestsWikiUrl.'/index.php?title=Special:Userlogin');
44 $this->type("wpName1", $wgSeleniumTestsWikiUser);
45 $this->type("wpPassword1", $wgSeleniumTestsWikiPassword);
46 $this->click("//input[@id='wpLoginAttempt']");
47 $value = $this->doCommand('assertTitle', array('Anmeldung erfolgreich*'));
48 }
49
50 public function loadPage($title, $action)
51 {
52 global $wgSeleniumTestsWikiUrl;
53 $this->open($wgSeleniumTestsWikiUrl.'/index.php?title='.$title.'&action='.$action);
54 }
55
56 // Prevent external cloning
57 protected function __clone() {}
58 // Prevent external construction
59 //protected function __construct() {}
60 }