From 65e968c37e87d8c837a0714bc27a97d604d2ac06 Mon Sep 17 00:00:00 2001 From: Luke Amdor Date: Thu, 14 May 2009 11:21:02 -0500 Subject: [PATCH] Fixed location strategy for clicking buttons to find button tags (not //inputs[type=button], but //button) and match based on textContent --- .../location_strategy_javascript/button.js | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/lib/webrat/selenium/location_strategy_javascript/button.js b/lib/webrat/selenium/location_strategy_javascript/button.js index add1679..0a7780b 100644 --- a/lib/webrat/selenium/location_strategy_javascript/button.js +++ b/lib/webrat/selenium/location_strategy_javascript/button.js @@ -1,6 +1,15 @@ if (locator == '*') { return selenium.browserbot.locationStrategies['xpath'].call(this, "//input[@type='submit']", inDocument, inWindow) } + +var buttons = inDocument.getElementsByTagName('button'); +var toClick = $A(buttons).find(function(candidate) { + return (PatternMatcher.matches(locator, candidate.value)); +}); +if (toClick) { + return toClick; +} + var inputs = inDocument.getElementsByTagName('input'); return $A(inputs).find(function(candidate){ inputType = candidate.getAttribute('type'); -- 1.6.2.38.ga54a