Index: openacs-4/packages/acs-automated-testing/www/doc/xml/selenium.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-automated-testing/www/doc/xml/selenium.xml,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-automated-testing/www/doc/xml/selenium.xml 17 Sep 2009 15:57:02 -0000 1.1 +++ openacs-4/packages/acs-automated-testing/www/doc/xml/selenium.xml 17 Sep 2009 16:20:40 -0000 1.2 @@ -8,44 +8,46 @@ by Dave Bauer - - To use Selenium Remote Control to run browser-based tested from - acs-automated-testing first install Selenium Remote - Control. Download + + + To use Selenium Remote Control to run browser-based tested from + acs-automated-testing first install Selenium Remote + Control. Download Selenium RC. This requires a working Java - configuration. See Selenium + configuration. See Selenium RC Documentation and specifically Selenium + http://seleniumhq.org/docs/05_selenium_rc.html#installation">Selenium RC Installation. - - You can record tests to Tcl code that will run in - acs-automated-testing by adding the a Tcl-RC mode in Selenium-IDE. - + - Open up Firefox, click on Tools, select Selenium IDE, select - Options, then Options again. Click on the formats tab. Click add. - Name the format "Tcl-Rc". Paste the following code in the large - box. - + You can record tests to Tcl code that will run in + acs-automated-testing by adding the a Tcl-RC mode in Selenium-IDE. + + + Open up Firefox, click on Tools, select Selenium IDE, select + Options, then Options again. Click on the formats tab. Click add. + Name the format "Tcl-Rc". Paste the following code in the large + box. + /* * Format for Selenium Remote Control Python client. */ load('remoteControl.js'); -this.name = "tcl-rc"; +this.name = "tcl-rc"; function testMethodName(testName) { - return "test_" + underscore(testName); + return "test_" + underscore(testName); } notOperator = function() { - return "! "; + return "! "; } tclString = function(value) { value = value.replace(/\\/g, '\\\\'); - value = value.replace(/\"/g, '\\"'); + value = value.replace(/\"/g, '\\"'); value = value.replace(/\r/g, '\\r'); value = value.replace(/\n/g, '\\n'); value = value.replace(/\{/g, '\\{'); @@ -60,15 +62,15 @@ unicode = true; } } - return (unicode ? 'u' : '') + '"' + value + '"'; + return (unicode ? 'u' : '') + '"' + value + '"'; } function assertTrue(expression) { - return "aa_true " + tclString(expression.toString()) + " [expr {![catch {" + expression.toString() + "} errmsg]}]"; + return "aa_true " + tclString(expression.toString()) + " [expr {![catch {" + expression.toString() + "} errmsg]}]"; } function assertFalse(expression) { - return "aa_false " + tclString(expression.toString()) + " [expr {![catch {" + expression.toString() + "} errmsg]}]"; + return "aa_false " + tclString(expression.toString()) + " [expr {![catch {" + expression.toString() + "} errmsg]}]"; } function verify(statement) { @@ -84,27 +86,27 @@ } function joinExpression(expression) { - return "join " + expression.toString(); + return "join " + expression.toString(); } function assignToVariable(type, variable, expression) { - return "set " + underscore(variable) + " [" + expression.toString() + "]"; + return "set " + underscore(variable) + " [" + expression.toString() + "]"; } function waitFor(expression) { - return "for {set i 0} {i < " + expression.toString() + "} {incr i} {\n" - + "if {" + expression.toString() + "} {break}\n" - + "after 1000\n" - + "}\n" - + "if {$i == 60} {error \"time out\"}"; + return "for {set i 0} {i < " + expression.toString() + "} {incr i} {\n" + + "if {" + expression.toString() + "} {break}\n" + + "after 1000\n" + + "}\n" + + "if {$i == 60} {error \"time out\"}"; } function assertOrVerifyFailure(line, isAssert) { - return "" + line + "} errmsg]} {error \"expected failure\"}"; + return "" + line + "} errmsg]} {error \"expected failure\"}"; } Equals.prototype.toString = function() { - return this.e1.toString() + " eq " + this.e2.toString(); + return this.e1.toString() + " eq " + this.e2.toString(); } Equals.prototype.assert = function() { @@ -116,11 +118,11 @@ } NotEquals.prototype.toString = function() { - return this.e1.toString() + " ne " + this.e2.toString(); + return this.e1.toString() + " ne " + this.e2.toString(); } NotEquals.prototype.assert = function() { - return "aa_true " + tclString(this.e1.toString() + " ne " + this.e2.toString()) + " [expr {" + this.e1.toString() + " ne " + this.e2.toString() + "}]"; + return "aa_true " + tclString(this.e1.toString() + " ne " + this.e2.toString()) + " [expr {" + this.e1.toString() + " ne " + this.e2.toString() + "}]"; } NotEquals.prototype.verify = function() { @@ -129,23 +131,23 @@ RegexpMatch.prototype.toString = function() { var str = this.pattern; - if (str.match(/\"/) || str.match(/\n/)) { - str = str.replace(/\\/g, "\\\\"); - str = str.replace(/\"/g, '\\"'); + if (str.match(/\"/) || str.match(/\n/)) { + str = str.replace(/\\/g, "\\\\"); + str = str.replace(/\"/g, '\\"'); str = str.replace(/\n/g, '\\n'); - return '"' + str + '"'; + return '"' + str + '"'; } else { - str = 'r"' + str + '"'; + str = 'r"' + str + '"'; } - return "re.search(" + str + ", " + this.expression + ")"; + return "re.search(" + str + ", " + this.expression + ")"; } function pause(milliseconds) { - return "after " + milliseconds; + return "after " + milliseconds; } function echo(message) { - return "aa_log " + xlateArgument(message); + return "aa_log " + xlateArgument(message); } function statement(expression) { @@ -156,14 +158,14 @@ var str = '[lst '; for (var i = 0; i < value.length; i++) { str += string(value[i]); - if (i < value.length - 1) str += " "; + if (i < value.length - 1) str += " "; } str += ']'; return str; } function nonBreakingSpace() { - return "u\"\\u00a0\""; + return "u\"\\u00a0\""; } CallSelenium.prototype.toString = function() { @@ -186,7 +188,7 @@ function formatComment(comment) { return comment.comment.replace(/.+/mg, function(str) { - return "# " + str; + return "# " + str; }); } @@ -199,16 +201,15 @@ this.configForm = '<description>Variable for Selenium instance</description>' + '<description>Header</description>' + - '<textbox id="options_header" multiline="true" flex="1" rows="4"/>' + + '<textbox id="options_header" multiline="true" flex="1" rows="4"/>' + '<description>Footer</description>' + - '<textbox id="options_footer" multiline="true" flex="1" rows="4"/>'; - </programlisting> + '<textbox id="options_footer" multiline="true" flex="1" rows="4"/>'; + You may also refer to the Selenese Commands Documentation which may give some hints to writing tests. - - - + +