Skip to content

Instantly share code, notes, and snippets.

@miau
Created July 10, 2010 07:20
Show Gist options
  • Save miau/470537 to your computer and use it in GitHub Desktop.
Save miau/470537 to your computer and use it in GitHub Desktop.
/**
* 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);
}
});
@miau
Copy link
Author

miau commented Jul 10, 2010

HeadWing | Seleniumでコメントを入れる方法
http://blog.headwing.com/2007/05/19/selenium-comment-for-testrunner/

で公開されていたファイルをインデントしなおしただけです。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment