Sha256: d26d001345ff2e1235d3d525b0d8267c1bb0046687a03285798ded08958b12c1

Contents?: true

Size: 785 Bytes

Versions: 91

Compression:

Stored size: 785 Bytes

Contents

var allLabels = inDocument.getElementsByTagName("label");
var candidateLabels = $A(allLabels).select(function(candidateLabel){
  var regExp = new RegExp('^' + locator + '\\b', 'i');
  var labelText = getText(candidateLabel).strip();
  return (labelText.search(regExp) >= 0);
});
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

91 entries across 91 versions & 28 rubygems

Version Path
jferris-webrat-0.4.3 lib/webrat/selenium/location_strategy_javascript/label.js
jwilger-webrat-0.4.2.1 lib/webrat/selenium/location_strategy_javascript/label.js
jwilger-webrat-0.4.2.2 lib/webrat/selenium/location_strategy_javascript/label.js
jwilger-webrat-0.4.2.3 lib/webrat/selenium/location_strategy_javascript/label.js
jwilger-webrat-0.4.2.4 lib/webrat/selenium/location_strategy_javascript/label.js
jwilger-webrat-0.4.2.5 lib/webrat/selenium/location_strategy_javascript/label.js
jwilger-webrat-0.4.2 lib/webrat/selenium/location_strategy_javascript/label.js
jwilger-webrat-0.4.3.2 lib/webrat/selenium/location_strategy_javascript/label.js
jwilger-webrat-0.4.3.3 lib/webrat/selenium/location_strategy_javascript/label.js
jwilger-webrat-0.4.3.4 lib/webrat/selenium/location_strategy_javascript/label.js
jwilger-webrat-0.4.4.2 lib/webrat/selenium/location_strategy_javascript/label.js
jwilger-webrat-0.4.4.3 lib/webrat/selenium/location_strategy_javascript/label.js
jwilger-webrat-0.4.4.4 lib/webrat/selenium/location_strategy_javascript/label.js
jwilger-webrat-0.4.4.5 lib/webrat/selenium/location_strategy_javascript/label.js
mattwynne-cucover-0.1.0 examples/self_test/rails/vendor/gems/webrat-0.4.4/lib/webrat/selenium/location_strategy_javascript/label.js
mattwynne-cucover-0.1.1 examples/self_test/rails/vendor/gems/webrat-0.4.4/lib/webrat/selenium/location_strategy_javascript/label.js
mmurphy-webrat-0.4.4 lib/webrat/selenium/location_strategy_javascript/label.js
ohammersmith-webrat-0.4.4.100 lib/webrat/selenium/location_strategy_javascript/label.js
ohammersmith-webrat-0.4.4.98 lib/webrat/selenium/location_strategy_javascript/label.js
sr-webrat-0.4.4.1 lib/webrat/selenium/location_strategy_javascript/label.js