Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 43 lines (33 sloc) 1.335 kb
b38dc72 @davehunt Created tests for logging in and logging out.
davehunt authored
1 #!/usr/bin/env python
a3145ae Updating imports to use from <filename> import <method>
Glenn Howard authored
2
9d83222 MPL2 licence migration
Zac authored
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
b38dc72 @davehunt Created tests for logging in and logging out.
davehunt authored
6
757232b Wait for page title to be present.
Zac authored
7 from selenium.webdriver.support.ui import WebDriverWait
bc61758 @glennhoward test to ensure no results are returned for a blank search.
glennhoward authored
8 from selenium.common.exceptions import NoSuchElementException
c46449b @davehunt Reordered imports, and removed superfluous assertion message.
davehunt authored
9 from unittestzero import Assert
b38dc72 @davehunt Created tests for logging in and logging out.
davehunt authored
10
dd80388 @davehunt PEP8 fixes.
davehunt authored
11
b38dc72 @davehunt Created tests for logging in and logging out.
davehunt authored
12 class Page(object):
13
14 def __init__(self, testsetup):
15 self.testsetup = testsetup
16 self.base_url = testsetup.base_url
17 self.selenium = testsetup.selenium
77e14cb Updating project structure to resemble other projects structure.
Glenn Howard authored
18 self.timeout = testsetup.timeout
b38dc72 @davehunt Created tests for logging in and logging out.
davehunt authored
19
20 @property
21 def is_the_current_page(self):
757232b Wait for page title to be present.
Zac authored
22 if self._page_title:
77e14cb Updating project structure to resemble other projects structure.
Glenn Howard authored
23 WebDriverWait(self.selenium, self.timeout).until(lambda s: s.title)
757232b Wait for page title to be present.
Zac authored
24
c46449b @davehunt Reordered imports, and removed superfluous assertion message.
davehunt authored
25 Assert.equal(self.selenium.title, self._page_title)
757232b Wait for page title to be present.
Zac authored
26 return True
b38dc72 @davehunt Created tests for logging in and logging out.
davehunt authored
27
28 def is_element_visible(self, locator):
29 try:
77e14cb Updating project structure to resemble other projects structure.
Glenn Howard authored
30 return self.selenium.find_element(*locator).is_displayed()
b38dc72 @davehunt Created tests for logging in and logging out.
davehunt authored
31 except:
32 return False
bc61758 @glennhoward test to ensure no results are returned for a blank search.
glennhoward authored
33
34 def is_element_present(self, *locator):
35 self.selenium.implicitly_wait(0)
36 try:
37 self.selenium.find_element(*locator)
38 return True
39 except NoSuchElementException:
40 return False
41 finally:
42 self.selenium.implicitly_wait(self.testsetup.default_implicit_wait)
Something went wrong with that request. Please try again.