Skip to content
This repository has been archived by the owner on Jun 6, 2018. It is now read-only.

Commit

Permalink
move .base_index method from Browser to IE to make #_no_wait methods …
Browse files Browse the repository at this point in the history
…work
  • Loading branch information
jarmo committed Jul 25, 2011
1 parent ff97c45 commit 5760dcb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 0 additions & 4 deletions commonwatir/lib/watir/browser.rb
Expand Up @@ -84,10 +84,6 @@ def options
klass.options
end

def base_index
options[:zero_based_indexing] ? 0 : 1
end

def klass
key = Watir.options[:browser]
eval @@browser_classes[key] # this triggers the autoload
Expand Down
4 changes: 4 additions & 0 deletions watir/lib/watir/ie-class.rb
Expand Up @@ -58,6 +58,10 @@ def self.zero_based_indexing
@@zero_based_indexing
end

def self.base_index
self.zero_based_indexing ? 0 : 1
end

# Used internally to determine when IE has finished loading a page
READYSTATES = {:complete => 4}

Expand Down
10 changes: 5 additions & 5 deletions watir/lib/watir/locator.rb
Expand Up @@ -30,7 +30,7 @@ def match_with_specifiers?(element)

def set_specifier(how, what=nil)
specifiers = what ? {how => what} : how
@specifiers = {:index => Watir::Browser.base_index} # default if not specified
@specifiers = {:index => Watir::IE.base_index} # default if not specified
normalize_specifiers! specifiers
end

Expand Down Expand Up @@ -76,7 +76,7 @@ def each
def locate
return locate_by_xpath_css_ole if @specifiers[:xpath] || @specifiers[:css] || @specifiers[:ole_object]

count = Watir::Browser.base_index - 1
count = Watir::IE.base_index - 1
each do |element|
count += 1
return element.ole_object if count == @specifiers[:index]
Expand Down Expand Up @@ -136,7 +136,7 @@ def each
def locate
return locate_by_xpath_css_ole if @specifiers[:xpath] || @specifiers[:css] || @specifiers[:ole_object]

count = Watir::Browser.base_index - 1
count = Watir::IE.base_index - 1
each do |frame|
count += 1
return frame.ole_object, frame.document if count == @specifiers[:index]
Expand Down Expand Up @@ -187,7 +187,7 @@ def element.locate; @o; end
def locate
return locate_by_xpath_css_ole if @specifiers[:xpath] || @specifiers[:css] || @specifiers[:ole_object]

count = Watir::Browser.base_index - 1
count = Watir::IE.base_index - 1
each do |element|
count += 1
return element.ole_object if count == @specifiers[:index]
Expand Down Expand Up @@ -226,7 +226,7 @@ def fast_locate

the_id = @specifiers[:id]
if the_id && the_id.class == String &&
@specifiers[:index] == Watir::Browser.base_index && @specifiers.length == 2
@specifiers[:index] == Watir::IE.base_index && @specifiers.length == 2
@element = @document.getElementById(the_id) rescue nil
# Return if our fast match really HAS a matching :id
return true if @element && @element.invoke('id') == the_id && @types.include?(@element.getAttribute('type'))
Expand Down

0 comments on commit 5760dcb

Please sign in to comment.