Permalink
Browse files

Adding rteID locator for testing rich text editors, and the xpath enh…

…ancement by cirwin

git-svn-id: http://svn.getwindmill.com/trunk@1351 78c7df6f-8922-0410-bcd3-9426b1ad491b
  • Loading branch information...
1 parent 7567f81 commit b203836e14a25e81cf7bb7450767b1eb9acaa692 admc committed Jul 29, 2009
Showing with 44 additions and 19 deletions.
  1. +39 −18 windmill/html/js/lib/getXPath.js
  2. +4 −0 windmill/html/js/wm/global.js
  3. +1 −1 windmill/html/js/wm/registry.js
@@ -5,28 +5,49 @@ function getXPath(node, path) {
if(node.parentNode) {
path = getXPath(node.parentNode, path);
}
-
- if(node.previousSibling) {
- var count = 1;
- var sibling = node.previousSibling
- do {
- if(sibling.nodeType == 1 && sibling.nodeName == node.nodeName) {count++;}
+
+ //patch from cirwin to more correctly record xpaths
+ var count = 1;
+ var sibling = node.previousSibling;
+ while (sibling) {
+ if (sibling.nodeType == 1 && sibling.nodeName == node.nodeName)
+ count++;
sibling = sibling.previousSibling;
- } while(sibling);
- if(count == 1) {count = null;}
- } else if(node.nextSibling) {
- var sibling = node.nextSibling;
- do {
- if(sibling.nodeType == 1 && sibling.nodeName == node.nodeName) {
- var count = 1;
- sibling = null;
- } else {
- var count = null;
- sibling = sibling.previousSibling;
+ }
+ if (count == 1) {
+ var more = false;
+ sibling = node.nextSibling;
+ while (sibling && !more) {
+ if (sibling.nodeType == 1 && sibling.nodeName == node.nodeName)
+ more = true;
+ sibling = sibling.nextSibling;
}
- } while(sibling);
+ if (!more)
+ count = -1;
}
+
+ // if(node.previousSibling) {
+ // var count = 1;
+ // var sibling = node.previousSibling
+ // do {
+ // if(sibling.nodeType == 1 && sibling.nodeName == node.nodeName) {count++;}
+ // sibling = sibling.previousSibling;
+ // } while(sibling);
+ // if(count == 1) {count = null;}
+ // } else if(node.nextSibling) {
+ // var sibling = node.nextSibling;
+ // do {
+ // if(sibling.nodeType == 1 && sibling.nodeName == node.nodeName) {
+ // var count = 1;
+ // sibling = null;
+ // } else {
+ // var count = null;
+ // sibling = sibling.previousSibling;
+ // }
+ // } while(sibling);
+ // }
+
if(node.nodeType == 1) {
path.push(node.nodeName.toLowerCase() + (node.id ? "[@id='"+node.id+"']" : count > 0 ? "["+count+"]" : ''));
}
@@ -90,6 +90,10 @@ var lookupNode = function (paramObject){
var theRest = paramObject.jquery.replace(chain[0],'');
element = eval('start'+theRest);
}
+ else if(typeof paramObject.rteID != "undefined"){
+ s = 'Looking up rte selector '+ paramObject.rte;
+ element = lookupNode({id:paramObject.rteID}).contentWindow.document.body;
+ }
else {
return false;
}
@@ -21,7 +21,7 @@ windmill.registry = new function () {
};
//Setup all the current methods supported
-windmill.registry.locator = ['id','link','xpath','jsid', 'name','value','classname', 'tagname','label','jquery'];
+windmill.registry.locator = ['id','link','xpath','jsid', 'name','value','classname', 'tagname','label','jquery', 'rteID'];
//windmill.registry.locator.push('id','link','xpath','jsid', 'name','classname', 'tagname');
for( var i=0; i<windmill.registry.locator.length;i++ ){

0 comments on commit b203836

Please sign in to comment.