summaryrefslogtreecommitdiff
path: root/tests/test_tools/selenium/php/selenium.php
diff options
context:
space:
mode:
authorwei <>2006-09-30 05:18:39 +0000
committerwei <>2006-09-30 05:18:39 +0000
commit7eafd95bfa21c9c8603e9c437a9d96dc880d92e7 (patch)
tree9ebe3012fc2a931a7a9e1d0c1b3eef33b1ed16ba /tests/test_tools/selenium/php/selenium.php
parent36a61db3144c111b722db89baf5a1d55c1c9a6b2 (diff)
Update selenium to 0.8
Diffstat (limited to 'tests/test_tools/selenium/php/selenium.php')
-rw-r--r--tests/test_tools/selenium/php/selenium.php103
1 files changed, 85 insertions, 18 deletions
diff --git a/tests/test_tools/selenium/php/selenium.php b/tests/test_tools/selenium/php/selenium.php
index 9ad4955b..1142458f 100644
--- a/tests/test_tools/selenium/php/selenium.php
+++ b/tests/test_tools/selenium/php/selenium.php
@@ -65,12 +65,23 @@ class SeleniumTestStorage
{
protected $outputs = array();
protected $tests = array();
+ protected $options=array();
public function getTests()
{
return $this->tests;
}
+ public function getOptions()
+ {
+ return $this->options;
+ }
+
+ public function addOption($test_name, $option)
+ {
+ $this->options[$test_name] = $option;
+ }
+
public function addCommand($test_case_id, $command)
{
$data = array($test_case_id, $command);
@@ -105,6 +116,11 @@ class SeleneseInterpreter
return $this->storage->getTests();
}
+ public function getOptions()
+ {
+ return $this->storage->getOptions();
+ }
+
public function getCommand()
{
$command = $this->storage->getCommand();
@@ -115,12 +131,15 @@ class SeleneseInterpreter
{
if($func{0} == '_') return;
+ $trace = debug_backtrace();
+ if($this->isTestOptionFunction($func,$args,$trace))
+ return;
+
$ID = isset($args[0]) ? $args[0] : "";
$value = isset($args[1]) ? $args[1] : "";
if(strpos(strtolower($func),'htmlpresent') || strpos(strtolower($func),'htmlnotpresent'))
$ID = htmlspecialchars($ID);
$command = array($func, $ID, $value);
- $trace = debug_backtrace();
if(is_int(strpos(strtolower($func), 'visible')))
$this->addCommand(array('pause','500',''),$trace);
@@ -128,6 +147,17 @@ class SeleneseInterpreter
return $this->addCommand($command, $trace);
}
+ protected function isTestOptionFunction($func,$args,$trace)
+ {
+ if(strtolower($func)==='skipcondition')
+ {
+ list($trace, $test, $suite) = $this->tracer->getTrace($trace);
+ $this->storage->addOption($test,$args[0]);
+ return true;
+ }
+ return false;
+ }
+
protected function addCommand($command, $trace)
{
list($trace, $test, $suite) = $this->tracer->getTrace($trace);
@@ -236,34 +266,26 @@ class SeleniumTestSuiteWriter
protected function renderHeader()
{
- $contents = <<<EOD
-<html>
-<head>
-<meta content="text/html; charset=UTF-8" http-equiv="content-type">
-<title>Test Suite</title>
+ $base_dir = $this->runner->getDriver().'?sr=';
-</head>
+ include(dirname(__FILE__).'/TestSuiteHeader.php');
-<body>
-
-<table cellpadding="1"
- cellspacing="1"
- border="1">
- <tbody>
+ $contents = <<<EOD
<tr><td><b>{$this->name}</b></td></tr>
EOD;
- return $contents;
+ echo $contents;
}
public function render()
{
- echo $this->renderHeader();
+ $this->renderHeader();
foreach($this->suites as $name => $suite)
{
$file = $suite[0]['trace']['file'];
$file = strtr($file,'\\','/');
+ $option = $suite[0]['option']===null?'':' unless="'.$suite[0]['option'].'" ';
$url = $this->runner->getDriver()."?case={$name}&file={$file}";
- echo "<tr>\n";
+ echo "<tr{$option}>\n";
echo "<td><a href=\"{$url}\">{$name}</a></td>\n";
echo "</tr>\n";
}
@@ -289,7 +311,18 @@ EOD;
{
$trace = '';//$this->getJsTraceInfo();
$contents = <<<EOD
- </tbody>
+ </tbody>
+ </table>
+
+ <br />
+ <em>Not supported in this browser</em>
+ <table id="skippedTests" cellpadding="1"
+ cellspacing="1"
+ border="1"
+ class="selenium">
+ <tbody>
+ <tr><td><b>Skipped Tests</b></td></tr>
+ </tbody>
</table>
<script type="text/javascript">
/*<![CDATA[*/
@@ -377,11 +410,14 @@ class SeleniumTestRunnerServer
protected function initialize($int)
{
+ $options = $int->getOptions();
foreach($int->getTests() as $command)
{
$case = $command[5];
+ $option=isset($options[$case])?$options[$case]:null;
$this->cases[$case][] =
- array('test' => $command[2], 'trace' => $command[4]);
+ array('test' => $command[2],
+ 'trace' => $command[4], 'option'=>$option);
if(is_null($this->name))
$this->name = $command[6];
}
@@ -449,6 +485,18 @@ class SeleniumTestCase extends UnitTestCase
protected $selenium;
protected $Page;
+ const KONQUEROR='browserVersion.isKonqueror';
+ const OPERA='browserVersion.isOpera';
+ const CHROME='browserVersion.isChrome';
+ const INTERNET_EXPLORER='browserVersion.isIE';
+ const SAFARI='browserVersion.isSafari';
+ const KHTML='browserVersion.khtml';
+ const FIREFOX='browserVersion.isFirefox';
+ const MOZILLA='browserVersion.isMozilla';
+ const GECKO='browserVersion.isGecko';
+
+ protected $options=array();
+
function __construct()
{
$server = SimpleSeleniumProxyServer::getInstance();
@@ -472,6 +520,25 @@ class SeleniumTestCase extends UnitTestCase
else if (count($args) == 2)
return $this->selenium->{$func}($args[0], $args[1]);
}
+
+ function disabled()
+ {
+ $this->selenium->skipCondition('DISABLED');
+ }
+
+ function skipBrowsers()
+ {
+ $arg_list = func_get_args();
+ $browsers=array();
+ foreach($arg_list as $arg)
+ {
+ if(is_array($arg))
+ $browsers[] = '('.implode(' && ', $arg).')';
+ else
+ $browsers[] = $arg;
+ }
+ $this->selenium->skipCondition(implode(' || ', $browsers));
+ }
}
?> \ No newline at end of file