From 46ced27dbdc8a0806f5c90dbf56b6639eeeb6fe8 Mon Sep 17 00:00:00 2001 From: Luke Melia Date: Mon, 13 Oct 2008 14:23:48 -0400 Subject: [PATCH] Minor selenium_session updates to alias #visits as #visit, fix the constructor, and successfully locate a field whose label is it's parent. -Lee Bankewitz & Luke Melia --- lib/webrat/selenium/selenium_session.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/webrat/selenium/selenium_session.rb b/lib/webrat/selenium/selenium_session.rb index e4b9ab0..e2cb766 100644 --- a/lib/webrat/selenium/selenium_session.rb +++ b/lib/webrat/selenium/selenium_session.rb @@ -2,7 +2,7 @@ module Webrat class SeleniumSession < Session def initialize(selenium_driver) - super + super() @selenium = selenium_driver define_location_strategies end @@ -11,6 +11,8 @@ module Webrat @selenium.open(url) end + alias_method :visit, :visits + def fills_in(field_identifier, options) locator = "webrat=#{Regexp.escape(field_identifier)}" @selenium.type(locator, "#{options[:with]}") @@ -99,6 +101,9 @@ module Webrat 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); JS