Fix selenium webrat tests in FF/Safari -- locatedLabel.htmlFor returns empty string in FF/Safari which breaks location strategy for label
This commit is contained in:
parent
68d5fde17a
commit
80ea640901
@ -10,7 +10,7 @@ RegExp.escape = function(text) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
return text.replace(arguments.callee.sRE, '\\$1');
|
return text.replace(arguments.callee.sRE, '\\$1');
|
||||||
}
|
};
|
||||||
|
|
||||||
var allLabels = inDocument.getElementsByTagName("label");
|
var allLabels = inDocument.getElementsByTagName("label");
|
||||||
var regExp = new RegExp('^\\W*' + RegExp.escape(locator) + '(\\b|$)', 'i');
|
var regExp = new RegExp('^\\W*' + RegExp.escape(locator) + '(\\b|$)', 'i');
|
||||||
@ -30,7 +30,13 @@ candidateLabels = candidateLabels.sortBy(function(s) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var locatedLabel = candidateLabels.first();
|
var locatedLabel = candidateLabels.first();
|
||||||
var labelFor = locatedLabel.getAttribute('for') || locatedLabel.htmlFor;
|
var labelFor = null;
|
||||||
|
|
||||||
|
if (locatedLabel.getAttribute('for')) {
|
||||||
|
labelFor = locatedLabel.getAttribute('for');
|
||||||
|
} else if (locatedLabel.attributes['for']) { // IE
|
||||||
|
labelFor = locatedLabel.attributes['for'].nodeValue;
|
||||||
|
}
|
||||||
|
|
||||||
if ((labelFor == null) && (locatedLabel.hasChildNodes())) {
|
if ((labelFor == null) && (locatedLabel.hasChildNodes())) {
|
||||||
return locatedLabel.getElementsByTagName('button')[0]
|
return locatedLabel.getElementsByTagName('button')[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user