Method: Sapphire::WebAbstractions::RubySeleniumWebDriver#ShouldNavigateTo

Defined in:
lib/sapphire/Adapters/Selenium/RubySeleniumWebDriver.rb

#ShouldNavigateTo(page, comparator) ⇒ Object



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/sapphire/Adapters/Selenium/RubySeleniumWebDriver.rb', line 125

def ShouldNavigateTo(page, comparator)

  $page = GetValue(page, nil)
  $page ||= page

  timeout = GetValue(page, :wait)
  timeout ||= 20

  $page.Init

  wait = Selenium::WebDriver::Wait.new(:timeout => timeout)
  begin
    item = wait.until {
      x = self.CurrentUrl.upcase.start_with?($page.Url.upcase)
      y = StartsWithComparison.new(Evaluation.new(self.CurrentUrl.upcase, $page.Url.upcase))
      if(comparator.Compare(x == false, true))
        $page.AlternateUrls.each do |url|
          if(comparator.Compare(x == false, true))
            x = self.CurrentUrl.upcase.start_with?(url.upcase)
            y = StartsWithComparison.new(Evaluation.new(self.CurrentUrl.upcase, url.upcase))
          end
        end
      end

      return y if comparator.Compare(x == true, true)
    }
  rescue
    temp = StartsWithComparison.new(Evaluation.new(self.CurrentUrl, $page.Url))
    return temp
  end

  temp = item
  return temp
end