define( 'MEDIAWIKI', true );
define( 'SELENIUMTEST', true );
+// Here, you can override standard setting
+if ( file_exists( 'selenium/LocalSeleniumSettings.php' ) ) {
+ include_once 'selenium/LocalSeleniumSettings.php';
+} else {
+ echo "You must provide local settings in LocalSeleniumSettings.php\n";
+ die( -1 );
+}
+
// Command line only
-$wgSeleniumTestsRunMode = 'cli';
if ( $wgSeleniumTestsRunMode == 'cli' && php_sapi_name() != 'cli' ) {
- echo 'Must be run from the command line.';
+ echo "Must be run from the command line.\n";
die( -1 );
}
-// include path and installation instructions
-
-// URL: http://localhost/tests/RunSeleniumTests.php
-// set_include_path( get_include_path() . PATH_SEPARATOR . './PEAR/' );
-
-// Hostname of selenium server
-$wgSeleniumTestsSeleniumHost = 'http://localhost';
-// URL of the wiki to be tested.
-$wgSeleniumTestsWikiUrl = 'http://localhost';
-
-// Wiki login. Used by Selenium to log onto the wiki
-$wgSeleniumTestsWikiUser = 'WikiSysop';
-$wgSeleniumTestsWikiPassword = 'password';
-
-// Common browsers on Windows platform
-// Use the *chrome handler in order to be able to test file uploads
-// further solution suggestions: http://www.brokenbuild.com/blog/2007/06/07/testing-file-uploads-with-selenium-rc-and-firefoxor-reducing-javascript-security-in-firefox-for-fun-and-profit/
-// $wgSeleniumTestsBrowsers['firefox'] = '*firefox c:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe';
-$wgSeleniumTestsBrowsers['firefox'] = '*chrome c:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe';
-$wgSeleniumTestsBrowsers['iexplorer'] = '*iexploreproxy';
-
-// Actually, use this browser
-$wgSeleniumTestsUseBrowser = 'firefox';
+// Get command line parameters
+if ( $wgSeleniumTestsRunMode == 'cli' ) {
+ require_once( dirname( __FILE__ ) . '/../commandLine.inc' );
+ if ( isset( $options['help'] ) ) {
+ echo <<<ENDS
+MediaWiki $wgVersion Selenium Framework tester
+Usage: php RunSeleniumTests.php [options...]
+Options:
+ --port=<TCP port> Port used by selenium server to accept commands
+ --help Show this help message
+ENDS;
+ exit( 0 );
+ }
+
+ if ( isset( $options['port'] ) ) {
+ $wgSeleniumServerPort = (int) $options['port'];
+ }
+}
// requires PHPUnit 3.4
require_once 'Testing/Selenium.php';
require_once 'PHPUnit/Framework.php';
require_once 'PHPUnit/Extensions/SeleniumTestCase.php';
-// include uiTestsuite
+// include seleniumTestsuite
require_once 'selenium/SeleniumTestHTMLLogger.php';
require_once 'selenium/SeleniumTestConsoleLogger.php';
require_once 'selenium/SeleniumTestListener.php';
$wgSeleniumTestSuites = array();
+// include tests
// Todo: include automatically
-# include_once '<your tests>';
-
-// Here, you can override standard setting
-if ( file_exists( 'LocalSeleniumSettings.php' ) ) {
- include_once 'LocalSeleniumSettings.php';
+if ( is_array( $wgSeleniumTestIncludes ) ) {
+ foreach ( $wgSeleniumTestIncludes as $include ) {
+ include_once $include;
+ }
}
// run tests
--- /dev/null
+<?php\r
+// This template file contains variables that should be localized.\r
+// The line (specifying the location of the PHP/PEAR libraries) must be\r
+// first. Moving it to a position later in the file will almost certainly\r
+// cause an error.\r
+\r
+// In order to use this file, first copy it to LocalSeleniumSettings.php.\r
+// Then edit the information to conform to the local environment. You\r
+// will almost certainly have to uncomment the line set_include_path ... and\r
+// change the string 'PEAR' to the path to your PEAR library, e.g.,\r
+// '/usr/share/php/PEAR' for a Debian based Linux system.\r
+// The edited file must appear in the same directory as does RunSeleniumTests.php.\r
+\r
+// include path. Set 'PEAR" to '/path/to/PEAR/library'\r
+\r
+// URL: http://localhost/tests/RunSeleniumTests.php\r
+#set_include_path( get_include_path() . PATH_SEPARATOR . 'PEAR' );\r
+\r
+// Hostname of selenium server\r
+$wgSeleniumTestsSeleniumHost = 'localhost';\r
+\r
+// URL of the wiki to be tested. Consult web server configuration.\r
+$wgSeleniumTestsWikiUrl = 'http://localhost';\r
+\r
+// Port used by selenium server (optional - default is 4444)\r
+$wgSeleniumServerPort = 4444;\r
+\r
+// Wiki login. Used by Selenium to log onto the wiki\r
+$wgSeleniumTestsWikiUser = 'Wikisysop';\r
+$wgSeleniumTestsWikiPassword = 'password';\r
+\r
+// Common browsers on Windows platform. Modify for other platforms or\r
+// other Windows browsers\r
+// Use the *chrome handler in order to be able to test file uploads\r
+// further solution suggestions: http://www.brokenbuild.com/blog/2007/06/07/testing-file-uploads-with-selenium-rc-and-firefoxor-reducing-javascript-security-in-firefox-for-fun-and-profit/\r
+// $wgSeleniumTestsBrowsers['firefox'] = '*firefox c:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe';\r
+$wgSeleniumTestsBrowsers['firefox'] = '*firefox /usr/bin/firefox';\r
+$wgSeleniumTestsBrowsers['iexplorer'] = '*iexploreproxy';\r
+$wgSeleniumTestsBrowsers['opera'] = '*chrome /usr/bin/opera';\r
+\r
+// Actually, use this browser\r
+$wgSeleniumTestsUseBrowser = 'firefox';\r
+\r
+// Set command line mode\r
+$wgSeleniumTestsRunMode = 'cli';\r
+\r
+// List of tests to be included by default\r
+$wgSeleniumTestIncludes = array(\r
+ 'selenium/SimpleSeleniumTest.php'\r
+);\r
+?>
\ No newline at end of file
public static function getInstance() {
global $wgSeleniumTestsBrowsers, $wgSeleniumTestsSeleniumHost, $wgSeleniumTestsUseBrowser;
+ global $wgSeleniumTestsWikiUrl, $wgSeleniumServerPort;
if ( null === self::$_instance ) {
- self::$_instance = new self( $wgSeleniumTestsBrowsers[$wgSeleniumTestsUseBrowser], $wgSeleniumTestsSeleniumHost );
- }
+ self::$_instance = new self( $wgSeleniumTestsBrowsers[$wgSeleniumTestsUseBrowser],
+ $wgSeleniumTestsWikiUrl,
+ $wgSeleniumTestsSeleniumHost,
+ $wgSeleniumServerPort );
+ }
return self::$_instance;
}
$this->type( 'wpName1', $wgSeleniumTestsWikiUser );
$this->type( 'wpPassword1', $wgSeleniumTestsWikiPassword );
$this->click( "//input[@id='wpLoginAttempt']" );
- $value = $this->doCommand( 'assertTitle', array( 'Anmeldung erfolgreich*' ) );
+ $value = $this->doCommand( 'assertTitle', array( 'Login successful*' ) );
}
public function loadPage( $title, $action ) {
--- /dev/null
+<?php\r
+\r
+if (!defined('MEDIAWIKI') || !defined('SELENIUMTEST')) {\r
+ echo "This script cannot be run standalone";\r
+ exit(1);\r
+}\r
+\r
+// create test suite\r
+$wgSeleniumTestSuites['SimpleSeleniumTest'] = new SeleniumTestSuite('Simple Selenium Test');\r
+$wgSeleniumTestSuites['SimpleSeleniumTest']->addTest(new SimpleSeleniumTest());\r
+\r
+class SimpleSeleniumTest extends SeleniumTestCase\r
+{\r
+ public $name = "Basic selenium test";\r
+\r
+ public function runTest()\r
+ {\r
+ global $wgSeleniumTestsWikiUrl;\r
+ $this->open($wgSeleniumTestsWikiUrl.'/index.php?title=Selenium&action=edit');\r
+ $this->type("wpTextbox1", "This is a basic test");\r
+ $this->click("wpPreview");\r
+ $this->waitForPageToLoad(10000);\r
+\r
+ // check result\r
+ $source = $this->getText("//div[@id='wikiPreview']/p");\r
+ $correct = strstr($source, "This is a basic test");\r
+ $this->assertEquals($correct, true);\r
+\r
+ }\r
+\r
+}
\ No newline at end of file