Sha256: 239988c79243e77b303284d885a9f5f87406d52df4370b9370726b7165d8efaf

Contents?: true

Size: 747 Bytes

Versions: 4

Compression:

Stored size: 747 Bytes

Contents

var allLabels = inDocument.getElementsByTagName("label");
var candidateLabels = $A(allLabels).select(function(candidateLabel){
  var labelText = getText(candidateLabel).strip();
  return labelText.toLowerCase() == locator.toLowerCase();
});
if (candidateLabels.length == 0) {
  return null;      
}
candidateLabels = candidateLabels.sortBy(function(s) { return s.length * -1; }); //reverse length sort
var locatedLabel = candidateLabels.first();
var labelFor = locatedLabel.getAttribute('for');
if ((labelFor == null) && (locatedLabel.hasChildNodes())) {
  return locatedLabel.firstChild; //TODO: should find the first form field, not just any node
}
return selenium.browserbot.locationStrategies['id'].call(this, labelFor, inDocument, inWindow);

Version data entries

4 entries across 4 versions & 4 rubygems

Version Path
aslakhellesoy-webrat-0.4.4.1 lib/webrat/selenium/location_strategy_javascript/label.js
davidtrogers-webrat-0.4.4.2 lib/webrat/selenium/location_strategy_javascript/label.js
diabolo-webrat-0.4.4.2 lib/webrat/selenium/location_strategy_javascript/label.js
raldred-webrat-0.4.4.2 lib/webrat/selenium/location_strategy_javascript/label.js