[prev in list] [next in list] [prev in thread] [next in thread]
List: selenium-commits
Subject: [Selenium-commits] [610] trunk/code/javascript: Replacing
From: dkemp () codehaus ! org
Date: 2005-08-13 9:16:05
Message-ID: 20050813091605.12649.qmail () codehaus ! org
[Download RAW message or body]
[Attachment #2 (text/html)]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><style type="text/css"><!--
body {background:#ffffff;font-family:Verdana,Helvetica,Arial,sans-serif;}
h3 {margin:15px 0;padding:0;line-height:0;}
#msg {margin: 0 0 2em 0;}
#msg dl, #msg ul, #msg pre {padding:1em;border:1px dashed black;margin: 10px 0 30px \
0;} #msg dl {background:#ccccff;}
#msg pre {background:#ffffcc;}
#msg ul {background:#cc99ff;list-style:none;}
#msg dt {font-weight:bold;float:left;width: 6em;}
#msg dt:after { content:':';}
#patch h4 {padding: 0 \
10px;line-height:1.5em;margin:0;background:#ccffff;border-bottom:1px solid \
black;margin:0 0 10px 0;} #patch .propset h4, #patch .binary h4 {margin: 0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {background:#eeeeee;padding: 0 0 10px 0;}
#patch .propset .diff, #patch .binary .diff {padding: 10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary \
{border:1px solid black;margin:10px 0;} #patch .add {background:#ddffdd;}
#patch .rem {background:#ffdddd;}
#patch .lines, .info {color:#888888;background:#ffffff;}
--></style>
<title>[610] trunk/code/javascript: Replacing assertText, assertAttribute, and \
assertTable with getText, getAttribute, and getTable</title> </head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd>610</dd>
<dt>Author</dt> <dd>dkemp</dd>
<dt>Date</dt> <dd>2005-08-13 05:16:04 -0400 (Sat, 13 Aug 2005)</dd>
</dl>
<h3>Log Message</h3>
<pre>Replacing assertText, assertAttribute, and assertTable with getText, \
getAttribute, and getTable</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkcodejavascripthtmlutilsjs">trunk/code/javascript/htmlutils.js</a></li>
<li><a href="#trunkcodejavascriptseleniumapijs">trunk/code/javascript/selenium-api.js</a></li>
<li><a href="#trunkcodejavascriptseleniumbrowserbotjs">trunk/code/javascript/selenium-browserbot.js</a></li>
<li><a href="#trunkcodejavascripttestsbrowserbotseleniumapitestshtml">trunk/code/javascript/tests/browserbot/selenium-api-tests.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkcodejavascripthtmlutilsjs"></a>
<div class="modfile"><h4>Modified: trunk/code/javascript/htmlutils.js (609 => \
610)</h4> <pre class="diff">
<span class="info">--- trunk/code/javascript/htmlutils.js 2005-08-07 13:21:16 UTC \
(rev 609)
+++ trunk/code/javascript/htmlutils.js 2005-08-13 09:16:04 UTC (rev 610)
</span><span class="lines">@@ -275,3 +275,9 @@
</span><span class="cx"> this.isAssertionFailedError = true;
this.failureMessage = message;
}
</span><span class="add">+
+function SeleniumError(message) {
+ var error = new Error(message);
+ error.isSeleniumError = true;
+ return error;
+};
</span></pre></div>
<a id="trunkcodejavascriptseleniumapijs"></a>
<div class="modfile"><h4>Modified: trunk/code/javascript/selenium-api.js (609 => \
610)</h4> <pre class="diff">
<span class="info">--- trunk/code/javascript/selenium-api.js 2005-08-07 13:21:16 UTC \
(rev 609)
+++ trunk/code/javascript/selenium-api.js 2005-08-13 09:16:04 UTC (rev 610)
</span><span class="lines">@@ -192,26 +192,26 @@
</span><span class="cx"> return getInputValue(element).trim();
}
</span><span class="rem">-/*
- * Verifies that the text of the located element matches the expected content.
</span><span class="add">+/**
+ * Get the (trimmed) text of a form element.
+ * This is used to generate assertText, verifyText, ...
</span><span class="cx"> */
</span><span class="rem">-Selenium.prototype.assertText = function(locator, \
expectedContent) { </span><span class="add">+Selenium.prototype.getText = \
function(locator) { </span><span class="cx"> var element = \
this.page().findElement(locator); </span><span class="rem">- var actualText = \
getText(element);
- Assert.matches(expectedContent, actualText.trim());
</span><span class="add">+ return getText(element).trim();
</span><span class="cx"> };
/*
</span><span class="rem">- * Asserts that the text for a single cell within and HTML \
table matches the expected content. </span><span class="add">+ * Return the text for \
a single cell within an HTML table. </span><span class="cx"> * The table locator \
syntax is table.row.column.
*/
</span><span class="rem">-Selenium.prototype.assertTable = function(tableLocator, \
expectedContent) { </span><span class="add">+Selenium.prototype.getTable = \
function(tableLocator, expectedContent) { </span><span class="cx"> // This \
regular expression matches "tableName.row.column" // For example, \
"mytable.3.4" pattern = /(.*)\.(\d+)\.(\d+)/;
if(!pattern.test(tableLocator)) {
</span><span class="rem">- Assert.fail("Invalid target format. Correct \
format is tableName.rowNum.columnNum"); </span><span class="add">+ throw \
new SeleniumError("Invalid target format. Correct format is \
tableName.rowNum.columnNum"); </span><span class="cx"> }
pieces = tableLocator.match(pattern);
</span><span class="lines">@@ -229,7 +229,7 @@
</span><span class="cx"> }
else {
actualContent = getText(table.rows[row].cells[col]);
</span><span class="rem">- Assert.matches(expectedContent, \
actualContent.trim()); </span><span class="add">+ return actualContent.trim();
</span><span class="cx"> }
};
</span><span class="lines">@@ -266,12 +266,11 @@
</span><span class="cx"> };
/**
</span><span class="rem">- * Verify the value of an element attribute. The syntax for \
returning an element attribute
- * is <element-locator>@attribute-name
</span><span class="add">+ * Get the value of an element attribute. The syntax for \
returning an element attribute + * is <element-locator>@attribute-name. Used \
to generate assert, verify, assertNot... </span><span class="cx"> */
</span><span class="rem">-Selenium.prototype.assertAttribute = function(target, \
expected) {
- var attributeValue = this.page().findAttribute(target);
- Assert.matches(expected, attributeValue);
</span><span class="add">+Selenium.prototype.getAttribute = function(target) {
+ return this.page().findAttribute(target).trim();
</span><span class="cx"> };
/*
</span></pre></div>
<a id="trunkcodejavascriptseleniumbrowserbotjs"></a>
<div class="modfile"><h4>Modified: trunk/code/javascript/selenium-browserbot.js (609 \
=> 610)</h4> <pre class="diff">
<span class="info">--- trunk/code/javascript/selenium-browserbot.js 2005-08-07 \
13:21:16 UTC (rev 609)
+++ trunk/code/javascript/selenium-browserbot.js 2005-08-13 09:16:04 UTC (rev 610)
</span><span class="lines">@@ -907,9 +907,3 @@
</span><span class="cx"> PageBot.prototype.close = function() {
this.currentWindow.close();
};
</span><span class="rem">-
-function SeleniumError(message) {
- var error = new Error(message);
- error.isSeleniumError = true;
- return error;
-};
</span></pre></div>
<a id="trunkcodejavascripttestsbrowserbotseleniumapitestshtml"></a>
<div class="modfile"><h4>Modified: \
trunk/code/javascript/tests/browserbot/selenium-api-tests.html (609 => 610)</h4> <pre \
class="diff"> <span class="info">--- \
trunk/code/javascript/tests/browserbot/selenium-api-tests.html 2005-08-07 13:21:16 \
UTC (rev 609)
+++ trunk/code/javascript/tests/browserbot/selenium-api-tests.html 2005-08-13 \
09:16:04 UTC (rev 610) </span><span class="lines">@@ -154,23 +154,14 @@
</span><span class="cx"> verifyMocks();
}
</span><span class="rem">-function testVerifyTextSuccess() {
</span><span class="add">+function testGetText() {
</span><span class="cx"> var mockElement = new Object();
mockElement.textContent = " foo ";
mockPageBot.expects("findElement", \
"id").returns(mockElement); </span><span class="rem">- \
selenium.assertText("id", "foo"); </span><span class="add">+ \
assertEquals("foo", selenium.getText("id")); </span><span \
class="cx"> verifyMocks(); }
</span><span class="rem">-function testVerifyTextFailed() {
- var mockElement = new Object();
- mockElement.textContent = " foo ";
- mockPageBot.expects("findElement", \
"id").returns(mockElement);
-
- assertCallFails("Verify text should have failed",
- function() {selenium.assertText("id", \
"bar");});
-}
-
</span><span class="cx"> function getMockTable() {
var mockTable = new Object();
var row1 = new Object();
</span><span class="lines">@@ -187,41 +178,33 @@
</span><span class="cx"> return cell;
}
</span><span class="rem">-function testVerifyTableSuccess() {
</span><span class="add">+function testGetTableSuccess() {
</span><span class="cx"> mockPageBot.expects("findElement", \
"table").returns(getMockTable()); </span><span class="rem">- \
selenium.assertTable("table.1.1", "buz"); </span><span \
class="add">+ assertEquals("buz", \
selenium.getTable("table.1.1")); </span><span class="cx"> \
verifyMocks(); }
</span><span class="rem">-function testVerifyTableFailure() {
- mockPageBot.expects("findElement", \
"table").returns(getMockTable());
- assertCallFails("VerifyTable should have failed",
- function() {selenium.assertTable("table.0.0", \
"bar");},
- "Actual value 'foo' did not match 'bar'");
- verifyMocks();
-}
-
-function testVerifyTableInvalidLocator() {
- assertCallFails("VerifyTable should have failed for invalid locator",
- function() {selenium.assertTable("foo", \
"bar");}, </span><span class="add">+function testGetTableInvalidLocator() {
+ assertCallErrors("VerifyTable should have failed for invalid locator",
+ function() {selenium.getTable("foo");},
</span><span class="cx"> "Invalid target format. Correct \
format is tableName.rowNum.columnNum"); verifyMocks();
}
</span><span class="rem">-function testVerifyTableNoSuchRow() {
</span><span class="add">+function testGetTableNoSuchRow() {
</span><span class="cx"> var mockTable = getMockTable();
mockPageBot.expects("findElement", \
"table").returns(mockTable);
assertCallFails("VerifyTable should have failed for no such row",
</span><span class="rem">- function() \
{selenium.assertTable("table.11.0", "bar");}, </span><span \
class="add">+ function() \
{selenium.getTable("table.11.0", "bar");}, </span><span \
class="cx"> "Cannot access row 11 - table has 2 rows"); \
verifyMocks(); }
</span><span class="rem">-function testVerifyTableNoSuchColumn() {
</span><span class="add">+function testGetTableNoSuchColumn() {
</span><span class="cx"> var mockTable = getMockTable();
mockPageBot.expects("findElement", \
"table").returns(mockTable);
assertCallFails("VerifyTable should have failed for no such column",
</span><span class="rem">- function() \
{selenium.assertTable("table.0.11", "bar");}, </span><span \
class="add">+ function() \
{selenium.getTable("table.0.11", "bar");}, </span><span \
class="cx"> "Cannot access column 11 - table row has 2 \
columns"); verifyMocks();
}
</span><span class="lines">@@ -400,10 +383,10 @@
</span><span class="cx"> verifyMocks();
}
</span><span class="rem">-function testVerifyAttributeWithId() {
</span><span class="add">+function testGetAttributeWithId() {
</span><span class="cx"> mockPageBot.expects("findAttribute", \
"id@attribute").returns("foo");
</span><span class="rem">- selenium.assertAttribute("id@attribute", \
"foo"); </span><span class="add">+ assertEquals("foo", \
selenium.getAttribute("id@attribute")); </span><span class="cx"> \
verifyMocks(); }
</span><span class="lines">@@ -440,6 +423,17 @@
</span><span class="cx"> }
fail(message);
}
</span><span class="add">+function assertCallErrors(message, theCall, \
expectedFailureMessage) { + try {
+ theCall();
+ } catch (e) {
+ if (expectedFailureMessage) {
+ assertEquals(expectedFailureMessage, e.message);
+ }
+ return;
+ }
+ fail(message);
+}
</span><span class="cx"> </script>
</head>
<body>Selenium API Tests</body>
</span>
</pre>
</div>
</div>
</body>
</html>
_______________________________________________
Selenium-commits mailing list
Selenium-commits@lists.public.thoughtworks.org
http://lists.public.thoughtworks.org/mailman/listinfo/selenium-commits
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic