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
adva-0.2.4 test/webrat/lib/webrat/selenium/location_strategy_javascript/label.js
adva-0.2.3 test/webrat/lib/webrat/selenium/location_strategy_javascript/label.js
adva-0.2.2 test/webrat/lib/webrat/selenium/location_strategy_javascript/label.js
adva-0.2.1 test/webrat/lib/webrat/selenium/location_strategy_javascript/label.js
adva-0.2.0 test/webrat/lib/webrat/selenium/location_strategy_javascript/label.js
adva-0.1.4 test/webrat/lib/webrat/selenium/location_strategy_javascript/label.js
adva-0.1.3 test/webrat/lib/webrat/selenium/location_strategy_javascript/label.js
adva-0.1.2 test/webrat/lib/webrat/selenium/location_strategy_javascript/label.js
adva-0.1.1 test/webrat/lib/webrat/selenium/location_strategy_javascript/label.js
adva-0.1.0 test/webrat/lib/webrat/selenium/location_strategy_javascript/label.js
adva-0.0.1 test/webrat/lib/webrat/selenium/location_strategy_javascript/label.js
aslakhellesoy-webrat-0.3.2.1 lib/webrat/selenium/location_strategy_javascript/label.js
aslakhellesoy-webrat-0.3.2.2 lib/webrat/selenium/location_strategy_javascript/label.js
auxesis-webrat-0.4.1 lib/webrat/selenium/location_strategy_javascript/label.js
benschwarz-webrat-0.3.2.1 lib/webrat/selenium/location_strategy_javascript/label.js
brynary-webrat-0.3.2.1 lib/webrat/selenium/location_strategy_javascript/label.js
brynary-webrat-0.3.2.2 lib/webrat/selenium/location_strategy_javascript/label.js
brynary-webrat-0.4.0 lib/webrat/selenium/location_strategy_javascript/label.js
casebook-webrat-0.4.4.1 lib/webrat/selenium/location_strategy_javascript/label.js
cavalle-webrat-0.4.4.1 lib/webrat/selenium/location_strategy_javascript/label.js