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
This commit is contained in:
parent
33fdf33c89
commit
46ced27dbd
@ -2,7 +2,7 @@ module Webrat
|
|||||||
class SeleniumSession < Session
|
class SeleniumSession < Session
|
||||||
|
|
||||||
def initialize(selenium_driver)
|
def initialize(selenium_driver)
|
||||||
super
|
super()
|
||||||
@selenium = selenium_driver
|
@selenium = selenium_driver
|
||||||
define_location_strategies
|
define_location_strategies
|
||||||
end
|
end
|
||||||
@ -11,6 +11,8 @@ module Webrat
|
|||||||
@selenium.open(url)
|
@selenium.open(url)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
alias_method :visit, :visits
|
||||||
|
|
||||||
def fills_in(field_identifier, options)
|
def fills_in(field_identifier, options)
|
||||||
locator = "webrat=#{Regexp.escape(field_identifier)}"
|
locator = "webrat=#{Regexp.escape(field_identifier)}"
|
||||||
@selenium.type(locator, "#{options[:with]}")
|
@selenium.type(locator, "#{options[:with]}")
|
||||||
@ -99,6 +101,9 @@ module Webrat
|
|||||||
candidateLabels = candidateLabels.sortBy(function(s) { return s.length * -1; }); //reverse length sort
|
candidateLabels = candidateLabels.sortBy(function(s) { return s.length * -1; }); //reverse length sort
|
||||||
var locatedLabel = candidateLabels.first();
|
var locatedLabel = candidateLabels.first();
|
||||||
var labelFor = locatedLabel.getAttribute('for');
|
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);
|
return selenium.browserbot.locationStrategies['id'].call(this, labelFor, inDocument, inWindow);
|
||||||
JS
|
JS
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user