Fix "element.getAttribute is not a function" Selenium errors when filling in fields
The root cause was the locator strategy was naively returning an element that was not a form field, causing Selenium's internals to blow up
This commit is contained in:
parent
3a9e7d3999
commit
c689166c48
@ -1,3 +1,4 @@
|
|||||||
|
// Credit to: http://simonwillison.net/2006/Jan/20/escape/
|
||||||
RegExp.escape = function(text) {
|
RegExp.escape = function(text) {
|
||||||
if (!arguments.callee.sRE) {
|
if (!arguments.callee.sRE) {
|
||||||
var specials = [
|
var specials = [
|
||||||
@ -32,8 +33,10 @@ var locatedLabel = candidateLabels.first();
|
|||||||
var labelFor = locatedLabel.getAttribute('for');
|
var labelFor = locatedLabel.getAttribute('for');
|
||||||
|
|
||||||
if ((labelFor == null) && (locatedLabel.hasChildNodes())) {
|
if ((labelFor == null) && (locatedLabel.hasChildNodes())) {
|
||||||
// TODO: should find the first form field, not just any node
|
return locatedLabel.getElementsByTagName('button')[0]
|
||||||
return locatedLabel.firstChild;
|
|| locatedLabel.getElementsByTagName('input')[0]
|
||||||
|
|| locatedLabel.getElementsByTagName('textarea')[0]
|
||||||
|
|| locatedLabel.getElementsByTagName('select')[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
return selenium.browserbot.locationStrategies['id'].call(this, labelFor, inDocument, inWindow);
|
return selenium.browserbot.locationStrategies['id'].call(this, labelFor, inDocument, inWindow);
|
||||||
|
Loading…
Reference in New Issue
Block a user