Site - Web site project class¶
Similar to Page, Site contains useful functions on the site-level. An example would look like:
from sda.page import Page
from sda.site import Site
from sda.structures import *
from selenium import webdriver
class MyPage(Page):
def __init__(self, driver):
Page.__init__(self, driver, '/category/sub-category/page') # Make sure that this is the path only
self.bar = Button(driver, '//button[@id="buttonBar"]')
class MySite(Site):
def __init__(self, driver):
Site.__init__(self, driver)
self.foo = MyPage(driver)
wd = webdriver.Firefox()
site = MySite(wd)
# Click 'Bar' button on page 'Foo'
site.foo.bar.click()
sda.site
-
class
sda.site.
Site
(web_driver, **kwargs)¶ Bases:
sda.element.SeleniumObject
The Site Implementation
The intention for the Site object is to contain all website pages. An example usage of this might be:
Let’s say we have the following file structure
- my_project
- __init__.py
- main.py
- page_1
- __init__.py
- fixtures.py
- locators.py
- page.py
- page_2
- __init__.py
- fixtures.py
- locators.py
- page.py
- site
- __init__.py
- site.py
- settings.py
site/site.py
from sda.site import Site from page_1.page import Page1 from page_2.page import Page2 class ExampleSite(Site): def __init__(self, web_driver): super(ExampleSite, self).__init__(web_driver) self.page_1 = Page1(web_driver) self.page_2 = Page2(web_driver)
-
domain
¶ Returns the domain for a website
Returns: domain Return type: str
-
path
¶ Returns the website path
Returns: path Return type: str
-
url
¶ Current page URL
Returns: Page URL Return type: str