click_button in selenium works now same as in headless mode

This commit is contained in:
Matthias Marschall 2009-05-27 14:02:09 +02:00 committed by mike.gaffney
parent 6fc6530a6b
commit 73dc59cc29

View File

@ -1,12 +1,19 @@
if (locator == '*') {
return selenium.browserbot.locationStrategies['xpath'].call(this, "//input[@type='submit']", inDocument, inWindow)
}
var buttons = inDocument.getElementsByTagName('button');
var inputs = inDocument.getElementsByTagName('input');
return $A(inputs).find(function(candidate){
inputType = candidate.getAttribute('type');
if (inputType == 'submit' || inputType == 'image') {
var buttonText = $F(candidate);
return (PatternMatcher.matches(locator, buttonText));
}
return false;
var result = $A(inputs).concat($A(buttons)).find(function(candidate){
var type = candidate.getAttribute('type');
if (type == 'submit' || type == 'image' || type == 'button') {
var matches_id = PatternMatcher.matches(locator, candidate.id);
var matches_value = PatternMatcher.matches(locator, candidate.value);
var matches_html = PatternMatcher.matches(locator, candidate.innerHTML);
var matches_alt = PatternMatcher.matches(locator, candidate.alt);
if (matches_id || matches_value || matches_html || matches_alt) {
return true;
}
}
return false;
});
return result;