Created
July 10, 2010 07:20
-
-
Save miau/470537 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Small extension for Selenium tests. | |
* | |
* This extension will find any comments in the table with tests and makes them | |
* visible by inserting new table rows with comment text. | |
* Selenium Test Runner will ignore this new inserted rows. | |
* | |
* Before: | |
* <!--Comment text--> | |
* | |
* After: | |
* <tr><td colspan="3" class="comment">Comment text</td></tr> | |
* <!--Comment text--> | |
* | |
* HeadWing | Seleniumでコメントを入れる方法 | |
* http://blog.headwing.com/2007/05/19/selenium-comment-for-testrunner/ | |
*/ | |
var makeCommentsVisible = function(doc) { | |
try { var tbody = doc.getElementsByTagName("table")[0].tBodies[0]; } catch(e) { return; }; | |
var nodes = tbody.childNodes; | |
for (i = 0; i < nodes.length; i++) { | |
var node = nodes[i]; | |
if (node.nodeType == 8) { // comment | |
var row = doc.createElement("TR"); | |
var cell = doc.createElement("TD"); | |
var colspan = doc.createAttribute("colspan"); | |
colspan.nodeValue = 3; | |
cell.setAttributeNode(colspan); | |
var className = doc.createAttribute("class"); | |
className.nodeValue = "comment"; | |
cell.setAttributeNode(className); | |
var text = doc.createTextNode(node.nodeValue); | |
cell.appendChild(text); | |
row.appendChild(cell); | |
tbody.insertBefore(row, node); | |
i++; | |
} | |
} | |
} | |
// make comments visible on test case page load | |
HtmlTestCase.prototype.initialize_old = HtmlTestCase.prototype.initialize; | |
objectExtend(HtmlTestCase.prototype, { | |
initialize: function(testDocument, htmlTestSuiteRow) { | |
this.initialize_old(testDocument, htmlTestSuiteRow); | |
makeCommentsVisible(testDocument); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
HeadWing | Seleniumでコメントを入れる方法
http://blog.headwing.com/2007/05/19/selenium-comment-for-testrunner/
で公開されていたファイルをインデントしなおしただけです。