Skip to content
Find file
80 lines (63 sloc) 2.41 KB
#!/usr/bin/env python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at
Created on Jun 21, 2010
from import WebDriverWait
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import ElementNotVisibleException
class Page(object):
Base class for all Pages.
def __init__(self, testsetup):
self.testsetup = testsetup
self.base_url = testsetup.base_url
self.services_base_url = testsetup.services_base_url
self.selenium = testsetup.selenium
self.timeout = testsetup.timeout
def get_url(self, url):
def is_the_current_page(self):
WebDriverWait(self.selenium, self.timeout).until(
lambda s: s.title == self._page_title,
"Expected page title: %s. Actual page title: %s" % (self._page_title, self.selenium.title))
return True
def get_url_current_page(self):
WebDriverWait(self.selenium, self.timeout).until(lambda s: self.selenium.title)
return self.selenium.current_url
def is_element_present(self, *locator):
return True
except NoSuchElementException:
return False
# set back to where you once belonged
def is_element_visible(self, *locator):
return self.selenium.find_element(*locator).is_displayed()
except (NoSuchElementException, ElementNotVisibleException):
return False
def return_to_previous_page(self):
class PageRegion(object):
_root_locator = None
def __init__(self, testsetup, root=None):
self.testsetup = testsetup
self.selenium = testsetup.selenium
self.timeout = testsetup.timeout
self.root_element = root
def root(self):
if self.root_element is None and self._root_locator is not None:
self.root_element = self.selenium.find_element(*self._root_locator)
return self.root_element
Jump to Line
Something went wrong with that request. Please try again.