Class: Page
- Inherits:
-
Object
- Object
- Page
- Defined in:
- lib/core/PageObject.rb
Instance Attribute Summary collapse
-
#browser ⇒ Object
Returns the value of attribute browser.
-
#elements ⇒ Object
Returns the value of attribute elements.
-
#name ⇒ Object
Returns the value of attribute name.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #FindElement(name) ⇒ Object
- #Go ⇒ Object
-
#initialize(browser, pageobject) ⇒ Page
constructor
A new instance of Page.
- #VerifyTitle ⇒ Object
- #VerifyURL ⇒ Object
Constructor Details
#initialize(browser, pageobject) ⇒ Page
Returns a new instance of Page.
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
# File 'lib/core/PageObject.rb', line 318 def initialize(browser, pageobject) @browser = browser @name = pageobject['page']['name'] @url = pageobject['page']['url'] @title = pageobject['page']['title'] @elements = Hash.new if pageobject.key? 'elements' for object in pageobject['elements'] element = Element.new(self, object) if @elements.key? element.name Log.Info "#{@name}\nDuplicate element name: '#{element.name}'" else @elements[element.name] = element end end end end |
Instance Attribute Details
#browser ⇒ Object
Returns the value of attribute browser.
316 317 318 |
# File 'lib/core/PageObject.rb', line 316 def browser @browser end |
#elements ⇒ Object
Returns the value of attribute elements.
316 317 318 |
# File 'lib/core/PageObject.rb', line 316 def elements @elements end |
#name ⇒ Object
Returns the value of attribute name.
316 317 318 |
# File 'lib/core/PageObject.rb', line 316 def name @name end |
#title ⇒ Object
Returns the value of attribute title.
316 317 318 |
# File 'lib/core/PageObject.rb', line 316 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
316 317 318 |
# File 'lib/core/PageObject.rb', line 316 def url @url end |
Instance Method Details
#FindElement(name) ⇒ Object
349 350 351 352 353 354 355 356 |
# File 'lib/core/PageObject.rb', line 349 def FindElement(name) if @elements.key? name return @elements[name] end raise "Element not found in list: '#{name}'\n" return nil end |
#Go ⇒ Object
339 340 341 342 343 344 345 346 347 |
# File 'lib/core/PageObject.rb', line 339 def Go() begin @browser.goto @url rescue Timeout::Error raise "Page load timeout\nURL: #{@url} (15 sec)\n" end return true end |
#VerifyTitle ⇒ Object
358 359 360 361 362 363 364 365 366 367 |
# File 'lib/core/PageObject.rb', line 358 def VerifyTitle() @browser.windows.last.use if @title == @browser.title return true end Log.Failed("Title not matched", @browser.title, @title) return false end |
#VerifyURL ⇒ Object
369 370 371 372 373 374 375 376 377 378 379 380 381 382 |
# File 'lib/core/PageObject.rb', line 369 def VerifyURL() @browser.windows.last.use uri = URI(@url) url = "#{uri.scheme}://#{uri.host}#{uri.path}" begin Watir::Wait.until(15) { browser.url.include? url } return true rescue Log.Failed("URL not matched", @browser.url, url) return false end end |