lib/bauxite/core/selector.rb in bauxite-0.4.2 vs lib/bauxite/core/selector.rb in bauxite-0.4.3
- old
+ new
@@ -23,12 +23,13 @@
module Bauxite
# Selector common state and behavior.
module SelectorModule
# Constructs a new test selector instance.
- def initialize(ctx)
+ def initialize(ctx, default_selector)
@ctx = ctx
+ @default = default_selector
end
# Searches for elements using the specified selector string.
#
# For more information see Context#find.
@@ -45,13 +46,17 @@
# end
# # === end selectors/example.rb === #
#
def find(selector, &block)
data = selector.split('=', 2)
- type = data.length == 2 ? data[0] : "default"
+ type = data[0]
+ arg = data[-1]
+ unless data.length == 2 and type =~ /^[a-z_]+$/i
+ type = @default
+ arg = selector
+ end
raise ArgumentError, "Invalid selector type '#{type}'" unless Context::selectors.include? type
- arg = data[-1]
custom_selectors = Context::selectors(false)
return send(type , arg, &block) if custom_selectors.include? type
return send(type+'_selector', arg, &block) if custom_selectors.include? type+'_selector'
selenium_find(type, arg, &block)
end
\ No newline at end of file