Page - Web page class¶
Pages are considered the scaffolding for interacting with web pages as a whole. While the class is not necessary in creating testing frameworks, it does contain a few useful functions such as validating that the browser is in view of that page. An example would look like:
from sda.page import Page
from sda.structures import *
from selenium import webdriver
class HelloWorld(Page):
def __init__(self, driver):
Page.__init__(self, driver, '/category/sub-category/page') # Make sure that this is the path only
self.foo = Button(driver, '//button[@id="buttonFoo"]')
wd = webdriver.Firefox()
h = HelloWorld(wd)
# Click 'Foo' button
h.foo.click()
sda.page
-
class
sda.page.
Page
(web_driver, url_path=u'/')¶ Bases:
sda.element.SeleniumObject
The Page Implementation
-
elements
()¶ Returns all testable elements on a page
Returns: Dictionary of WebElements Return type: dict
-
in_view
()¶ Returns True if the driver is currently within the scope of this page
Returns: True, if driver on page Return type: bool
-
static
is_element
(attrib=None)¶ Returns True if the class attribute is a valid locator
Parameters: attrib – Class attribute Returns: True, if the class attribute is a valid locator Return type: bool
Navigate to path
Returns:
-
title
¶ Return page title
Returns: Page title Return type: str
-
url
¶ Current page URL
Returns: Page URL Return type: str
-