summaryrefslogtreecommitdiff
path: root/tests/test_tools/selenium/php
diff options
context:
space:
mode:
authorxue <>2006-09-30 18:40:40 +0000
committerxue <>2006-09-30 18:40:40 +0000
commit1c32172efb18e8d08ea483e2460813670ebfe1a5 (patch)
tree8420f9e53eaba35d7b4822fac823197254f0d131 /tests/test_tools/selenium/php
parent6b1d87352911e43672b46b7a65a3c90dd8e5b8b1 (diff)
merge from 3.0 branch till 1451.
Diffstat (limited to 'tests/test_tools/selenium/php')
-rw-r--r--tests/test_tools/selenium/php/TestRunner.php304
-rw-r--r--tests/test_tools/selenium/php/TestSuiteHeader.php54
-rw-r--r--tests/test_tools/selenium/php/selenium.php103
3 files changed, 287 insertions, 174 deletions
diff --git a/tests/test_tools/selenium/php/TestRunner.php b/tests/test_tools/selenium/php/TestRunner.php
index a82ce0dd..54e46647 100644
--- a/tests/test_tools/selenium/php/TestRunner.php
+++ b/tests/test_tools/selenium/php/TestRunner.php
@@ -1,169 +1,161 @@
-
<html>
<head>
-<HTA:APPLICATION ID="SeleniumHTARunner" APPLICATIONNAME="Selenium" >
-<!-- the previous line is only relevant if you rename this
+ <HTA:APPLICATION ID="SeleniumHTARunner" APPLICATIONNAME="Selenium">
+ <!-- the previous line is only relevant if you rename this
file to "TestRunner.hta" -->
-<!-- The copyright notice and other comments have been moved to after the HTA declaration,
- to work-around a bug in IE on Win2K whereby the HTA application doesn't function correctly -->
-<!--
-Copyright 2004 ThoughtWorks, Inc
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
-
-<title>Selenium Functional Test Runner</title>
-<link rel="stylesheet" type="text/css" href="<?php echo $base_dir; ?>core/selenium.css" />
-<script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/scripts/selenium-browserdetect.js"></script>
-<script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/scripts/selenium-browserbot.js"></script>
-<script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/scripts/prototype-1.4.0.js"></script>
-<script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/scripts/find_matching_child.js"></script>
-<script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/scripts/selenium-api.js"></script>
-<script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/scripts/selenium-commandhandlers.js"></script>
-<script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/scripts/selenium-executionloop.js"></script>
-<script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/scripts/selenium-testrunner.js"></script>
-<script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/scripts/selenium-logging.js"></script>
-<script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/scripts/selenium-version.js"></script>
-<script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/scripts/htmlutils.js"></script>
-<script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/xpath/misc.js"></script>
-<script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/xpath/dom.js"></script>
-<script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/xpath/xpath.js"></script>
-<script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>prado-functional-test.js"></script>
-<script language="JavaScript" type="text/javascript">
- function openDomViewer() {
- var autFrame = document.getElementById('myiframe');
- var autFrameDocument = getIframeDocument(autFrame);
- this.rootDocument = autFrameDocument;
- var domViewer = window.open('<?php echo $base_dir; ?>core/domviewer/domviewer.html');
- return false;
- }
-
- Logger.prototype.openLogWindow = function()
- {
- this.logWindow = window.open(
- "<?php echo $base_dir; ?>core/SeleniumLog.html", "SeleniumLog",
- "width=600,height=250,bottom=0,right=0,status,scrollbars,resizable"
- );
- return this.logWindow;
- }
-
- var post_results_to = "<?php echo $driver; ?>";
-
-</script>
+ <!-- The copyright notice and other comments have been moved to after the HTA declaration,
+to work-around a bug in IE on Win2K whereby the HTA application doesn't function correctly -->
+ <!--
+ Copyright 2004 ThoughtWorks, Inc
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+ <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"/>
+
+ <title>Selenium Functional Test Runner</title>
+ <link rel="stylesheet" type="text/css" href="<?php echo $base_dir; ?>core/selenium.css"/>
+ <script type="text/javascript" src="<?php echo $base_dir; ?>core/scripts/narcissus-defs.js"></script>
+ <script type="text/javascript" src="<?php echo $base_dir; ?>core/scripts/narcissus-parse.js"></script>
+ <script type="text/javascript" src="<?php echo $base_dir; ?>core/scripts/narcissus-exec.js"></script>
+ <script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/lib/prototype.js"></script>
+ <script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/lib/scriptaculous/scriptaculous.js"></script>
+ <script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/lib/cssQuery/cssQuery-p.js"></script>
+ <script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/scripts/selenium-browserdetect.js"></script>
+ <script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/scripts/selenium-browserbot.js"></script>
+ <script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/scripts/find_matching_child.js"></script>
+ <script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/scripts/htmlutils.js"></script>
+ <script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/scripts/selenium-api.js"></script>
+ <script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/scripts/selenium-commandhandlers.js"></script>
+ <script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/scripts/selenium-executionloop.js"></script>
+ <script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/scripts/selenium-testrunner.js"></script>
+ <script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/scripts/selenium-logging.js"></script>
+ <script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/scripts/selenium-version.js"></script>
+ <script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/xpath/misc.js"></script>
+ <script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/xpath/dom.js"></script>
+ <script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/xpath/xpath.js"></script>
+ <script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>prado-functional-test.js"></script>
+
+ <script language="JavaScript" type="text/javascript">
+ var post_results_to = "<?php echo $driver; ?>";
+ </script>
</head>
-<body onLoad="start();">
+<body onLoad="onSeleniumLoad();">
+<table class="layout">
+<form action="" name="controlPanel">
+
+<!-- Suite, Test, Control Panel -->
+<tr class="selenium">
+<td width="25%" height="15%">
+ <iframe name="testSuiteFrame" id="testSuiteFrame" src="<?php echo $driver; ?>?testSuites" application="yes"></iframe>
+</td>
+<td width="50%" height="15%">
+ <iframe name="testFrame" id="testFrame" application="yes"></iframe>
+</td>
+
+<td width="25%">
<table class="layout">
- <form action="" name="controlPanel">
-
- <!-- Suite, Test, Control Panel -->
-
- <tr class="selenium">
- <td width="25%" height="30%" ><iframe name="testSuiteFrame" id="testSuiteFrame" src="<?php echo $driver; ?>?testSuites" application="yes"></iframe></td>
- <td width="50%" height="30%" ><iframe name="testFrame" id="testFrame" application="yes"></iframe></td>
-
- <td width="25%">
- <table class="layout">
- <tr class="selenium">
- <th width="25%" height="1" class="header">
- <h3><a href="http://selenium.thoughtworks.com" title="The Selenium Project">Selenium</a></h3>
- </th>
- </tr>
- <tr>
- <td width="25%" height="30%" id="controlPanel">
-
- <fieldset>
- <legend>Execute Tests</legend>
-
- <div>
- <input id="modeRun" type="radio" name="runMode" value="0" checked="checked"/><label for="modeRun">Run</label>
- <input id="modeWalk" type="radio" name="runMode" value="500" /><label for="modeWalk">Walk</label>
- <input id="modeStep" type="radio" name="runMode" value="-1" /><label for="modeStep">Step</label>
- </div>
-
- <div>
- <button type="button" id="runSuite" onClick="startTestSuite();"
- title="Run the entire Test-Suite">
- <strong>All</strong>
- </button>
- <button type="button" id="runTest" onClick="runSingleTest();"
- title="Run the current Test">
- <em>Selected</em>
- </button>
- <button type="button" id="continueTest" disabled="disabled"
- title="Continue the Test">
- Continue
- </button>
- </div>
-
- </fieldset>
-
- <table id="stats" align="center">
- <tr>
- <td colspan="2" align="right">Elapsed:</td>
- <td id="elapsedTime" colspan="2">00.00</td>
- </tr>
- <tr>
- <th colspan="2">Tests</th>
- <th colspan="2">Commands</th>
- </tr>
- <tr>
- <td class="count" id="testRuns">0</td>
- <td>run</td>
- <td class="count" id="commandPasses">0</td>
- <td>passed</td>
- </tr>
- <tr>
- <td class="count" id="testFailures">0</td>
- <td>failed</td>
- <td class="count" id="commandFailures">0</td>
- <td>failed</td>
- </tr>
- <tr>
- <td colspan="2"></td>
- <td class="count" id="commandErrors">0</td>
- <td>incomplete</td>
- </tr>
- </table>
- <!--
- <fieldset>
- <legend>Tools</legend>
- <button type="button" id="domViewer1" onClick="openDomViewer();">
- View DOM
- </button>
- <button type="button" onClick="LOG.show();">
- Show Log
- </button>
-
- </fieldset>
- -->
- </td>
- </tr>
- </table>
- </td>
- </tr>
-
- <!-- AUT -->
-
- <tr>
- <td colspan="3" height="70%"><iframe name="myiframe" id="myiframe" src="<?php echo $base_dir; ?>core/TestRunner-splash.html"></iframe></td>
- </tr>
+ <tr class="selenium">
+ <th width="25%" height="1" class="header">
+ <h1><a href="http://selenium.thoughtworks.com" title="The Selenium Project">Selenium</a> TestRunner
+ </h1>
+ </th>
+ </tr>
+ <tr>
+ <td width="25%" height="15%" id="controlPanel">
+ <fieldset>
+ <legend>Execute Tests</legend>
+
+ <div style="float:left">Fast</div>
+ <div style="float:right">Slow</div>
+ <br>
+ <div id="speedSlider">
+ <div id="speedTrack">&nbsp;</div>
+ <div id="speedHandle">&nbsp;</div>
+ </div>
+
+ <div>
+ <button type="button" id="runSuite" onClick="htmlTestRunner.startTestSuite();"
+ title="Run the entire Test-Suite">
+ <strong>All</strong>
+ </button>
+ <button type="button" id="runSeleniumTest" onClick="htmlTestRunner.runSingleTest();"
+ title="Run the current Test">
+ <em>Selected</em>
+ </button>
+ <button type="button" id="pauseTest" disabled="disabled"
+ title="Pause the current Test">
+ Pause
+ </button>
+ <button type="button" id="stepTest" disabled="disabled"
+ title="Step the Test">
+ Step
+ </button>
+ </div>
+
+ <div class="executionOptions">
+ <input id="highlightOption" type="checkbox" name="highlightOption" value="0" checked="checked"/>
+ <label for="highlightOption">Highlight elements</label>
+ </div>
+
+ </fieldset>
+
+ <table id="stats" align="center">
+ <tr>
+ <td colspan="2" align="right">Elapsed:</td>
+ <td id="elapsedTime" colspan="2">00.00</td>
+ </tr>
+ <tr>
+ <th colspan="2">Tests</th>
+ <th colspan="2">Commands</th>
+ </tr>
+ <tr>
+ <td class="count" id="testRuns">0</td>
+ <td>run</td>
+ <td class="count" id="commandPasses">0</td>
+ <td>passed</td>
+ </tr>
+ <tr>
+ <td class="count" id="testFailures">0</td>
+ <td>failed</td>
+ <td class="count" id="commandFailures">0</td>
+ <td>failed</td>
+ </tr>
+ <tr>
+ <td colspan="2"></td>
+ <td class="count" id="commandErrors">0</td>
+ <td>incomplete</td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+</td>
+</tr>
+
+<!-- AUT -->
+
+<tr>
+ <td colspan="3" height="70%">
+ <iframe name="myiframe" id="myiframe" src="<?php echo $base_dir; ?>core/TestRunner-splash.html"></iframe>
+ </td>
+</tr>
+
</form>
</table>
</body>
-</html> \ No newline at end of file
+</html>
diff --git a/tests/test_tools/selenium/php/TestSuiteHeader.php b/tests/test_tools/selenium/php/TestSuiteHeader.php
new file mode 100644
index 00000000..6fe2f6b6
--- /dev/null
+++ b/tests/test_tools/selenium/php/TestSuiteHeader.php
@@ -0,0 +1,54 @@
+<!--
+Copyright 2004 ThoughtWorks, Inc
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<html>
+<head>
+<meta content="text/html; charset=ISO-8859-1"
+http-equiv="content-type">
+<title>Test Suite</title>
+<link rel="stylesheet" type="text/css" href="<?php echo $base_dir; ?>core/selenium.css" />
+<script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/scripts/selenium-browserdetect.js"></script>
+<script language="JavaScript" type="text/javascript">
+ var DISABLED = true; // used to flag failing tests
+
+ function filterTestsForBrowser() {
+ var suiteTable = document.getElementById("suiteTable");
+ var skippedTests = document.getElementById("skippedTests");
+
+ for(rowNum = suiteTable.rows.length - 1; rowNum >= 0; rowNum--)
+ {
+ var row = suiteTable.rows[rowNum];
+ var filterString = row.getAttribute("unless");
+ if (filterString && eval(filterString))
+ {
+ var cellHTML = row.cells[0].innerHTML;
+ suiteTable.deleteRow(rowNum);
+
+ var newRow = skippedTests.insertRow(1);
+ var newCell = newRow.insertCell(0)
+ newCell.innerHTML = cellHTML;
+ }
+ }
+ }
+</script>
+</head>
+
+<body onload="filterTestsForBrowser()">
+
+ <table id="suiteTable" cellpadding="1"
+ cellspacing="1"
+ border="1"
+ class="selenium">
+ <tbody>
diff --git a/tests/test_tools/selenium/php/selenium.php b/tests/test_tools/selenium/php/selenium.php
index 683bcaa2..fcbbe562 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